I'm writing a game. When it starts up, I want to call the Windows 10 GetCurrentPackageFullName()
function to see if my app is running as a Universal Windows Program or not.
However, GetCurrentPackageFullName()
does not exist in Windows 7 and earlier, so when people run my game on their systems, they get this error:
Is there a way to avoid this error by first checking if the function even exists in kernel32.dll
and if not then simply not call it? I've tried the following but it doesn't seem to work:
try {
//do we even have this function?
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
PGNSI pGNSI;
SYSTEM_INFO si;
ZeroMemory(&si, sizeof(SYSTEM_INFO));
pGNSI = (PGNSI) GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "GetCurrentPackageFullName");
//ok this exists, now let's use it
if(pGNSI != NULL) {
//then I call the function here
}
} catch (int e) {
//do nothing, just don't crash
}