I tried to detect from PB, if Windows is a 32 or 64 bit (x86,x64) version. Found some threads here in this forum, they tried to detect, if the process is running in WOW or not.
Found an example on MSDN and i think the definition of the SYSTEM_INFO type/structure is different in PB/C.
=> my PBCC example does not work on x64 architecture
Any hint appreciated.
Here is the C code from WinBase.h (VisualStudio 2008)
And here is my PBCC 5 code, which does not work:
Found an example on MSDN and i think the definition of the SYSTEM_INFO type/structure is different in PB/C.
=> my PBCC example does not work on x64 architecture
Any hint appreciated.
Here is the C code from WinBase.h (VisualStudio 2008)
Code:
typedef struct _SYSTEM_INFO { union { DWORD dwOemId; // Obsolete field...do not use struct { WORD wProcessorArchitecture; WORD wReserved; }; }; DWORD dwPageSize; LPVOID lpMinimumApplicationAddress; LPVOID lpMaximumApplicationAddress; DWORD_PTR dwActiveProcessorMask; DWORD dwNumberOfProcessors; DWORD dwProcessorType; DWORD dwAllocationGranularity; WORD wProcessorLevel; WORD wProcessorRevision; } SYSTEM_INFO, *LPSYSTEM_INFO;
And here is my PBCC 5 code, which does not work:
Code:
#COMPILE EXE #DIM ALL #INCLUDE "Win32API.inc" TYPE SI_Processor wProcessorArchitecture AS WORD wReserved AS WORD END TYPE TYPE SYSTEM_INFO2 dwOemID AS SI_Processor dwPageSize AS DWORD lpMinimumApplicationAddress AS DWORD lpMaximumApplicationAddress AS DWORD dwActiveProcessorMask AS DWORD dwNumberOfProcessors AS DWORD dwProcessorType AS DWORD dwAllocationGranularity AS DWORD wProcessorLevel AS WORD wProcessorRevision AS WORD END TYPE 'processor architecures stored in .wProcessorArchitecture %PROCESSOR_ARCHITECTURE_INTEL = 0 %PROCESSOR_ARCHITECTURE_MIPS = 1 %PROCESSOR_ARCHITECTURE_ALPHA = 2 %PROCESSOR_ARCHITECTURE_PPC = 3 %PROCESSOR_ARCHITECTURE_SHX = 4 %PROCESSOR_ARCHITECTURE_ARM = 5 %PROCESSOR_ARCHITECTURE_IA64 = 6 %PROCESSOR_ARCHITECTURE_ALPHA64 = 7 %PROCESSOR_ARCHITECTURE_MSIL = 8 %PROCESSOR_ARCHITECTURE_AMD64 = 9 %PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 = 10 '%PROCESSOR_ARCHITECTURE_UNKNOWN = &HFFFF FUNCTION GetOSVersion() AS STRING LOCAL osvi AS OSVERSIONINFOEX LOCAL bOsVersionInfoEx AS LONG LOCAL OSver AS STRING osvi.dwOsVersionInfoSize = SIZEOF( osvi ) bOsVersionInfoEx = GetVersionEx(osvi) IF bOsVersionInfoEx = %ERROR_OLD_WIN_VERSION THEN OSver = "-1" ELSE 'LOCAL lPlatform AS LONG 'lPlatform = osvi.dwPlatformId OSver = FORMAT$( osvi.dwMajorVersion + ( osvi.dwMinorVersion \ 10 ), "0.0" ) END IF FUNCTION = OSver END FUNCTION FUNCTION IsWindowsx64() AS LONG LOCAL si AS SYSTEM_INFO2 LOCAL arch AS LONG 'get system information GetSystemInfo BYVAL VARPTR(si) arch = si.dwOemID.wProcessorArchitecture 'STDOUT "CPUs:"+STR$(si.dwNumberOfProcessors) 'this is just for testing, if structure is still OK IF arch = %PROCESSOR_ARCHITECTURE_AMD64 OR _ arch = %PROCESSOR_ARCHITECTURE_IA64 THEN FUNCTION = %True ELSEIF arch = %PROCESSOR_ARCHITECTURE_INTEL THEN FUNCTION = %False ELSE FUNCTION = %False END IF END FUNCTION FUNCTION PBMAIN () AS LONG LOCAL WinVer AS STRING LOCAL Is64 AS LONG WinVer = GetOSVersion() Is64 = IsWindowsx64() IF Is64 THEN STDOUT "Windows x64, Version: "+WinVer ELSE STDOUT "Windows x86, Version: "+WinVer END IF WAITKEY$ END FUNCTION
Comment