我使用以下代码来判断Windows是32位还是64位:
我购买并安装了64位的Windows 7 - 然而,上面的代码显示0,意味着我的操作系统是32位的...该怎么处理?
好的,我的其他尝试基本上也不起作用...在我的64位Windows 7上,我只看到32位...
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
static int is64bitOS()
{
SYSTEM_INFO si;
GetSystemInfo(&si);
if((si.wProcessorArchitecture & PROCESSOR_ARCHITECTURE_IA64)||(si.wProcessorArchitecture & PROCESSOR_ARCHITECTURE_AMD64)==64)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
printf("%d\n", is64bitOS());
return 0;
}
我购买并安装了64位的Windows 7 - 然而,上面的代码显示0,意味着我的操作系统是32位的...该怎么处理?
好的,我的其他尝试基本上也不起作用...在我的64位Windows 7上,我只看到32位...
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
int getArchType1()
{
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
switch(sysInfo.wProcessorArchitecture)
{
case 6:
return 64;
case 9:
return 64;
case 0:
return 32;
default:
return -1;
}
}
static char *getArchType2()
{
char *archType = malloc(sizeof(char) * (255));
memset(archType, '\0', 255);
#if defined _WIN64
strcpy(archType, "64-bit");
#else
strcpy(archType, "32-bit");
#endif // defined
return archType;
}
int main()
{
char *arch = getArchType1();
printf("%s\n", arch);
free(arch);
printf("%d\n", getArchType2());
char c;
scanf("%c", &c);
return 0;
}