Getting system information

BlitzMax Forums/BlitzMax Programming/Getting system information

Does BMax provide a generic way to get any bits of system information? Ideally I'd like strings that give me the OS brand, version number, build numbers, service pack numbers, computer network name, etc. Just general information. We are logging this in an application that has to run on Windows and Mac...

Any ideas? I can probably get the network name easily enough (or just the IP address, etc.) The tricky stuff is the OS specific numbers and names...thoughts?

You'll have to code it in C or something and then include it in your app - or put the code to go find the data into c and then call it from your app.

I'm sure that there is a Windows API call that will give you the exact info you're looking for, but failing that the following will give you an educated guess:

Strict
Global os$
Global root$
Global appdata$
Global cpunum$
Global cpuid$
Global cpubrand$

OS$=GetEnv_("OS")
root$=GetEnv_("systemroot")
appdata$=GetEnv_("AppData")
CPUnum$=GetEnv_("NUMBER_OF_PROCESSORS")
CPUid$=GetEnv_("PROCESSOR_IDENTIFIER")

If OS$="Windows_NT" Then Print "You are running the Windows NT kernel"
If OS$="Windows_NT" And (Instr(root$,"WINNT")<>0) And AppData$<>"" Then Print "Probably Windows 2000"
If OS$="Windows_NT" And (Instr(root$,"WINDOWS")<>0) And AppData<>"" Then Print "Probably Windows XP or Windows 2003"
If OS$="Windows_NT" And AppData$="" Then Print "Probably Windows NT"
If OS$="" Then Print "Windows 9x"

If CPUNum$<>"" Then Print "Number of CPU's: "+cpunum$
If Instr(Upper$(CPUid$),"AMD") Then 
	CPUbrand$="AMD"
ElseIf Instr(Upper$(CPUid$),"INTEL") Then
	CPUBrand$="Intel"
ElseIf Instr(Upper$(CPUid$),"CYRIX") Then
	CPUBrand$="Cyrix"
Else
	CPUBrand$="Unknown"
EndIf
Print "CPU Manufacturer: "+CPUBrand$
Print "CPU model and revision: "+CPUid$


Sample output:

You are running the Windows NT kernel
Probably Windows XP or Windows 2003
Number of CPU's: 1
CPU Manufacturer: AMD
CPU model and revision: x86 Family 6 Model 10 Stepping 0, AuthenticAMD



You can also find the hostname, domain, username, logon server, windows folder, temp folder, user home directory and other useful information this way...

Open a command prompt, and type 'set' (without the quotes). You'll see a list of all environment variables. do note that under Windows 95/98 not all of them may exist.

(CPU identifiers for the main manufacturers: GenuineIntel, AuthenticAMD, CyrixInstead)