The window call API lists all current process examples

  • 2020-04-02 02:19:05
  • OfStack


#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <tlhelp32.h>
void PrintProcessList();
int main(){
 PrintProcessList();
 system("pause");
 return 0;
}
void PrintProcessList(){
 HANDLE pHandle;
 PROCESSENTRY32 proc;
 DWORD procId;
 pHandle = CreateToolhelp32Snapshot(0x2,0x0);
 if(pHandle==INVALID_HANDLE_VALUE){
  return;
 }
 proc.dwSize = sizeof(PROCESSENTRY32);
 while(Process32Next(pHandle,&proc)){
  printf("ProcessName : %s - ProcessID : %drn",proc.szExeFile,proc.th32ProcessID);
 }
 CloseHandle(pHandle);
 return;
}


Related articles: