Reputation: 593
I am having one form with one TEdit and one TButton. I am trying to determine OS Architecture. So I have defined the following codes as suggested by Embarcadero forum :
function OSArchitectureToStr(const a: TOSVersion.TArchitecture): string;
function OSPlatformToStr(const p: TOSVersion.TPlatform): string;
function PlatformFromPointer: integer;
.
.
.
.
.
function OSArchitectureToStr(const a: TOSVersion.TArchitecture): string;
begin
case a of
arIntelX86: Result := 'Intel X86';
arIntelX64: Result := 'Intel X64';
else
Result := 'UNKNOWN OS Aarchitecture';
end;
end;
function OSPlatformToStr(const p: TOSVersion.TPlatform): string;
begin
case p of
pfWindows: Result := 'Windows';
pfMacOS: Result := 'MacOS';
else
Result := 'UNKNOWN OS Platform';
end;
end;
function PlatformFromPointer: integer;
begin
Result := SizeOf(Pointer) * 8;
end;
.
.
.
.
.
procedure TMainForm.BitBtn1Click(Sender: TObject);
begin
Edit1.Text := OSPlatformToStr(TOSVersion.Platform) + ' ' + IntToStr(PlatformFromPointer) + ' Bit';
end;
But the problem is that It results always 32Bit OS though it is 64Bit OS. Please help me.
Upvotes: 0
Views: 2207
Reputation: 1
In order to obtain an application (process) in 32-bit and / or 64-bit version, you need to add the appropriate compiler to the project in the project. In the * .dproj - Project window, select the Target Platforms item and add Windows 64-bit (of course you must have the option installed) Now you can set target platform to 32-bit or 64-bit
Upvotes: 0
Reputation: 109002
You (erroneously!) use the following to get the architecture:
function PlatformFromPointer: integer;
begin
Result := SizeOf(Pointer) * 8;
end;
Now, in a 32-bit application, SizeOf(Pointer)
equals 4
, while in a 64-bit application, it equals 8
. So this only examines what type of application you are writing, not what OS it is running on! (So, obviously, your application is 32-bit. And that has nothing to do with the OS being 32-bit or 64-bit.)
You probably want to investigate TOSVersion.Architecture
instead. But you don't. In fact, you never use it (or OSArchitectureToStr
!) at all.
What you want is OSArchitectureToStr(TOSVersion.Architecture)
.
Upvotes: 5