利用パソコンが32ビットOSか、64ビットOSか

解決


cocomo  2012-03-27 20:38:59  No: 41850  IP: [192.*.*.*]

タイトル通りなのですか、利用パソコンが32ビットOSか、64ビットOSか判定する関数を探しています。
OSVERSIONINFO で取れるかと思いましたが、うまくいきませんでした。
x86 or x64 か調べる事はできるのでしょうか

編集    削除
ぽむぽむ  2012-03-27 20:59:57  No: 41851  IP: [192.*.*.*]

つIsWow64Process

編集    削除
cocomo  2012-03-27 21:57:22  No: 41852  IP: [192.*.*.*]

ぽむぽむさん、こんにちは。ヒントありがとうございます。
IsWow64Processを使って解決する事ができました。
サンプルソースです。

type
  TIsWow64Process = function(
    Handle: THandle;
    var Res: BOOL
  ): BOOL; stdcall;

function IsWOW64: Boolean;
var
  IsWow64Result: BOOL;
  IsWow64Process: TIsWow64Process;
begin
  IsWow64Process := GetProcAddress(
    GetModuleHandle('kernel32'), 'IsWow64Process'
  );
  if Assigned(IsWow64Process) then
  begin
    if not IsWow64Process(GetCurrentProcess, IsWow64Result) then
      raise Exception.Create('Bad process handle');
    Result := IsWow64Result;
  end
  else
    Result := False;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
  if IsWOW64 = True then
  ShowMessage('Running on 64-bit OS!!')
  else
  ShowMessage('NOT running on 64-bit OS!!');
end;

編集    削除