6

我正在尝试使用 GetProcessImageFileName。我已经包含了 Psapi.h 但是当我尝试 ti compile 我得到

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

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

4

1 回答 1

6

这是一个链接器故障(它确实编译)并且与包含Psapi.h. 您可能需要链接到Psapi.lib.

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

Windows 7 和 Windows Server 2008 R2 上的 Kernel32.lib;
Windows 7 和 Windows Server 2008 R2 上的 Psapi.lib(如果 PSAPI_VERSION=1);
Psapi.lib 在 Windows Server 2008、Windows Vista、Windows Server 2003、
和 Windows XP
于 2012-09-17T15:17:46.093 回答