Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.42 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, Registry;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     Label1: TLabel;
  14.     procedure FormCreate(Sender: TObject);
  15.   private
  16.     { Private declarations }
  17.   public
  18.     { Public declarations }
  19.   end;
  20.  
  21.     TOSInfo = class(TObject)
  22.   public
  23.     class function IsWOW64: Boolean;
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29.  
  30. implementation
  31.  
  32. {$R *.dfm}
  33.  
  34. class function TOSInfo.IsWOW64: Boolean;
  35. type
  36.   TIsWow64Process = function(
  37.     Handle: THandle;
  38.     var Res: BOOL
  39.   ): BOOL; stdcall;
  40. var
  41.   IsWow64Result: BOOL;
  42.   IsWow64Process: TIsWow64Process;
  43. begin
  44.   IsWow64Process := GetProcAddress(
  45.     GetModuleHandle('kernel32'), 'IsWow64Process'
  46.   );
  47.   if Assigned(IsWow64Process) then
  48.   begin
  49.     if not IsWow64Process(GetCurrentProcess, IsWow64Result) then
  50.       raise Exception.Create('Bad process handle');
  51.     Result := IsWow64Result;
  52.   end
  53.   else
  54.     Result := False;
  55. end;
  56.  
  57. procedure TForm1.FormCreate(Sender: TObject);
  58. begin
  59.   if TOSInfo.IsWOW64 = True then begin
  60.   Label1.Caption := 'You are on a x64 machine.';
  61.   //ShowMessage('Running on 64-bit OS!!');
  62.   Button1.Enabled := False;
  63. end
  64.  else
  65.   begin
  66.   Label1.Caption := 'You are not on a x64 machine.';
  67.   //ShowMessage('NOT running on 64-bit OS!!');
  68.   Button2.Enabled := False;
  69. end;
  70. end;
  71.  
  72. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement