Determine whether the Windows operating system is 32-bit or 64-bit

Source: Internet
Author: User

functionIswin64:boolean;varKernel32handle:thandle; Iswow64process:function(Handle:Windows.THandle;varRes:Windows.BOOL): Windows.bool;stdcall; Getnativesysteminfo:procedure(varLpsysteminfo:tsysteminfo);stdcall;  Iswow64:bool; Systeminfo:tsysteminfo;ConstProcessor_architecture_amd64=9; Processor_architecture_ia64=6;beginKernel32handle:= GetModuleHandle ('KERNEL32. DLL'); ifKernel32handle =0  ThenKernel32handle:= LoadLibrary ('KERNEL32. DLL'); ifKernel32handle <>0  Then  beginiswow64process:= GetProcAddress (Kernel32handle,'iswow64process'); Getnativesysteminfo:= GetProcAddress (Kernel32handle,'Getnativesysteminfo'); ifAssigned (iswow64process) Then    beginiswow64process (GETCURRENTPROCESS,ISWOW64); Result:= isWoW64 andAssigned (Getnativesysteminfo); ifResult Then      beginGetnativesysteminfo (SystemInfo); Result:= (Systeminfo.wprocessorarchitecture = processor_architecture_amd64)or(Systeminfo.wprocessorarchitecture=processor_architecture_ia64); End; End    ElseResult: =False; End  ElseResult: =False;End;

http://blog.csdn.net/suiyunonghen/article/details/4870219

There are many such codes and discussions on the web, especially the use of iswow64process functions.

Suddenly think: Only 32-bit EXE at runtime to determine whether the OS is 32 or 64bit?

If the exe itself is 64bit, then the runtime does not have to judge at all, the OS must be 64-bit, otherwise it can not run at all.

So, I feel that many discussions on the internet is a bit superfluous?

Determine whether the Windows operating system is 32-bit or 64-bit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.