在 delphi 语言里,判断 *** 作系统是否64位,可以通过 kernel32.dll 系统库中提供 IsWow64Process 函数来确宴碰定。
关于 IsWow64Process 的函数功用说明如下:
据此,编写的 判断 *** 作系统是32位还是64位 功能函数代码如下:
function 握困IsWOW64: BOOLbegin
Result := False
if GetProcAddress(GetModuleHandle(kernel32), 'IsWow64Process') <> nil then
IsWow64Process(GetCurrentProcess, Result)
end
示例调用晌皮谈代码:
运行代码截图:
需举裂毕要注意是GetNativeSystemInfo 函数从Windows XP 开始才有, 而 IsWow64Process 函数从Windows XP with SP2 以及 Windows Server 2003 with SP1 开始才有。
所以使用该正芹函数的时候最好用源带GetProcAddress 。
function IsWin64: Boolean
var
Kernel32Handle: THandle
IsWow64Process: function(Handle: Windows.THandlevar Res: Windows.BOOL): Windows.BOOLstdcall
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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)