hi ,

I am using SYSTEM_INFO structure to know the processor architecture of machine. I did this

SYSTEM_INFO sys;
memset(&sys,0,sizeof(sys));
GetSystemInfo(&sys);

For Intel Pentium machine it is giving right information i.e.
sys.dwActiveProcessorMask 3
sys.dwAllocationGranularity 65536
sys.dwNumberOfProcessors 2
sys.dwProcessorType 586
sys.wProcessorArchitecture 0
sys.wProcessorLevel 15
sys.wReserved 0

but running this code on AMD Athelon(tm) 64 processor giving this wrong output
sys.dwActiveProcessorMask 1
sys.dwAllocationGranularity 65536
sys.dwNumberOfProcessors 1
sys.dwProcessorType 586
sys.wProcessorArchitecture 0
sys.wProcessorLevel 15
sys.wReserved 0

What am I doing wrong? I just want to know the processor architecture(x64 or x86). Is there any other way to find this.

Recommended Answers

All 11 Replies

Almost all modern consumer-grade processors are x64 architecture with an x86 subset. Whether you are processing x64 or x86 instructions depends on if the operating system is written for 64 or 32 bits respectively.

As Fbody says, are you running 32-bit windows on your 64-bit processor?

Thanks for reply!
are you running 32-bit windows on your 64-bit processor?
Salem,
I am using Windows 2003 Ent X64 edition. Both machine and OS is compatible with X64 architecture.

Guys,
One thing i was forgot to mention that wProcessorRevision
In case of 32-bit machine it is 1031 and in case of 64bit it is 20226.

I am going through MSDN and trying to understand this difference but not getting exactly the meaning.

Just to be sure, what does IsWow64Process say?

I found that it is totally depend upon OS Architecture. No other ways i found.

Ok do you mean the binary is 32 bit or 64 bit? I am running 32 bit version of my exe on x86 and x64 processor.

Ok do you mean the binary is 32 bit or 64 bit? I am running 32 bit version of my exe on x86 and x64 processor.

OK, since it is a 32 bit binary, try GetNativeSystemInfo(), read the full documentation on GetNativeSystemInfo()/GetSystemInfo().
If you won't be needing a 32 bit binary, then compile it into 64 bit and use GetSystemInfo().

hey thanks for your great help.
It is working fine after compile it as 64bit version. Now the o/p is

sys.dwActiveProcessorMask 1
sys.dwAllocationGranularity 65536
sys.dwNumberOfProcessors 1
sys.dwProcessorType 8664
sys.wProcessorArchitecture 9 - which means AMD64
sys.wProcessorLevel 15
sys.wReserved 0
sys.wProcessorRevision 20226

But if in case of 64bit processor and 32bit OS then this will fail. Thoughts? What would be the solution in this case?

Oops you already told about GetNativeSystemInfo function. In that case we shoud use this function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.