使用CreateToolhelp32Snapshot却陷入死循环,求助
HANDLE hSnapShot = ::CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS , 0);
PROCESSENTRY32 stProcess;
stProcess.dwSize = sizeof(PROCESSENTRY32);
::Process32First( hSnapShot , &stProcess);
HANDLE hTargetProcess;
while(hSnapShot )
{
if ( stProcess.szExeFile == "draw.exe" ||stProcess.szExeFile == "DRAW.EXE")
{
hTargetProcess = ::OpenProcess( PROCESS_VM_READ | PROCESS_VM_WRITE , NULL , stProcess.th32ProcessID);
::DuplicateHandle(::GetCurrentProcess(), memDC.GetSafeHdc() , hTargetProcess , (void**)&hdc , NULL , NULL , DUPLICATE_SAME_ACCESS);
}
::Process32Next(hSnapShot , &stProcess );
}
::CloseHandle(hSnapShot);
顺便弱弱的问一句DuplicateHandle的用法,第四个参数hdc应该是另一个进程中的句柄吗?那它在这个进程是应该是不可见的呀。