使用Python调用工作目录下所有快捷方式

本文介绍了一种使用Python调用工作目录下所有快捷方式(lnk文件)的方法。通过使用ShellExecute函数,可以轻松实现这一目标。该函数属于Win32 API,并详细解释了其参数意义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用Python调用工作目录下所有快捷方式

方法就是使用ShellExecute,类似VC,Python调用Windows API也很简单。

 

ActivePython 2.5 Documentation 中关于ShellExecute函数的说明:

 

win32api.ShellExecute

 

int = ShellExecute(hwnd, op , file , params , dir , bShow )

 

Opens or prints a file.

 

Parameters

 

hwnd : int

The handle of the parent window, or 0 for no parent. This window receives any message boxes an application produces (for example, for error reporting).

op : string

The operation to perform. May be "open", "print", or None, which defaults to "open".

file : string

The name of the file to open.

params : string

The parameters to pass, if the file name contains an executable. Should be None for a document file.

dir : string

The initial directory for the application.

bShow : int

Specifies whether the application is shown when it is opened. If the lpszFile parameter specifies a document file, this parameter is zero.

 

Win32 API References

 

Search for ShellExecute at msdn, google or google groups.

 

Return Value

The instance handle of the application that was run. (This handle could also be the handle of a dynamic data exchange [DDE] server application.) If there is an error, the method raises an exception. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值