[fpc-pascal] Function to know if WIN is 32 or 64
Marcos Douglas
md at delfire.net
Tue Mar 15 16:46:05 CET 2011
On Tue, Mar 15, 2011 at 11:47 AM, DaWorm <daworm at gmail.com> wrote:
> I've used this in Delphi 32 and it seems to work. Forgot where I
> pulled the basic info. Probably doesn't do much on native 64 bit.
>
> function Is64BitOS: Boolean;
> type
> TIsWow64Process = function(Handle:THandle; var IsWow64 : BOOL) :
> BOOL; stdcall;
> var
> hKernel32 : Integer;
> IsWow64Process : TIsWow64Process;
> IsWow64 : BOOL;
> begin
> // we can check if the operating system is 64-bit by checking whether
> // we are running under Wow64 (we are 32-bit code). We must check if this
> // function is implemented before we call it, because some older versions
> // of kernel32.dll (eg. Windows 2000) don't know about it.
> // see http://msdn.microsoft.com/en-us/library/ms684139%28VS.85%29.aspx
> Result := False;
> hKernel32 := LoadLibrary('kernel32.dll');
> if (hKernel32 = 0) then RaiseLastOSError;
> @IsWow64Process := GetProcAddress(hkernel32, 'IsWow64Process');
> if Assigned(IsWow64Process) then
> Begin
> IsWow64 := False;
> if (IsWow64Process(GetCurrentProcess, IsWow64)) then
> Result := IsWow64
> end;
> FreeLibrary(hKernel32);
> end;
Thanks Jeff, this also works and seems to be standard function to know
if is a 32 or 64bits
See http://msdn.microsoft.com/en-us/library/ms684139%28v=vs.85%29.aspx
Marcos Douglas
More information about the fpc-pascal
mailing list