Re: OSBits()
Posted: Sat May 26, 2012 3:03 pm
ProcessorArchitecture <> 0 ;#PROCESSOR_ARCHITECTURE_INTEL
always 64 Bit
always 64 Bit
Is #PROCESSOR_ARCHITECTURE_ARM always <>0 and 32bit or 64bit ( for Windows 8 )?ts-soft wrote:ProcessorArchitecture <> 0 ;#PROCESSOR_ARCHITECTURE_INTEL
always 64 Bit
My processor can only run 32-bit code, so the result "64" is definitely wrong on my machine.KJ67 wrote:I think that Ts-soft's code checks if the CPU can run 64-bit code.
Code: Select all
Procedure OSBits()
Protected si.SYSTEM_INFO, result = 32
Protected DLL = OpenLibrary(#PB_Any, "Kernel32.dll")
If DLL
If GetFunction(DLL,"GetNativeSystemInfo")
CallFunction(DLL, "GetNativeSystemInfo", @si)
If si\wProcessorArchitecture
result = 64
EndIf
EndIf
CloseLibrary(DLL)
EndIf
ProcedureReturn result
EndProcedure
Debug OSBits()
3 MacOSX and 5 Linux users, at least 5.000 Windows users.ts-soft wrote:Can this result ever come with PB EXE?
As long pb doesn't support ARM, this result can't come, not on windows 8 or other
Code: Select all
Macro Is(expression)
((expression) And 1) ;((expression) Or 0)
EndMacro
Procedure.s IIFs(expression,IsTrue.s,IsFalse.s)
If Is(expression)
ProcedureReturn IsTrue
Else
ProcedureReturn IsFalse
EndIf
EndProcedure
Macro FL_FileExists(Fname)
; 0 = File or Folder does not exist
; 1 = File Exists
; -1 = Folder Exists
; Since FileSize() returns:
; -1 = File Not found.
; -2 = File is a directory.
; 0 = Empty File, > 1 = File Exists
; FileSize() respects '*' wildcards and reports results accordingly.
FileSize(Fname) + 1
EndMacro
Macro SL_Is64BitOS()
; Windows 64-bit OS Info
; ---------------------- ----------------------------------
; C:\Windows\System32 System directory for 64-bit files
; C:\Windows\SysWOW64 System directory for 32-bit files
; C:\Program Files Apps directory for 64-bit files
; C:\Program Files (x86) Apps directory for 32-bit files
; -------------------------------- -------------------------------------------------------------------
; WoW64 uses 3 DLLs Description
; -------------------------------- -------------------------------------------------------------------
; C:\Windows\System32\Wow64.dll core interface to Windows NT kernel that translates between
; 32-bit & 64-bit calls including pointer & call stack manipulations
; C:\Windows\System32\Wow64win.dll provide appropriate entry-points for 32-bit apps
; C:\Windows\System32\Wow64cpu.dll switch processor from 32-bit to 64-bit mode
; 32-bit apps runnning on 64-bit OS are redirected, so query the existence of C:\Windows\SysWOW64\*.dll's
FL_FileExists(GetEnvironmentVariable("WinDir")+"\SysWow64\*.dll")
EndMacro
MessageRequester("SL_Is64BitOS", IIFs(SL_Is64BitOS(),"64","32"), #MB_ICONINFORMATION)
Code: Select all
FL_FileExists(GetEnvironmentVariable("WinDir")+"\System32\Wow64.dll")
Code: Select all
Prototype.i IsWow64Process(hProcess.i, Wow64Process.i)
Prototype.i Wow64EnableWow64FsRedirection(Wow64EnableRedirection.i)
Procedure.i DisableWow64FsRedirection(Flag.i)
If OSVersion() >= #PB_OS_Windows_Vista
Protected.i DLL = OpenLibrary(#PB_Any, "kernel32.dll")
Protected.IsWow64Process IsWow64Process
Protected.Wow64EnableWow64FsRedirection Wow64EnableWow64FsRedirection
Protected.i IsWow64
If DLL
IsWow64Process = GetFunction(DLL, "IsWow64Process")
Wow64EnableWow64FsRedirection = GetFunction(DLL, "Wow64EnableWow64FsRedirection")
If IsWow64Process(GetCurrentProcess_(), @IsWow64)
If IsWow64
ProcedureReturn Wow64EnableWow64FsRedirection(Flag ! 1)
EndIf
EndIf
EndIf
EndIf
EndProcedure
Macro FL_FileExists(Fname)
; 0 = File or Folder does not exist
; 1 = File Exists
; -1 = Folder Exists
; Since FileSize() returns:
; -1 = File Not found.
; -2 = File is a directory.
; 0 = Empty File, > 1 = File Exists
; FileSize() respects '*' wildcards and reports results accordingly.
FileSize(Fname) + 1
EndMacro
Macro SL_Is64BitOS()
; Windows 64-bit OS Info
; ---------------------- ----------------------------------
; C:\Windows\System32 System directory for 64-bit files
; C:\Windows\SysWOW64 System directory for 32-bit files
; C:\Program Files Apps directory for 64-bit files
; C:\Program Files (x86) Apps directory for 32-bit files
; -------------------------------- -------------------------------------------------------------------
; WoW64 uses 3 DLLs Description
; -------------------------------- -------------------------------------------------------------------
; C:\Windows\System32\Wow64.dll core interface to Windows NT kernel that translates between
; 32-bit & 64-bit calls including pointer & call stack manipulations
; C:\Windows\System32\Wow64win.dll provide appropriate entry-points for 32-bit apps
; C:\Windows\System32\Wow64cpu.dll switch processor from 32-bit to 64-bit mode
FL_FileExists(GetEnvironmentVariable("WinDir")+"\System32\Wow64.dll")
EndMacro
DisableWow64FsRedirection(#True)
Debug SL_Is64BitOS()
Code: Select all
; 32-bit apps runnning on 64-bit OS are redirected, so query the existence of C:\Windows\SysWOW64\*.dll's
FL_FileExists(GetEnvironmentVariable("WinDir")+"\SysWow64\*.dll")
Code: Select all
Procedure OSBitness()
CompilerSelect SizeOf(Integer)
CompilerCase 4
Protected Result, Library, *Function, Wow64Process
Library = OpenLibrary(#PB_Any, "Kernel32.dll")
If Library
*Function = GetFunction(Library, "IsWow64Process")
If *Function
If CallFunctionFast(*Function, GetCurrentProcess_(), @Wow64Process)
If Wow64Process
Result = 64
Else
Result = 32
EndIf
EndIf
Else
Result = 32
EndIf
CloseLibrary(Library)
EndIf
ProcedureReturn Result
CompilerCase 8
ProcedureReturn 64
CompilerEndSelect
EndProcedure
Debug OSBitness()
There are no 64 bit ARM CPU's. They are allways 32 bit and 16 bit depending on the instruction set you use: ARM or Thumb.Danilo wrote:Is #PROCESSOR_ARCHITECTURE_ARM always <>0 and 32bit or 64bit ( for Windows 8 )?ts-soft wrote:ProcessorArchitecture <> 0 ;#PROCESSOR_ARCHITECTURE_INTEL
always 64 Bit