Last active
August 29, 2015 14:14
-
-
Save romasvrd/8060ea3dd85131818281 to your computer and use it in GitHub Desktop.
Ожидание завершения процесса
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void asdf(void) | |
{ | |
HANDLE hSnap; | |
HANDLE hViewer; | |
uint16_t pid; | |
hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); | |
if (hSnap == NULL) | |
{ | |
//return 0; | |
} | |
PROCESSENTRY32 ProcessEntry; | |
if (Process32First(hSnap, &ProcessEntry)) | |
{ | |
do | |
{ | |
//сравниваем имя процесса с нужным | |
if(strcmp(ProcessEntry.szExeFile,"ArcDataViewer.exe")==0) | |
{ | |
//получаем его pid | |
pid = ProcessEntry.th32ProcessID; | |
//получаем его handle | |
hViewer=OpenProcess(PROCESS_ALL_ACCESS,false,pid); | |
//функция вернет управление, когда процесс завершится. Лучше запихнуть её в отдельный поток, чтобы прога не висла | |
WaitForSingleObject(hViewer,INFINITE); | |
} | |
} | |
while (Process32Next(hSnap, &ProcessEntry)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment