I am trying to compile a small program using the minGw compiler with Code :: Blocks. My program is as follows:
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
int main()
{
HWND hwnd = FindWindowA(NULL, "A Valid Window Title");
printf("Window Handle=%X\n", hwnd);
DWORD pid = 0;
GetWindowThreadProcessId(hwnd, &pid);
printf("PID=%d\n", pid);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
printf("Process HANLDE=%X\n", hProcess);
GetProcessId(hProcess);
CloseHandle(hProcess);
return 0;
}
However, when I try to compile, Code :: Blocks gives an error undefined reference to GetProcessId. If I delete the call GetProcessId, the program compiles and starts normally. I thought this error message was caused by an incorrect search. So I went to my settings and added
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
C:\Program Files (x86)\Windows Kits\8.1\Include\um
. Code:: Blocks . , . Kernel32.lib User32.lib . . , GetProcessId, , GetProcessId 
?