Process name from ID?

I'm trying to get a process name from (what i think) is the PID i get

1
2
		HWND Tabbed = GetForegroundWindow();
		printf("Open Window!: %d", Tabbed);

The code above outputs numbers instead of Notepad or Console or what ever when i want it to say Notepad or the actual name of the process
Last edited on
To get the PID from a HWND use GetWindowThreadProcessId.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633522(v=vs.85).aspx

Then you can create a snapshot of system processes and iterate over them, comparing the PID returned above.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686701(v=vs.85).aspx
Topic archived. No new replies allowed.