private static  GetMsgProc intHOOK = new GetMsgProc(myHOOK);public void startHook()
        {//Process[] po=Process.GetProcessesByName("notepad");
        //foreach (Process e1 in po)
       // {
                  
        
          
            using(Process mb=Process.GetCurrentProcess())
            using(ProcessModule pm=mb.MainModule)
            {
                useHandle = SetWindowsHookEx(WH_GETMESSAGE, intHOOK, GetModuleHandle(pm.ModuleName), GetWindowThreadProcessId( FindWindowEx(FindWindow(null,"无标题-记事本"), 0, "Edit", null), 0));
        }
            }
        private const int WM_KEYDOWN = 100;
        private enum MouseMessages
        {
            PM_NOREMOVE = 0x00000000,
       PM_REMOVE=0x00000001
        }        public static IntPtr myHOOK(int code, IntPtr wParam, IntPtr lParam)
        {
            MsgHookStruct MyMsgHookStruct = (MsgHookStruct)Marshal.PtrToStructure(lParam, typeof(MsgHookStruct));            if (code < 0)
            {
                return CallNextHookEx(useHandle, code, wParam, lParam);
            }
             if((code>=0)&& ((MouseMessages)wParam== MouseMessages.PM_REMOVE)) 
            { //{switch ( MyMsgHookStruct.message)
                // {case WM_KEYDOWN:
                MessageBox.Show("MyMsgHookStruct.pt.x.ToString()");
                // break;
                // }
                // }
             
               
            }
            return CallNextHookEx(useHandle, code, wParam, lParam);
        }
我想对进程中的记事本窗口设置HOOK , 为什么一使用hook就自动关闭VS程序,或者自动关闭记事本程序,或者还没有调用peekmessage或者getmessage的时候,MessageBox.Show("MyMsgHookStruct.pt.x.ToString()")就会自动执行了?