Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Getting Processor architecture in x86 and x64 bit platform.

By , 19 Oct 2010
Rate this:
Please Sign up or sign in to vote.
I found this at Microsoft MSDN somewhere. The Code is C#, but should be easy to port to C++.
[DllImport("kernel32")] private static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("kernel32")] private static extern int GetProcAddress(HANDLE hModule, string lpProcName);
[DllImport("kernel32")] private static extern int IsWow64Process(HANDLE hProcess, out bool Wow64Process);
public static bool Is64BitOs() 
			bool bReturnValue = false;
			System.Text.StringBuilder oPath = new System.Text.StringBuilder();
			IntPtr iHandle = GetModuleHandle(oPath.ToString());
			int iAddress = GetProcAddress(iHandle, "IsWow64Process");
			if (iAddress != 0) 
				bool bResult = false;
					IsWow64Process(System.Diagnostics.Process.GetCurrentProcess().Handle, out bResult);
				catch {}
				if (bResult) bReturnValue = true;
			return bReturnValue;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Nenad L.
Architect STZ Rechnereinsatz, Esslingen
Germany Germany
Studied Computer Science at the University of Stuttgart (specialized in Software Engineering and Computer Graphics), went through lots of Languages (Java, Modula, Prolog, Lisp, Basic, Smalltalk, VB, C#, C++ and even Assembler for the beloved 6502, 68000 and HP 9000 RISC), now grown up to a classic System- and Software-Architect Smile | :)

Comments and Discussions

GeneralReason for my vote of 4 Good start, but not complete: if the... PinmemberSauro Viti25-Oct-10 22:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140421.2 | Last Updated 19 Oct 2010
Article Copyright 2010 by Nenad L.
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid