[fpc-pascal] Function to know if WIN is 32 or 64
Marcos Douglas
md at delfire.net
Tue Mar 15 16:19:16 CET 2011
On Tue, Mar 15, 2011 at 12:05 PM, Sven Barth
<pascaldragon at googlemail.com> wrote:
>> Weird. This code did not compile in this line:
>> @GNSIProc := GetProcAddress(GetModuleHandle('kernel32.dll'),
>> 'GetNativeSystemInfo');
>>
>> Error: unit1.pas(46,2) Error: Can't assign values to an address
>>
>>
>
> Just a guess:
> Add {$mode delphi} at the top.
>
> Another solution would be:
> GNSIProc := TGNSIProc(GetProcAddress(...));
I forgot... =( I just copied the code from Delphi to Lazarus... sorry.
I used the second solution.
>>> This ignores ia64, as you can see.
>>
>> What is ia64?
>
> A 64-bit architecture developed by Intel and supported by Windows server
> systems (although it should be dropped with one of the next versions?!) and
> Linux systems.
>
> Also see here:
> http://en.wikipedia.org/wiki/IA64
Right. But is better ignore the IA64?
I found this code to Delphi:
const
PROCESSOR_ARCHITECTURE_AMD64 = 9;
{$EXTERNALSYM PROCESSOR_ARCHITECTURE_AMD64}
PROCESSOR_ARCHITECTURE_IA64 = 6;
{$EXTERNALSYM PROCESSOR_ARCHITECTURE_IA64}
function GetNativeSystemInfo(var SystemInfo: TSystemInfo): Boolean;
type
TGetNativeSystemInfo = procedure (var SystemInfo: TSystemInfo) stdcall;
var
LibraryHandle: HMODULE;
_GetNativeSystemInfo: TGetNativeSystemInfo;
begin
Result := False;
LibraryHandle := GetModuleHandle(kernel32);
if LibraryHandle <> 0 then
begin
_GetNativeSystemInfo := GetProcAddress(
LibraryHandle, 'GetNativeSystemInfo');
if Assigned(_GetNativeSystemInfo) then
begin
_GetNativeSystemInfo(SystemInfo);
Result := True;
end
else
GetSystemInfo(SystemInfo);
end
else
GetSystemInfo(SystemInfo);
end;
function IsWindows64: Boolean;
var
ASystemInfo: TSystemInfo;
begin
GetNativeSystemInfo(ASystemInfo);
Result := ASystemInfo.wProcessorArchitecture in
[PROCESSOR_ARCHITECTURE_IA64, PROCESSOR_ARCHITECTURE_AMD64];
end;
So, IA64 is 6. That is correct?
Marcos Douglas
More information about the fpc-pascal
mailing list