在C#中如何调用API函数CreateEvent
在MSDN的帮助中看到:
HANDLE CreateEvent(
LPSECURITY_ATTRIBUTES lpEventAttributes,
BOOL bManualReset,
BOOL bInitialState,
LPTSTR lpName);
我如下引入:
[ DllImport("kernel32") ]
public static extern IntPtr CreateEvent(ref SECURITY_ATTRIBUTES secatt,bool bManualReset,bool bInitialState,StringBuilder lpName);
[StructLayout(LayoutKind.Sequential) ]
public struct SECURITY_ATTRIBUTES
{
uint nLength;
IntPtr lpSecurityDescriptor;
bool bInheritHandle;
}
调用:
IntPtr hNotify=CreateEvent(null,false,true,new StringBuilder(""));
编译时说CreateEvent有无效参数,请大侠指教