今天遇到一个问题,就是我想获得线程ID,但是GetWindowThreadProcessId()的第二个参数我该怎么写?我写null但是有错误,谢谢解答!

解决方案 »

  1.   

    refer:
    [DllImport("User32.dll", CharSet = CharSet.Auto)]
            public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);        [DllImport("user32.dll", EntryPoint = "FindWindow")]
            private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);        static void Main(string[] args)
            {
                IntPtr hwnd = FindWindow(null, "计算器");
                if (hwnd != IntPtr.Zero)
                {
                    int calcID;
                    //获取进程ID  
                    GetWindowThreadProcessId(hwnd, out calcID);
                }
            }
      

  2.   

    分给了,但是好像不行哦,你看看:Error 2 Argument 2 must be passed with the 'out' keyword
      

  3.   

    那就结帖给分吧。
    还是有错误:Error 2 Argument 2 must be passed with the 'out' keyword
      

  4.   

    那就结帖给分吧。
    还是有错误:Error 2 Argument 2 must be passed with the 'out' keyword
    不好意思,我错了,我看走眼了,解决了!!谢谢