Run the Spy program Notice that this provides a static displ
Run the Spy++ program. Notice that this provides a static display of information. To update the information, hit the \"Refresh\" button. (Leave this tool running through question 3.) How many processes are running? List the fraction of time that the idle process spends in privileged time and in user time and explain what this information is telling you. What is the base priority of the idle process? What is the Spy++ process ID? How many threads are running in the Spy++ process?
Solution
DWORD aProcesses[1024], cbNeeded, cProcesses; unsigned int i; if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) { // } else { for(int i = 0; i < 1024; i++) { DWORD processID = aProcesses[i]; WCHAR szProcessName[50]; // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if (NULL != hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) ) { GetModuleFileNameExW(hProcess, hMod, szProcessName, cbNeeded); } } } }