#include <windows.h> 
#include <tlhelp32.h> 
#include <boost/process.hpp> 
#include <iostream> 

using namespace boost::process; 

int main() 
{ 
  HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 
  if (handle == INVALID_HANDLE_VALUE) 
    return 1; 

  PROCESSENTRY32 entry; 
  entry.dwSize = sizeof(entry); 
  if (!Process32First(handle, &entry)) 
    return 2; 

  do 
  { 
    process p(entry.th32ProcessID); 
    std::cout << p.get_id() << std::endl; 
  } 
  while (Process32Next(handle, &entry)); 

  CloseHandle(handle); 
} 