getSystemInfo

Windows specific forum
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

getSystemInfo

Post by cecilcheah »

In the WinAPI, getSystemInfo is a subroutine rather than a function, how can i retireve say the CPU speed with the getSystemInfo?

Thanks

Cecil
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

You just pass the pointer to a SYSTEM_INFO Structure to the GetSystemInfo_()
function, and it fills the structure with information.

GetSystemInfo_(@info.SYSTEM_INFO)

now the info structure contains all information.
However, i don't see how you want to get the CPU speed out of this.
As far a I can see, this structure doesn't contain information about this.

Timo
quidquid Latine dictum sit altum videtur
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

imho the best way is to use SRGET library for PB... there are lots of opts..:) Just search it on PB forums and resources site.. Besides there are a lot of libs for such tasks ;)
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

What am I doing wrong here?

Code: Select all

Structure SysInfo
  dwOemId.w
  wProcessorArchitecture.w
  wReserved.w
  dwPageSize.w
  lpMinimumApplicationAddress.l
  lpMaximumApplicationAddress.l
  dwActiveProcessorMask.w
  dwNumberOfProcessors.w
  dwProcessorType.w
  dwAllocationGranularity.w
  wProcessorLevel.w
  wProcessorRevision.w
EndStructure

GetSystemInfo_(@wProcessorArchitecture.SysInfo)
Debug PeekS(@wProcessorArchitecture)
I also tried this

Code: Select all

*Result = GetSystemInfo_(@wProcessorArchitecture.SysInfo)
Debug PeekS(*Result)
but it doesn't return anything.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

My take on it would be something like this...

Code: Select all

Structure SysInfo
  StructureUnion 
    dwOemId.l
    wProcessorArchitecture.w 
    wReserved.w 
  EndStructureUnion 
  dwPageSize.l 
  lpMinimumApplicationAddress.l 
  lpMaximumApplicationAddress.l 
  dwActiveProcessorMask.l 
  dwNumberOfProcessors.l 
  dwProcessorType.l 
  dwAllocationGranularity.l 
  wProcessorLevel.w
  wProcessorRevision.w
EndStructure

GetSystemInfo_(@si.SysInfo)


Debug si\wProcessorArchitecture
Debug "---"
Debug si\dwPageSize
Debug si\dwActiveProcessorMask
Debug si\dwNumberOfProcessors
Debug si\dwProcessorType
Debug si\wProcessorLevel
If running on a PC, wProcessorArchitecture would return 0 since #PROCESSOR_ARCHITECTURE_INTEL=0


Warning: don't use PB's built in structure for SYSTEM_INFO since it contains spelling errors and is missing the union.


And as Freak said, there is no processor speed info available in this.
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Great.
Thanks alot Paul :)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Post Reply