How to detect 64-bit OS


A 32-bit application can detect whether it is running under WOW64 by calling the IsWow64Process function. The application can obtain additional information about the processor by using the GetNativeSystemInfo


The IsWow64Process function is only included in Windows OS that have 64-bit versions. To avoid an error we have to check for it presence with GetProcAddress / GetModuleHandle

WIN API functions before it can be called.



* First determine if IsWow64Process function exists in the OS we're running under
DECLARE Long GetModuleHandle IN WIN32API STRING lpModuleName
DECLARE Long GetProcAddress IN WIN32API Long hModule, String lpProcName
llIsWow64ProcessExists = (GetProcAddress(GetModuleHandle("kernel32"),"IsWow64Process") <> 0)

llIs64BitOS = .F.
IF llIsWow64ProcessExists 
	DECLARE Long GetCurrentProcess IN WIN32API 
	DECLARE Long IsWow64Process IN WIN32API Long hProcess, Long @ Wow64Process
	lnIsWow64Process = 0
	* IsWow64Process function return value is nonzero if it succeeds 
	* The second output parameter value will be nonzero if VFP application is running under 64-bit OS 
	IF IsWow64Process( GetCurrentProcess(), @lnIsWow64Process) <> 0
		llIs64BitOS = (lnIsWow64Process <> 0)
? llIs64BitOS 


The MSDN says on IsWow64Process API page: "Note that this technique is not a reliable way to detect whether the operating system is a 64-bit version of Windows because the Kernel32.dll in current versions of 32-bit Windows also contains this function."

You're quoting out of context. The full quote: "For compatibility with operating systems that do not support this function, call GetProcAddress to detect whether IsWow64Process is implemented in Kernel32.dll. If GetProcAddress succeeds, it is safe to call this function. Otherwise, WOW64 is not present. Note that this technique is not a reliable way to detect whether the operating system is a 64-bit version of Windows because the Kernel32.dll in current versions of 32-bit Windows also contains this function".
IOW, just checking for presence of IsWow64Process() function in the Kernel32.dll is not reliable way to detect 64-bit OS. OTOH, using the IsWow64Process() in 32-bit application to detect 64-bit OS is fine.

You're mistaken. WOW64 is the subsystem that runs 32-bit processes on 64bits. IsWow64Process *does not* tell you whether you're running on a 64bit OS, because native 64bit processes will return "false". The correct function is GetNativeSystemInfo.

Mistaken about what? This article is relevant to 32-bit applications only. It's obvious that 64-bit application runs under 64-bit version of Windows.

Your statement "using the IsWow64Process() to detect 64-bit OS is fine" is false, because if the same code is compiled in 32bits and 64bits, when compiled in 64bits it will fail. That needs to be made clear.

The code is Visual FoxPro. Do you have a VFP 64bit compiler? Have you tested it on your VFP 64bit compiler and it failed? If so, please let us all know! Otherwise, this is an great solution and unless someone has a better idea, I reccomend it! Works great for me.

Very useful code to determine 64bits OS.
Thanks for sharing.


Thank you for sharing; Your VFP contributions are numerous and always excellent!!!

Greetings from San Juan, Puerto Rico - USA

thanks for the nice sharing Sergey!


Thanks for sharing the code to detect OS 64 bits, very much useful to me, for the application I am doing, which has module that doesn't work on 64 bit.

Form: Di

In my program I need to check whether OS is 64 bit or 32 bit for win xp and vista.

So basically i need to differentiate between xp 32, xp 64,vista32 and vista 64.

Based on this i want to install specific system drivers.

How can I do this ? Is registry entries can be used if yes which one?

Any help is appreciated.

See and

The windows API function GetVersionEx, in combination with the info in this article, should tell you everything you need.
__inout LPOSVERSIONINFO lpVersionInfo
typedef struct _OSVERSIONINFOEX {
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
TCHAR szCSDVersion[128];
WORD wServicePackMajor;
WORD wServicePackMinor;
WORD wSuiteMask;
BYTE wProductType;
BYTE wReserved;