代码如下:public class Common
{
    public const int WM_USER = 0x400;
    public const int WM_REWRITENPC = WM_USER + 1000;    [DllImport("user32", EntryPoint = "FindWindow", SetLastError = false,
    CharSet = CharSet.Auto, ExactSpelling = false,
    CallingConvention = CallingConvention.StdCall)]
    public static extern int FindWindow(
        string lpClassName,
        string lpWindowName
    );    [DllImport("user32", EntryPoint = "PostMessage", SetLastError = false,
    CharSet = CharSet.Auto, ExactSpelling = false,
    CallingConvention = CallingConvention.StdCall)]
    public static extern int PostMessage(
        IntPtr hWnd,
        int wMsg,
        int wParam,
        int lParam
    );
}在button事件调用:
int id=1;
int hwnd = Common.FindWindow(null, "PAYSERVER");
IntPtr h = new IntPtr(hwnd);
Common.PostMessage(h, Common.WM_REWRITENPC, id, 0);
在本地调试没有任何问题,发布到服务器上就不行了,
我调试了下发现根本取不到句柄(hwnd总是0),后来我通过其他途径先把窗口句柄取到,然后发消息,也是不行,没反映。
请大家帮忙