CodeBlock undefined refers to a Windows API function, even if the search directory is configured

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 enter image description here

?

+4
1

GetProcessId Windows XP SP1. , , #define WINVER 0x0501, . .h , *.cpp

#define WINVER 0x0501

#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>

int main()
{
...
}

---- .

+1

Source: https://habr.com/ru/post/1629797/


All Articles