我怎样才能知道,如果我在x64上运行? [英] How can I tell if I'm running on x64?
问题描述
我刚刚得到一个bug报告,只有当程序运行时出现的问题在64位机器上。现在,Delphi的不产生64位code,所以从理论上说不应该的问题,但显然它在这种情况下。我觉得我有一个解决办法,但它会破坏东西在32位的Windows,所以我需要一些方法来告诉:
I just got a bug report for an issue that only occurs when the program is running "on a 64-bit machine." Now, Delphi doesn't produce 64-bit code, so theoretically that shouldn't matter, but apparently it does in this case. I think I have a workaround, but it will break things on 32-bit Windows, so I need some way to tell:
- 如果我在x64或x86处理器和 运行
- 如果我在Windows下的Win32仿真或本机Win32 64位版本,在32位操作系统上运行。
有谁知道我怎么能得到这些问题的答案从我的应用程序吗?
Does anyone know how I can get those answers from within my app?
推荐答案
梅森,你可以使用的 IsWow64Process (WOW64是x86模拟器,允许32位基于Windows的应用程序在64位Windows上无缝运行)
Mason, you can use IsWow64Process (WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows)
Uses Windows;
type
WinIsWow64 = function( Handle: THandle; var Iret: BOOL ): Windows.BOOL; stdcall;
function IAmIn64Bits: Boolean;
var
HandleTo64BitsProcess: WinIsWow64;
Iret : Windows.BOOL;
begin
Result := False;
HandleTo64BitsProcess := GetProcAddress(GetModuleHandle('kernel32.dll'), 'IsWow64Process');
if Assigned(HandleTo64BitsProcess) then
begin
if not HandleTo64BitsProcess(GetCurrentProcess, Iret) then
Raise Exception.Create('Invalid handle');
Result := Iret;
end;
end;
再见。
这篇关于我怎样才能知道,如果我在x64上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!