public delegate IntPtr WndProcHandler(IntPtr hWnd,Int32 msg,Int32 wParam,Int32 lParam);
        public static WndProcHandler NewWndProc = null;
        public static IntPtr OldWndProc = IntPtr.Zero;
private void Form1_Load(object sender, EventArgs e)
        {
            IntPtr lResult;
            lhandl = this.Handle;
            lResult = ShellExecute(lhandl, "open", "WX.exe", lhandl.ToString(), null, System.Convert.ToInt32(SW_SHOWNORMAL));
            this.Tag = Hook(this.Handle);
        }
        public IntPtr Hook(IntPtr hWnd)
        {
            NewWndProc = new WndProcHandler(MyWindowProc);
            Debug.Assert(NewWndProc != null);
            OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC, NewWndProc);
            SetWindowLong(hWnd, GWL_USERDATA, (WndProcHandler)Marshal.GetDelegateForFunctionPointer((IntPtr)OldWndProc, typeof(WndProcHandler)));
            return OldWndProc;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            Process[] ps = Process.GetProcesses();
            foreach (Process item in ps)
            {
                if (item.ProcessName == "WX")
                {
                    item.Kill();
                }
            }
        }
        public IntPtr MyWindowProc(IntPtr hWnd, Int32 msg, Int32 wParam, Int32 lParam)
        {
            IntPtr returnVar = IntPtr.Zero;
            IntPtr lpPrevWndProc = IntPtr.Zero;
            switch (msg)
            {
                case WMA_InterPro:
                txtHook.Text = txtHook.Text + "hw=" + hWnd + ";uMsg=" + msg + ";wParam=" + wParam + ";lParam=" + lParam + "\r\n";
                break;            }
            lpPrevWndProc = GetWindowLong(hWnd,GWL_USERDATA);
            returnVar = CallWindowProc(lpPrevWndProc, hWnd, msg, wParam, lParam);
            return returnVar;
        }在SetWindowLong(hWnd, GWL_USERDATA, (WndProcHandler)Marshal.GetDelegateForFunctionPointer((IntPtr)OldWndProc, typeof(WndProcHandler)));
这句时总是提示我“传递给运行时且要转换为委托的函数指针 0xffff0315 无效。传递要转换为委托的无效函数指针会导致崩溃、损坏或数据丢失”我刚刚接触API这块,有点不太明白,请高手指教