Thanks 440bx and PascalDragon for the explanation. Learned a bit because I am new to OS and most part of Windows API.
With that said
, I think I found a quick way to determine Windows Bitness.
GetSystemWow64DirectoryA
Retrieves the path of the system directory used by WOW64. This directory is not present on 32-bit Windows.
Someone posted the ASM code and I modified it a bit and compile to EXE... if you want to test. Or perhaps can implement it in Pascal?
EDIT ON Mar 1st, 2021:The "64-bit Windows" and "32-bit Windows" text string in the EXE (compiled by Flat Assembler) do not have null byte as terminated string. That's why you might already notice on 64-bit Windows, you get "64-bit Windows. 32-bit Windows" concatenated together.
Below is the correct code (just append ",0" to the back of both text string):
(However, I am not going to re-compile and re-upload the correct version of EXE. If you like, you can compile it yourself with FASM )
format PE GUI 4.0
entry start
include '\fasm\include\win32a.inc'
section '.data' data readable writeable
a rb MAX_PATH
IS64 db '64-bit Windows',0
IS32 db '32-bit Windows',0
section '.code' code readable executable
start:
invoke GetSystemWow64Directory, a, MAX_PATH
cmp eax, 0
je NOT64
invoke MessageBox, 0, IS64, a, MB_OK
jmp exit
NOT64:
invoke MessageBox, 0, IS32, '', MB_OK
exit:
invoke ExitProcess, 0
section '.idata' import data readable
library kernel32,'kernel32.dll',\
user32,'user32.dll'
import kernel32,\
ExitProcess,'ExitProcess',\
GetSystemWow64Directory,'GetSystemWow64DirectoryA'
import user32,\
MessageBox,'MessageBoxA'