Thanks in advance!

解决方案 »

  1.   

    GetWindowThreadProcessId and openprocess
      

  2.   

    http://www.china-askpro.com/msg1/qa60.shtml
        无法得到任意进程的线程句柄。如果得到了一个线程句柄,就可以利用API函数对该线程进行操作,而在拥有该线程的程序不知道的情况下可能会导致严重问题,所以Windows不允许这样做。可以使用CreateToolhelp32Snapshot、Thread32First和Thread32Next(在VC++中这几个函数定义在tlhelp32.h中。)得到所有线程的ThreadID,但没有办法从ID得到句柄,这同进程有所不同。如果真的要得到句柄,必须从线程的创建者或线程本身得到,并使两个程序协同工作。此外,应用程序可以调用DebugActiveProcess()来控制一个进程,在该进程创建线程时可以得到进程句柄。 
      

  3.   

    The OpenProcess function returns a handle to an existing process object. HANDLE OpenProcess(
      DWORD dwDesiredAccess,  // access flag
      BOOL bInheritHandle,    // handle inheritance flag
      DWORD dwProcessId       // process identifier
    );