salut
j'utilise openthread pour avoir un handle pour suspendre le thread dans le code suivant. Mais ca ne marche pas toujours.
Des fois, open thread renvoit un handle nul.
Est ce que quelqu'un saurait comment faire pour que ca marche toujours,et si il faut activer sedebugprivileges alors comment faut il faire?
{
HANDLE hThreadSnap = NULL; THREADENTRY32 te32 = {0};
hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (hThreadSnap == INVALID_HANDLE_VALUE) return ;
te32.dwSize = sizeof(THREADENTRY32);
if (Thread32First(hThreadSnap, &te32))
{
do
{
if (te32.th32OwnerProcessID == dwOwnerPID)
{
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te32.th32ThreadID);
SuspendThread(hThread);
CloseHandle(hThread);
}
}
while (Thread32Next(hThreadSnap, &te32));
}
else
{
// bRet = FALSE;
a(" could not walk the list of threads");
}
CloseHandle (hThreadSnap);
//CloseHandle(leproc);
}
Partager