日期:2014-05-19  浏览次数:21085 次

在C#中调用ShellExecute
哪位在C#中调用过windows   API函数ShellExecute,
请指教一下具体应该怎样声明,怎样调用?

------解决方案--------------------
www.pinvoke.net

C# Signature:
public enum ShowCommands : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11
}

[DllImport( "shell32.dll ")]
static extern IntPtr ShellExecute(
IntPtr hwnd,
string lpOperation,
string lpFile,
string lpParameters,
string lpDirectory,
ShowCommands nShowCmd);


VB Signature:
Declare Function ShellExecuteA Lib "shell32.dll " ( _
ByVal hWnd As IntPtr, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Integer) As IntPtr


User-Defined Types:
None.

例子见:
http://www.pinvoke.net/default.aspx/shell32/ShellExecute.html