CpuArchitecture() returns "CPU Architecture: x86" on Windows/64bit with PB/32bit, but CpuArchitecture() should return "CPU Architecture: x64 (AMD or Intel)".
I also out-commented Itanium, MIPS, Alpha, and PowerPC - PB/Windows does not compile on those platforms, yet. (maybe #PROCESSOR_ARCHITECTURE_ARM for PB/Win8 support in the near future?
Code: Select all
; Import "Kernel32.lib"
; CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
; GetNativeSystemInfo_(*si.SYSTEM_INFO) As "_GetNativeSystemInfo@4"
; CompilerElse
; GetNativeSystemInfo_(*si.SYSTEM_INFO) As "GetNativeSystemInfo"
; CompilerEndIf
; EndImport
Declare CpuArchitecture()
Declare.s GetOsVersn()
Declare.s OSbits()
Declare.s GetOsServicePack()
Declare.s GetWindowsProductKey()
Declare.s GetCpuName()
Declare.q GetCpuNumber()
Declare.s GetPcName()
Global sgProcessorArchitecture.s = ""
Global sgPageSize.s = ""
Global sgNumberOfProcessors.s = ""
Import "kernel32.lib"
GlobalMemoryStatusEx.i(*lpBuffer)
EndImport
Procedure CpuArchitecture()
;--------------------------
#PROCESSOR_ARCHITECTURE_INTEL = 0
#PROCESSOR_ARCHITECTURE_MIPS = 1
#PROCESSOR_ARCHITECTURE_ALPHA = 2
#PROCESSOR_ARCHITECTURE_PPC = 3
#PROCESSOR_ARCHITECTURE_IA64 = 6
#PROCESSOR_ARCHITECTURE_AMD64 = 9 ; = AMD or Intel 64bit processor (std defined by AMD)
#PROCESSOR_ARCHITECTURE_UNKNOWN = $FFFF
Protected ThisSystemInfo.SYSTEM_INFO
If OSVersion() < #PB_OS_Windows_XP
GetSystemInfo_(ThisSystemInfo)
Else
;GetNativeSystemInfo_(ThisSystemInfo.SYSTEM_INFO) ; do not use 'Import', use OpenLibrary instead
Protected OK, hDLL, GetNativeSystemInfo_
hDll = OpenLibrary(#PB_Any,"kernel32.dll")
If hDll
GetNativeSystemInfo_ = GetFunction(hDll,"GetNativeSystemInfo")
If GetNativeSystemInfo_
CallFunctionFast(GetNativeSystemInfo_, ThisSystemInfo.SYSTEM_INFO)
OK = #True
EndIf
CloseLibrary(hDll)
EndIf
If Not OK
GetSystemInfo_(ThisSystemInfo)
EndIf
EndIf
Select ThisSystemInfo\wProcessorArchitecture
Case #PROCESSOR_ARCHITECTURE_AMD64 : sgProcessorArchitecture = "CPU Architecture: x64 (AMD or Intel)"
;Case #PROCESSOR_ARCHITECTURE_IA64 : sgProcessorArchitecture = "CPU Architecture: Intel Itanium"
Case #PROCESSOR_ARCHITECTURE_INTEL : sgProcessorArchitecture = "CPU Architecture: x86"
;Case #PROCESSOR_ARCHITECTURE_MIPS : sgProcessorArchitecture = "CPU Architecture: MIPS"
;Case #PROCESSOR_ARCHITECTURE_ALPHA : sgProcessorArchitecture = "CPU Architecture: ALPHA"
;Case #PROCESSOR_ARCHITECTURE_PPC : sgProcessorArchitecture = "CPU Architecture: Power PC"
Default : sgProcessorArchitecture = "CPU Architecture: Unknown"
EndSelect
sgPageSize = Str(ThisSystemInfo\dwPageSize)
sgNumberOfProcessors = Str(ThisSystemInfo\dwNumberOfProcessors)
EndProcedure
Procedure.s GetOsVersn()
;----------------------
sVersion.s = ""
Select OSVersion()
Case #PB_OS_Windows_NT3_51: sVersion = "Windows NT3.51"
Case #PB_OS_Windows_95: sVersion = "Windows 95"
Case #PB_OS_Windows_NT_4: sVersion = "Windows NT4"
Case #PB_OS_Windows_98: sVersion = "Windows 98"
Case #PB_OS_Windows_ME: sVersion = "Windows ME"
Case #PB_OS_Windows_2000: sVersion = "Windows 2000"
Case #PB_OS_Windows_XP: sVersion = "Windows XP"
Case #PB_OS_Windows_Server_2003: sVersion = "Windows Server 2003"
Case #PB_OS_Windows_Vista: sVersion = "Windows Vista"
Case #PB_OS_Windows_Server_2008: sVersion = "Windows Server 2008"
Case #PB_OS_Windows_7: sVersion = "Windows 7"
Case #PB_OS_Windows_Future: sVersion = "Windows 8"
Default: sVersion = "Windows Version not identified"
EndSelect
ProcedureReturn sVersion
EndProcedure
Procedure.s OSbits()
;-------------------
; Check if the OS is 32 or 64 bit.
;
Protected Is64BitOS = 0
Protected hDLL, IsWow64Process_
Protected sOSbits.s = "32"
If SizeOf(Integer) = 8
sOSbits = "64"
Else
hDll = OpenLibrary(#PB_Any,"kernel32.dll")
If hDll
IsWow64Process_ = GetFunction(hDll,"IsWow64Process")
If IsWow64Process_
CallFunctionFast(IsWow64Process_, GetCurrentProcess_(), @Is64BitOS)
EndIf
CloseLibrary(hDll)
EndIf
If(Is64BitOS = 1) : sOSbits = "64" : EndIf
EndIf
ProcedureReturn sOSbits
EndProcedure
Procedure.s GetOsServicePack()
;-----------------------------
OSVerInfo.OSVERSIONINFOEX
OSVerInfo\dwOSVersionInfoSize = SizeOf(OSVERSIONINFOEX)
GetVersionEx_(@OSVerInfo)
sServicePack.s = "SP" + Str(OSVerInfo\wServicePackMajor) + "." + Str(OSVerInfo\wServicePackMinor) + " [Build " + Str(OSVerInfo\dwBuildNumber) + "]"
ProcedureReturn sServicePack
EndProcedure
Procedure.s GetWindowsProductKey()
;---------------------------------
#KEY_WOW64_64KEY = $100
Protected hKey, Res, size = 280
Protected i, j, x, Result.s
Protected *mem = AllocateMemory(size)
Protected *newmem = AllocateMemory(size)
Protected *digits = AllocateMemory(25)
PokeS(*digits, "BCDFGHJKMPQRTVWXY2346789", -1, #PB_Ascii)
If OSVersion() <= #PB_OS_Windows_2000
Res = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion", 0, #KEY_READ, @hKey)
Else
Res = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion", 0, #KEY_READ | #KEY_WOW64_64KEY, @hKey)
EndIf
If Res = #ERROR_SUCCESS
RegQueryValueEx_(hKey, "DigitalProductID", 0, 0, *mem, @size)
RegCloseKey_(hKey)
If size <> 280
For i = 24 To 0 Step -1
x = 0
For j = 66 To 52 Step -1
x = (x << 8) + PeekA(*mem + j)
PokeA(*mem + j, x / 24)
x % 24
Next
PokeA(*newmem + i, PeekA(*digits + x))
Next
For i = 0 To 15 Step 5
Result + PeekS(*newmem + i, 5, #PB_Ascii) + "-"
Next
Result + PeekS(*newmem + 20, 5, #PB_Ascii)
EndIf
EndIf
FreeMemory(*mem) : FreeMemory(*newmem) : FreeMemory(*digits)
ProcedureReturn Result
EndProcedure
Procedure.s GetCpuName()
;-----------------------
Protected sBuffer.s
Protected Zeiger1.i, Zeiger2.i, Zeiger3.i, Zeiger4.i
!MOV eax, $80000002
!CPUID
; the CPU-Name is now stored in EAX-EBX-ECX-EDX
!MOV [p.v_Zeiger1], EAX ; move eax to the buffer
!MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
!MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
!MOV [p.v_Zeiger4], EDX ; move edx to the buffer
;Now move the content of Zeiger (4*4=16 Bytes to a string
sBuffer = PeekS(@Zeiger1, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
;Second Part of the Name
!MOV eax, $80000003
!CPUID
; the CPU-Name is now stored in EAX-EBX-ECX-EDX
!MOV [p.v_Zeiger1], EAX ; move eax to the buffer
!MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
!MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
!MOV [p.v_Zeiger4], EDX ; move edx to the buffer
;Now move the content of Zeiger (4*4=16 Bytes to a string
sBuffer + PeekS(@Zeiger1, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
;Third Part of the Name
!MOV eax, $80000004
!CPUID
; the CPU-Name is now stored in EAX-EBX-ECX-EDX
!MOV [p.v_Zeiger1], EAX ; move eax to the buffer
!MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
!MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
!MOV [p.v_Zeiger4], EDX ; move edx to the buffer
;Now move the content of Zeiger (4*4=16 Bytes to a string
sBuffer + PeekS(@Zeiger1, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
sCpuName.s = RemoveString(sBuffer," ",#PB_String_NoCase)
ProcedureReturn sCpuName
EndProcedure
Procedure.q GetCpuNumber()
;-------------------------
Define highbits.l
Define lowbits.l
Define serial.q
!MOV eax, $80000003
!CPUID
!MOV dword [p.v_lowbits], ecx
!MOV dword [p.v_highbits], edx
serial = lowbits | highbits << 32
ProcedureReturn serial
EndProcedure
Procedure.s GetPcName()
;----------------------
Protected sComputerName.s = GetEnvironmentVariable("COMPUTERNAME")
If sComputerName
sComputerName = "Computer Name: " + sComputerName
Else
sComputerName = "Not Found"
EndIf
ProcedureReturn(sComputerName)
EndProcedure
;==== TEST ========
CpuArchitecture()
Debug sgProcessorArchitecture
Debug sgPageSize
Debug sgNumberOfProcessors
Debug GetOsVersn()
Debug OSbits()
Debug GetOsServicePack()
Debug GetWindowsProductKey()
Debug GetCpuName()
Debug GetCpuNumber()
Debug GetPcName()