取得mobile系统进程列表(名称、路径、ID)

    技术2022-05-11  6

    HANDLE hSnapshot = NULL; PROCESSENTRY32 processinfo ; processinfo.dwSize = sizeof (processinfo) ;

    //创建镜像 hSnapshot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0) ;

     if ( NULL == hSnapshot) {  return -1; }

     BOOL bStatus = Process32First( hSnapshot, &processinfo) ; wstring wstrProcessInfo = L""; TCHAR tchBuf[500] = { 0 }; DOUBLE dProcessID = 0; HANDLE hProcess = 0; while ( bStatus) {    if ( 0 == dProcessID)  {   wstrProcessInfo = processinfo.szExeFile;//保存结果(第一个进程名称)  }  else  {   wstrProcessInfo += processinfo.szExeFile;//保存结果  }   wstrProcessInfo += L",";  dProcessID = processinfo.th32ProcessID;//进程id  swprintf( tchBuf, L"%0.0f", dProcessID);  wstrProcessInfo += tchBuf;  wstrProcessInfo += L",";

      hProcess = OpenProcess( PROCESS_TERMINATE, FALSE, processinfo.th32ProcessID);   GetModuleFileName( (HMODULE)hProcess, tchBuf, 256); //路径  wstrProcessInfo += tchBuf;  wstrProcessInfo += L"|";  CloseHandle( hProcess);  bStatus = Process32Next( hSnapshot, &processinfo);

     }

     CloseToolhelp32Snapshot( hSnapshot);

     


    最新回复(0)