Skip to content

hwloc-ps using native Windows API #367

Open
@bgoglin

Description

@bgoglin

Possible code proposed by Eloi Gaudry a long time ago (was previously in contrib/windows/README):

  // Get the process list snapshot
  HANDLE hProcessSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
  // Initialize the process entry structure
  PROCESSENTRY32 ProcessEntry = { 0 } ;
  ProcessEntry.dwSize = sizeof(ProcessEntry);
  // Get the first process info
  if (Process32First( hProcessSnapShot, &ProcessEntry)) {
    do {
      HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ProcessEntry.th32ProcessID) ;
      if (hProcess) {
        std::cerr << ProcessEntry.th32ProcessID << "(" << ProcessEntry.szExeFile << ")" << std::endl ;
      }
      // check the PROCESSENTRY32 for other members.
    } while (Process32Next(hProcessSnapShot, &ProcessEntry));
    // Close the handle
    CloseHandle( hProcessSnapShot ) ;
  }

This is only for the native MSVC build. On cygwin, see #335.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions