我一直在互联网上搜索,不知道为什么会这样,这并不是一个明显的阵列问题。
功能如下:
BOOL IsOsCompatible()
{
BOOL retVal = 0;
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx(&osvi);
if(osvi.dwMajorVersion == 6)
{
if(osvi.dwMinorVersion == 0)
{
if(SendErrorM("This program has not been tested on Windows Vista(TM).\nAre you sure you want to use it?",MB_YESNO) == IDYES)
retVal = 1;
}
else if(osvi.dwMinorVersion == 1)
{
retVal = 1;
}
else if(osvi.dwMinorVersion == 2)
{
if(SendErrorM("This program has not been tested on Windows 8(TM).\nAre you sure you want to use it?",MB_YESNO) == IDYES)
retVal = 1;
}
}
else
SendErrorM("Your windows verison is incompatible with the minimum requirements of this application.",NULL);
return retVal;
}
有任何想法吗?
最佳答案
OSVERSIONINFOEX
大于OSVERSIONINFO
,因此
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
将在“外部”(大约)
osvi
中写入零。你要
OSVERSIONINFOEX osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
或(通常更安全)
OSVERSIONINFOEX osvi;
ZeroMemory(&osvi, sizeof(osvi));