获取进程图像文件名未链接

GetProcessImageFileName not linking

本文关键字:链接 文件名 图像 取进程 获取      更新时间:2023-10-16

>我试图使用 GetProcessImageFileName。我已经包含了 Psapi.h,但是当我尝试 ti 编译时,我得到

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:TestmainTests.exe : fatal error LNK1120: 1 unresolved externals

该函数出现在 Itellisense 中,所以谁能告诉我为什么它不会编译?

这是一个

链接器故障(它确实编译),与包含Psapi.h无关。您可能需要链接到Psapi.lib

有关要链接到哪个库的具体说明,请参阅GetProcessImageFileName()参考页面中的部分:

Windows 7 和 Windows Server 2008 R2 上的 Kernel32.lib;Psapi.lib(如果 PSAPI_VERSION=1)在 Windows 7 和 Windows Server 2008 R2 上;Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003,和视窗XP