function Tmain.IsWin64: Boolean;
var
Kernel32Handle: THandle;
IsWow64Process: function(Handle: Windows.THandle; var Res: Windows.BOOL): Windows.BOOL; stdcall;
GetNativeSystemInfo: procedure(var lpSystemInfo: TSystemInfo); stdcall;
isWoW64: Bool;
SystemInfo: TSystemInfo;
const
PROCESSOR_ARCHITECTURE_AMD64 = 9;
PROCESSOR_ARCHITECTURE_IA64 = 6;
begin
Kernel32Handle := GetModuleHandle('KERNEL32.DLL');
if Kernel32Handle = 0 then
Kernel32Handle := LoadLibrary('KERNEL32.DLL');
if Kernel32Handle <> 0 then
begin
IsWOW64Process := GetProcAddress(Kernel32Handle,'IsWow64Process');
GetNativeSystemInfo := GetProcAddress(Kernel32Handle,'GetNativeSystemInfo');
if Assigned(IsWow64Process) then
begin
IsWow64Process(GetCurrentProcess,isWoW64);
Result := isWoW64 and Assigned(GetNativeSystemInfo);
if Result then
begin
GetNativeSystemInfo(SystemInfo);
Result := (SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or
(SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64);
end;
end
else Result := False;
end
else Result := False;
end;
判断操作系统是否是64位的函数
这是一个使用Delphi编写的函数,用于判断当前运行的操作系统是否为64位。函数通过获取并调用`KERNEL32.DLL`库中的`IsWow64Process`和`GetNativeSystemInfo`函数,结合处理器架构信息来确定系统是否为64位。
摘要由CSDN通过智能技术生成