GetProcessImageFileName not bound

I am trying to use GetProcessImageFileName. I have included Psapi.h, but when I try to compile, I get

error LNK2019: unresolved external symbol _GetProcessImageFileNameA@12 referenced in function "bool __cdecl FindProcesses(char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" ( ?FindProcesses@ @ YA_NPBDPAV?$basic_string@DU ?$char_traits@D @ std@ @ V?$allocator@D @ 2@ @ std@ @@Z)99>G:\Test\main\Tests.exe : fatal error LNK1120: 1 unresolved externals 

The function appears in Itellisense, so can someone tell me why it does not compile?

+4
source share
1 answer

This is a linker failure (it compiles) and is not related to the inclusion of Psapi.h . You probably need to link to Psapi.lib .

For specific instructions about which library you can link to, see the "Library" section of the GetProcessImageFileName() help page:

  Kernel32.lib on Windows 7 and Windows Server 2008 R2; 
 Psapi.lib (if PSAPI_VERSION = 1) on Windows 7 and Windows Server 2008 R2; 
 Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003,
 and Windows XP
+4
source

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


All Articles