delphi 中判断windows系统是否是64位系统
2016-04-27 14:19
671 查看
function IsWin64: Boolean;
var
Kernel32Handle: THandle;
IsWow64Process: function(Handle:THandle; var Res:BOOL):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 函数从Windows XP 开始才有,
//而 IsWow64Process 函数从 Windows XP with SP2 以及 Windows Server 2003 with SP1 开始才有。
//所以使用该函数的时候最好用GetProcAddress 。
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;
var
Kernel32Handle: THandle;
IsWow64Process: function(Handle:THandle; var Res:BOOL):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 函数从Windows XP 开始才有,
//而 IsWow64Process 函数从 Windows XP with SP2 以及 Windows Server 2003 with SP1 开始才有。
//所以使用该函数的时候最好用GetProcAddress 。
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;
相关文章推荐
- [转]HMAC functions in Delphi (HMAC_SHA256, HMAC_SHA1)
- 如何使DELPHI程序在Win7下自动请求以管理员身份运行
- delphi 动态结构数组例程
- delphi.memory.分配及释放---New/Dispose, GetMem/FreeMem及其它函数的区别与相同,内存分配函数
- Delphi指针详解
- Delphi通过MSHTML实现一个HTML解析类
- Delphi 10.1 Berlin 官方未列之修正
- 注册表写入二进制数据
- Delphi中动态调用DLL的方法
- delphi TeeChart保存3种图片文件
- 在Delphi中利用MSDASC来配置数据库链接
- Delphi 编写ActiveX控件(OCX控件)的知识和样例
- Delphi 编写DLL动态链接库文件的知识和样例
- Delphi 变体类型(Variant)的介绍(流与变体类型的相互转换、变体类型常用的函数)
- Delphi 编写ActiveForm窗体工程知识和样例(开发浏览器客户端应用程序)
- Delphi 接口技术
- Delphi COM编程技术六(DCOM技术)
- Delphi COM编程技术五(ActiveX技术)
- Delphi COM编程技术四自动化技术
- Delphi COM编程技术三类型库