在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有无效参数,请大侠指教

解决方案 »

  1.   

    问题已经解决,本来是为了写注册表监视程序才用到API的,现在 发现这路不太通,用别的方法了
    请来者领分,偶也可结贴,不过你得贴点好的代码噢
    关于如何监视注册表,请大家到我的另一贴子http://community.csdn.net/Expert/topic/3864/3864295.xml?temp=.9699976
    上看看,相信你看后也能写出注册表监视程序
      

  2.   

    [DllImport("kernel32.dll")]
    static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);再试试
      

  3.   

    你定义的CreateEvent第一个参数是一个引用参数,但在你调用的时候你居然使用null,显然不行,ref参数必须是一个具体对象(实例),不能是null.