Geeks With Blogs

@gkhanna
  • gkhanna Nabia made excellent chocolate strawberries! about 2026 days ago
  • gkhanna Trying out www.digsby.com about 2128 days ago

News
WinToolZone - Spelunking Microsoft Technologies
I work as a developer on the Common Language Runtime (CLR) team, specifically in the areas of exception handling and CLR hosting.
Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Inside and Out... An attempt to understand technology better...
Want to know if you are running on 32bit or 64bit Windows? Here's how:

SYSTEM_INFO si;

GetSystemInfo(&si);
printf("You are running %dbit Windows\n",(((si.wProcessorArchitecture & PROCESSOR_ARCHITECTURE_IA64)||(si.wProcessorArchitecture & PROCESSOR_ARCHITECTURE_AMD64)))?64:32);


Ofcourse, you need Windows XP or Windows Server 2003 for this to work.
Posted on Wednesday, July 14, 2004 8:54 AM 32bit , 64bit | Back to top


Comments on this post: 32bit or 64bit - That is the question...

# re: 32bit or 64bit - That is the question...
Requesting Gravatar...
Of course this breaks once a new 64-bit processor gets added. (Who knows, maybe Alpha AXP will return someday.) Better is to call IsWow64Process().
Left by Raymond Chen on Jul 14, 2004 10:01 AM

# re: 32bit or 64bit - That is the question...
Requesting Gravatar...
Hi Raymond!

The problem in question is to understand if a process is running under 32bit or 64bit Windows.

IsWow64Process will return true if the 32bit process is running WOW64 emulation. If a 64bit process will call this API, it will return false since 64bit processes will run native on 64bit Windows and not under WOW64.

So, how does the 64bit process know if the running Windows version is 32bit or 64bit?

Definitely, if the process will use IsWow64Process as the criterion, it will return false which would imply that the process is *not* running on 64bit Windows. And as you wil agree, that's incorrect.

So, using GetSystemInfo is a better way to know this. Ofcourse, if in the future another 64bit flavour is added, the API will be updated for the same. And these kinds of updates have always happened, if we see the history of the API.


Left by Gaurav Khanna on Jul 14, 2004 11:33 AM

# re: 32bit or 64bit - That is the question...
Requesting Gravatar...
Um, a 64-bit process knows that it's running under 64-bit Windows because it is running. 32-bit Windows cannot run 64-bit programs.
Left by Raymond Chen on Sep 27, 2004 11:30 AM

# re: 32bit or 64bit - That is the question...
Requesting Gravatar...
http://weblogs.asp.net/oldnewthing/archive/2005/02/01/364563.aspx shows how to tell if you're running on 64 bit Windows.
Left by David Walker on Feb 04, 2005 12:55 AM

# re: 32bit or 64bit - That is the question...
Requesting Gravatar...
Getting the OS Version works OK to get
the Windows XP 64 version, don't know about future 64 bit OS.
That is all I have to work with right now, and
working OK.
The problem I have is getting the CSIDL_PROGRAM_FILES folger, it
returns Peogram Files (86) instead. Reading a small article in Installshield, it says you need a 64 bit executable to make it work.
Left by Ted on Dec 09, 2005 9:38 AM

# re: 32bit or 64bit - That is the question...
Requesting Gravatar...
how woud someone determine if a 64 bit processor was running a 32 bit version of windows?
Left by jim gay on Mar 08, 2006 9:55 PM

# re: 32bit or 64bit - That is the question...
Requesting Gravatar...
Use IsOs in shlwapi.dll and call with OS_WOW6432 (30) ...:)

To detect the procesor as 64 bit, use GetSystemInfo and check wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 (9) or wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 (7)

These are not the same.... 32 bit OS can run on 64 bit processor.

constant values given for you vb types.
Left by Nchantim on Feb 28, 2007 11:13 PM

# re: 32bit or 64bit - That is the question...
Requesting Gravatar...
HELLO, COULD SOME HELP ME??...I JUST BOUGHT A NEW COMPUTOR AND IT HAS WINDOWS VISTA HOME PREMIUM 32 BIT WITH 2GB OF RAM...BUT MY PROCESSOR IS A 64 BIT...SHOULD I UPGRADE TO 64BIT SOFTWARE(WINDOWS VISTA ULTIMATE) TO HAVE BETTER LIVE VIDEO QAULITY??..WHATS THE ADVANTAGES AND DISADVANTAGES???...PLEASE HELP...
Left by KEVIN on Jul 05, 2007 5:52 PM

Your comment:
 (will show your gravatar)
 


Copyright © Gaurav Khanna | Powered by: GeeksWithBlogs.net | Join free