使用Python調用工作目錄下所有快捷方式

使用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. 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章