I am new to wine. So, I would appreciate suggestions regarding my coding style if that's not-so-perfect according to wine standards. Or any other problems with the code I have written. I apologize for submitting an untested code earlier. I hope now it works fine.
/*-------------------------------------------CODE--------------------------------------------------*/
�� �� SIZE_T �� �� ��count; �� �� ��/*index to maintain the last entry of the array;*/
�� �� list->size = 4; �� �� �� �� �� ��/*initialise size with 4. Will increase if necessary.*/
�� �� list->pid = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list->size * sizeof(list->pid));
�� �� list->pid = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list->pid, list->size * sizeof(list->pid));
}
static void process_list_append(process_list *list, DWORD id) {
�� �� if(list->count == list->size)
�� �� �� �� increase_list_size(list);
�� �� list->pid[list->count] = id;
�� �� list->count += 1;
}
static void free_process_list(process_list *list) {
�� �� HeapFree(GetProcessHeap(), 0, list->pid);
}
static void enum_process_children(HANDLE snapshot, process_list *list, DWORD pid) {
�� �� PROCESSENTRY32 entry;
�� �� SIZE_T start, end, i��;
�� �� start = list->count;
�� �� entry.dwSize = sizeof(entry);
�� �� if(!Process32First(snapshot, &entry))
�� �� �� �� return;
�� �� do
�� �� { ��
�� �� �� �� if(entry.th32ParentProcessID == pid)
�� �� �� �� �� �� process_list_append(list, entry.th32ProcessID);
�� �� } while (Process32Next(snapshot, &entry));
�� �� end = list->count;
�� �� for(i = start; i < end; ++i)
�� �� {
�� �� �� �� enum_process_children(snapshot, list, list->pid[i]);
�� �� }
}
void ProcessPage_OnEndProcessTree(void)
{
�� ��{...}
�� �� process_list �� �� ��list;
�� �� SIZE_T �� �� �� �� �� �� i;
�� �� HANDLE �� �� �� �� �� snapshot;
�� ��
�� �� {...}
�� ����
�� �� init_process_list(&list);
�� �� if(list.pid == NULL)
�� �� �� �� return;
�� �� process_list_append(&list, dwProcessId);
�� �� snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
�� �� if(!snapshot)
�� �� �� �� return;
�� �� enum_process_children(snapshot, &list, dwProcessId);
�� ��
�� �� CloseHandle(snapshot);
�� �� for(i = 0; i < list.count; ++i) {
�� �� �� �� hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, list.pid[i]); �� �� �� ��
�� �� �� �� if (!hProcess)
�� �� �� �� {
�� �� �� �� �� �� GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
�� �� �� �� �� �� MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
�� �� �� �� �� �� break;
�� �� �� �� }
�� �� �� �� if (!TerminateProcess(hProcess, 0))
�� �� �� �� {
�� �� �� �� �� �� GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
�� �� �� �� �� �� MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
�� �� �� �� }
�� �� �� �� CloseHandle(hProcess);
�� �� }
�� �� free_process_list(&list);
}
/*---------------------------------------END OF CODE------------------------------------------*/
Thanks and regards
--
Akarsha Sehwag