It is currently Wed Jul 08, 2020 11:06 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: How to find system type?
PostPosted: Fri Jun 05, 2020 4:42 am 
Offline
User
User

Joined: Sun May 24, 2020 11:41 pm
Posts: 17
https://prnt.sc/su3jkz
a code example with autoit do this
Code:
If @OSArch = "x86" Then
   MsgBox(0,"", "Your Operating System x86")
Else
   MsgBox(0,"", "Your Operating System x64")
EndIf


Is there a short example of this in Purebasic?


Top
 Profile  
Reply with quote  
 Post subject: Re: How to find system type?
PostPosted: Fri Jun 05, 2020 5:20 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 894
mRbrS wrote:
Is there a short example of this in Purebasic?

Yes -> viewtopic.php?p=256374#p256374

Returns 1 on a 64bit OS, or 0 on a 32bit OS.

Hint: I found this by searching these forums for "detect 64bit".


Top
 Profile  
Reply with quote  
 Post subject: Re: How to find system type?
PostPosted: Fri Jun 05, 2020 9:16 am 
Offline
Addict
Addict

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 903
Quote:
Is there a short example of this in Purebasic?
Yes -> viewtopic.php?p=256374#p256374
Returns 1 on a 64bit OS, or 0 on a 32bit OS.
Does not works for Linux (Ligne 6: Structure not found: SYSTEM_INFO.)


For Windows you can check system environment variable ProgramFiles(x86) with GetEnvironmentVariable()
Code:
If GetEnvironmentVariable("ProgramFiles(x86)") = ""
  MessageRequester("Info", "Windows 32 bits")
Else
  MessageRequester("Info", "Windows 64 bits")
EndIf
To see all environment variable available, type SET in shell (cmd)


For Linux there is HOSTTYPE, but I don't know why this does not works. :(
Code:
GetEnvironmentVariable("HOSSTYPE")
= Nothing
But this works in shell (bash)
Code:
# echo $HOSTTYPE
X86_64

Some environment variables are accessible to PB but not all of them while they are all accessible in the console (with the same user).
:?:

_________________
(English is not my native language, I use an online translator.)


Top
 Profile  
Reply with quote  
 Post subject: Re: How to find system type?
PostPosted: Fri Jun 05, 2020 12:24 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 1670
Check the size of type int.

Nevermind, that's just for your program. Some 64 bit os's allow running 32 bit programs.


Top
 Profile  
Reply with quote  
 Post subject: Re: How to find system type?
PostPosted: Fri Jun 05, 2020 1:40 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2541
Location: Germany
Tenaja wrote:
Check the size of type int.

Nevermind, that's just for your program. Some 64 bit os's allow running 32 bit programs.


No,
PB program compiled as x86 is integer always 32 bit

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: How to find system type?
PostPosted: Fri Jun 05, 2020 1:47 pm 
Offline
User
User

Joined: Sat Mar 14, 2015 11:53 am
Posts: 74
How about this:

Code:
Procedure GetProcessorArchitechture()
   If GetEnvironmentVariable("PROCESSOR_ARCHITEW6432") = "AMD64"     : ProcedureReturn 64 ; OS is 64-Bit, but program is 32-Bit
   ElseIf GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") = "AMD64" : ProcedureReturn 64 ; OS and program are both 64-Bit
   ElseIf GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") = "x86"   : ProcedureReturn 32 ; both are 32-Bit
   EndIf   ; return 0, if failed
 EndProcedure

_________________
There's usually a lot of "try this, do that" but ONLY an example source that one can test for themself and get an immediate result brings people forward.


Top
 Profile  
Reply with quote  
 Post subject: Re: How to find system type?
PostPosted: Fri Jun 05, 2020 2:09 pm 
Offline
Addict
Addict

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 903
Yes and no, it lacks IA64, ARM64

%PROCESSOR_ARCHITECTURE% can return differents values : AMD64, IA64, ARM64
https://docs.microsoft.com/fr-fr/window ... dfrom=MSDN

:arrow: possible solution: Check "64" at end
Code:
Debug Right(GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"), 2) ; 64

:wink:

_________________
(English is not my native language, I use an online translator.)


Top
 Profile  
Reply with quote  
 Post subject: Re: How to find system type?
PostPosted: Fri Jun 05, 2020 2:36 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 551
Location: Germany, Saarbrücken
On Linux you could use the command "uname -i" for the OS type and "uname -p" or "uname -m" for the processor/machine type. See also here: https://unix.stackexchange.com/a/188572

_________________
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.


Top
 Profile  
Reply with quote  
 Post subject: Re: How to find system type?
PostPosted: Fri Jun 05, 2020 4:16 pm 
Offline
User
User

Joined: Sun May 24, 2020 11:41 pm
Posts: 17
Thanks everyone :)
I love you PureBasic :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: chris319 and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye