MSDN's remarks section, described here, specifically mentions there is a difference between the loading types of the following function.
Since my module is portable and loads models dynamically, I'm not allowed / able to use any pre-processors commands:
#if (PSAPI_VERSION == 2)
(GetProcAddress("kernel32.dll", OBFUSCATE(L"K32GetMappedFileNameW")));
#elif (PSAPI_VERSION == 1)
(GetProcAddress("psapi.dll", OBFUSCATE(L"GetMappedFileNameW")));
#endif
In addition -
Kernel32.dll on Windows 7 and Windows Server 2008 R2; Psapi.dll (if PSAPI_VERSION=1) on Windows 7 and Windows Server 2008 R2; Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP
Doesn't make it much clearer of how windows version is exactly coordinated with the PSAPI version.
The
GetMappedFileName()
documentation specifically says:If static linking is not an option for you, and you need to dynamically load the function at runtime without using
#ifdef
statements, then simply check both DLLs unconditionally, eg:Or, just do what the documentation says - simply ignore kernel32 altogether and just use psapi.dll by itself on all Windows versions. On Windows 7 and later,
psapi.GetMappedFileNameW()
is a wrapper forkernel32.K32GetMappedFileNameW()
.