#include <iostream>
#include <string>

#include <windows.h>
#include <tlhelp32.h>

int main(int argc, char* argv[])
{
  HANDLE snapshot = ::CreateToolhelp32Snapshot(
	TH32CS_SNAPMODULE, 0);

  if (snapshot != INVALID_HANDLE_VALUE)
  {
	MODULEENTRY32 me32{};
	me32.dwSize = sizeof(MODULEENTRY32);
	if (::Module32First(snapshot, &me32))
	{
	  do
	  {
		std::wcout << me32.szExePath << std::endl;
	  } while (::Module32Next(snapshot, &me32));
	}

	::CloseHandle(snapshot);
  }

  return EXIT_SUCCESS;
}