OSBits()
Re: OSBits()
ProcessorArchitecture <> 0 ;#PROCESSOR_ARCHITECTURE_INTEL
always 64 Bit
always 64 Bit
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: OSBits()
Is #PROCESSOR_ARCHITECTURE_ARM always <>0 and 32bit or 64bit ( for Windows 8 )?ts-soft wrote:ProcessorArchitecture <> 0 ;#PROCESSOR_ARCHITECTURE_INTEL
always 64 Bit
Re: OSBits()
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
As long pb doesn't support ARM, this result can't come, not on windows 8 or other

Last edited by ts-soft on Sat May 26, 2012 3:15 pm, edited 1 time in total.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: OSBits()
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.
Regards, Little John
Re: OSBits()
Oh
small typo, false member of structure (shit autocomplete and bad eyes
)


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()
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: 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
Yes, PB/Windows/ARM is the next big thing.

Re: OSBits()
<offtopic>
However, the number of the MacOS and Linux user will rise if Windows 8 appears
</offtopic>
However, the number of the MacOS and Linux user will rise if Windows 8 appears

</offtopic>
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: OSBits()
Windows only...
Edit: modified given ts-soft's comments below.
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)
Last edited by skywalk on Sat May 26, 2012 8:26 pm, edited 2 times in total.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: OSBits()
@skywalk
The Systemdrive is not always C: and the windows Dir can have different Names!
The Systemdrive is not always C: and the windows Dir can have different Names!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: OSBits()
Thanks ts-soft, I modified previous code to allow for non-standard installs...
Code: Select all
FL_FileExists(GetEnvironmentVariable("WinDir")+"\System32\Wow64.dll")
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: OSBits()
The other problem is, a 32-Bit executable, on a 64-bit os, will not found the DLL. The exe use the syswow64 version of the path 
This one works, but is to much code

This one works, but is to much code

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()
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: OSBits()
Sorry ts-soft, I didn't run the code on x64 machine.
This works...

This works...
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")
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: OSBits()
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()
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: OSBits()
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