Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include-once
  2. ; ===============================================================================================================================
  3. ; <_WinAPI_GetSystemInfo.au3>
  4. ;
  5. ; Simple DLL call to get system information.
  6. ;
  7. ; Function:
  8. ;   _WinAPI_GetSystemInfo()
  9. ;
  10. ; See also:
  11. ;   <_CPURegistryInfo.au3>
  12. ;   <CompareCPUProcessorCount.au3>
  13. ;   <_ProcessorGetLogicalInfo.au3>
  14. ;   EnvGet("NUMBER_OF_PROCESSORS")  [see below]
  15. ;
  16. ; Other WinAPI calls to get Processor Info:
  17. ;   GetLogicalProcessorInformation  [unfortunately available only on Win XP w/SP3 and higher]
  18. ;   IsProcessorFeaturePresent (get processor features information)
  19. ;
  20. ; Other ways to obtain Processor Information:
  21. ;   Utilizing the CPUID instruction (through Assembly code) in conjunction with Intel/AMD CPUID code
  22. ;   %NUMBER_OF_PROCESSORS%  Environment variable: Number of Processors (physical, not logical, again)
  23. ;       EnvGet("NUMBER_OF_PROCESSORS")
  24. ;
  25. ; On Win2000+, you can use:
  26. ;   "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\"
  27. ;       [one subkey for each physical processor, and inside the 1st key (and some inside subsequent ones is)]:
  28. ;           Speed, Features set, Processor Name, Identifier, etc.
  29. ;
  30. ; Note that this will also return 'logical' processors counted as physical ones.
  31. ;   See @ http://support.microsoft.com/kb/888282
  32. ;
  33. ; On Win NT and Win 2000, it appears the OS 'views' the # CPU's as separate even if one is hyperthreading.
  34. ;  On Win 95-Me, it only utilizes one CPU, so it doesn't matter anyway..
  35. ;   See @ http://blogs.msdn.com/oldnewthing/archive/2004/09/13/228780.aspx
  36. ;       More info @ http://blogs.msdn.com/oldnewthing/archive/2005/12/16/504659.aspx
  37. ;
  38. ; Misc. See-Also functions:
  39. ;   <_WinAPI_GetPerformanceInfo.au3>
  40. ;   <_WinAPI_GetSystemTimes.au3>
  41. ;
  42. ; Author: Ascend4nt
  43. ; ===============================================================================================================================
  44.  
  45.  
  46. ; ===============================================================================================================================
  47. ; Func _WinAPI_GetSystemInfo($iInformation=-1)
  48. ;
  49. ; Retrieves an array of system information, or just one item based on parameter
  50. ;
  51. ; $iInformation = The piece of information you would like to collect, or -1 for an entire array:
  52. ;   1 = Processor Architecture [0 = Intel, 6 = Itanium64, 9 = x64 (AMD or Intel), 0xFFFF = Unknown]
  53. ;   2 = Page Size
  54. ;   3 = Minimum Application Address
  55. ;   4 = Maximum Application Address
  56. ;   5 = Active Processor Mask - Set Bits indicate processor has been 'configured into the system' (MSDN)
  57. ;       [Bit 0 = processor # 0, Bit 31 = processor 31
  58. ;   6 = Number of Processors [not the same as 'Logical Processors']
  59. ;   7 = Processor Type [386 = Intel 386, 486 = "" 486, 586 = Pentium, 2200 = Itanium64, 8664 = AMD x8664 (?)
  60. ;   8 = Allocation Granularity ("granularity for the starting address at which virtual memory can be allocated" - MSDN)
  61. ;   9 = Processor Level (1 for Itanium64, otherwise for Processor Architecture 0 it represents CPU-vendor-specific info)
  62. ;   10 = Processor Revision (no clue - check out http://msdn.microsoft.com/en-us/library/ms724958(VS.85).aspx)
  63. ;
  64. ; Return:
  65. ;   Success: @error=0, and either a 10-element array filled in the order described above #1 at element [0], #10 at [9],
  66. ;       or a # associated with $iInformation
  67. ;   Failure: -1 return, @error is set:
  68. ;       @error = 1 = invalid parameter (out of range)
  69. ;       @error = 2 = DLL call error
  70. ;
  71. ; Other WinAPI calls to get Processor Info:
  72. ;   GetLogicalProcessorInformation  [unfortunately available only on Win XP w/SP3 and higher]
  73. ;   IsProcessorFeaturePresent (get processor features information)
  74. ;
  75. ; Other ways to obtain Processor Information:
  76. ;   %NUMBER_OF_PROCESSORS%  Environment variable: Number of Processors (physical, not logical, again)
  77. ;       EnvGet("NUMBER_OF_PROCESSORS")
  78. ;
  79. ; On Win2000+, you can use:
  80. ;   "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\"
  81. ;       [one subkey for each physical processor, and inside the 1st key (and some inside subsequent ones is)]:
  82. ;           Speed, Features set, Processor Name, Identifier, etc.
  83. ;
  84. ; Note that this will also return 'logical' processors counted as physical ones.
  85. ; See http://support.microsoft.com/kb/888282
  86. ;
  87. ; Author: Ascend4nt
  88. ; ===============================================================================================================================
  89.  
  90. Func _WinAPI_GetSystemInfo($iInformation=-1)
  91.     If $iInformation<>-1 And ($iInformation<1 Or $iInformation>10) Then Return SetError(1,0,-1)
  92.     Local $aRet,$stSystemInfo=DllStructCreate("ushort;short;dword;ptr;ptr;ulong_ptr;dword;dword;dword;short;short")
  93.  
  94.     ; If we are running in 32-bit mode on a 64-bit OS, we need to call a different API function
  95.     If Not @AutoItX64 And @OSArch<>"X86" Then
  96.         $aRet=DllCall("kernel32.dll","none","GetNativeSystemInfo","ptr",DllStructGetPtr($stSystemInfo))
  97.     Else
  98.         $aRet=DllCall("kernel32.dll","none","GetSystemInfo","ptr",DllStructGetPtr($stSystemInfo))
  99.     EndIf
  100.  
  101.     If @error Then Return SetError(2,@error,-1)
  102.  
  103.     If $iInformation<>-1 Then
  104.         If $iInformation=1 Then Return DllStructGetData($stSystemInfo,1)
  105.         Return DllStructGetData($stSystemInfo,$iInformation+1)
  106.     EndIf
  107.     Local $aSysInfo[10]
  108.     $aSysInfo[0]=DllStructGetData($stSystemInfo,1)
  109.     For $i=1 To 9
  110.         $aSysInfo[$i]=DllStructGetData($stSystemInfo,$i+2)
  111.     Next
  112. #cs
  113.     ; Full feature display:
  114.  
  115.     MsgBox(64,"System Info", _
  116.         "Processor Architecture:"&$aSysInfo[0]&@CRLF& _
  117.         "Page Size:"&$aSysInfo[1]&@CRLF& _
  118.         "Minimum Application Address:"&$aSysInfo[2]&@CRLF& _
  119.         "Maximum Application Address:"&$aSysInfo[3]&@CRLF& _
  120.         "Active Processor Mask:"&Hex($aSysInfo[4])&@CRLF& _
  121.         "Number of Processors:"&$aSysInfo[5]&@CRLF& _
  122.         "Processor Type:"&$aSysInfo[6]&@CRLF& _
  123.         "Allocation Granularity:"&$aSysInfo[7]&@CRLF& _
  124.         "Processor Level:"&Hex($aSysInfo[8])&@CRLF& _
  125.         "Processor Revision:"&Hex($aSysInfo[9]))
  126.  
  127. #ce
  128.     Return $aSysInfo
  129. EndFunc
  130.  
  131. ;~ _WinAPI_GetSystemInfo()