#include <APIConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <Array.au3>
#include <Date.au3>
#include <Misc.au3>
#include <WinAPIEx.au3>
Global $bDebug = True
Global $aMsInfo32_Strs = _SystemEnumStrings('msinfo32.exe', $RT_STRING)
Global $sMsInfo32_Str, $sDecimal_Format = '%.2f'
Global $sMsInfo32_Str_Byte, $sMsInfo32_Str_KB, $sMsInfo32_Str_MB, $sMsInfo32_Str_GB, $sMsInfo32_Str_TB, $sMsInfo32_Str_NA
;Win Vista or higher and $aMsInfo32_Strs includes 283 or more items
If Hex($__WINVER, 4) >= 0600 And UBound($aMsInfo32_Strs) >= 283 Then
Dim Enum $iStr_Byte = 19, $iStr_KB, $iStr_MB, $iStr_GB, $iStr_TB, $iStr_NA
Dim $iStr_DcmlFrmt = 37
Dim $iStr_1 = 282, $iStr_2 = 128, $iStr_3 = 140, $iStr_4 = 130, $iStr_5 = 137, $iStr_6 = 131, $iStr_7 = 139, $iStr_8 = 132, $iStr_9 = 136, $iStr_10 = 142, $iStr_11 = 133, $iStr_12 = 134, $iStr_13 = 135
;Win 8 or higher
If Hex($__WINVER, 4) > 0601 Then
Dim $iStr_3 = 154 ;, $iStr_4 = 129,
EndIf
$sMsInfo32_Str_Byte = $aMsInfo32_Strs[$iStr_Byte]
$sMsInfo32_Str_KB = $aMsInfo32_Strs[$iStr_KB]
$sMsInfo32_Str_MB = $aMsInfo32_Strs[$iStr_MB]
$sMsInfo32_Str_GB = $aMsInfo32_Strs[$iStr_GB]
$sMsInfo32_Str_TB = $aMsInfo32_Strs[$iStr_TB]
$sMsInfo32_Str_NA = $aMsInfo32_Strs[$iStr_NA]
$sDecimal_Format = StringRegExpReplace($aMsInfo32_Strs[$iStr_DcmlFrmt], ' .{2} .*$', '')
$sMsInfo32_Str = _
StringRegExpReplace( _
$aMsInfo32_Strs[$iStr_1] & @CRLF & $aMsInfo32_Strs[$iStr_2] & @CRLF & $aMsInfo32_Strs[$iStr_3] & @CRLF & $aMsInfo32_Strs[$iStr_4] & @CRLF & $aMsInfo32_Strs[$iStr_5] & @CRLF & _
$aMsInfo32_Strs[$iStr_6] & @CRLF & $aMsInfo32_Strs[$iStr_7] & @CRLF & $aMsInfo32_Strs[$iStr_8] & @CRLF & $aMsInfo32_Strs[$iStr_9] & @CRLF & $aMsInfo32_Strs[$iStr_10] & '|%s' & @CRLF & _
$aMsInfo32_Strs[$iStr_11] & @CRLF & $aMsInfo32_Strs[$iStr_12] & @CRLF & $aMsInfo32_Strs[$iStr_13], _
'%(a|c|d|v|y)', '%s')
Else
;MsgBox(16, 'SysInfo - Error', 'This utility supports only Win Vista/7.')
;Exit
If @OSLang = 0419 Then ;Russian
$sMsInfo32_Str_Byte = 'Байт'
$sMsInfo32_Str_KB = 'КБ'
$sMsInfo32_Str_MB = 'МБ'
$sMsInfo32_Str_GB = 'ГБ'
$sMsInfo32_Str_TB = 'ТБ'
$sMsInfo32_Str_NA = 'Недоступно'
$sMsInfo32_Str = _
'Имя ОС|%s' & @CRLF & _
'Версия|%s %s Сборка %s' & @CRLF & _
'Дополнительное описание ОС|%s' & @CRLF & _
'Изготовитель ОС|%s' & @CRLF & _
'Имя системы|%s' & @CRLF & _
'Изготовитель|%s' & @CRLF & _
'Модель|%s' & @CRLF & _
'Тип|%s' & @CRLF & _
'Процессор|%s, %s МГц, ядер: %s, логических процессоров: %s' & @CRLF & _
'Версия BIOS|%s, %s' & @CRLF & _
'Версия SMBIOS|%s' & @CRLF & _
'Папка Windows|%s' & @CRLF & _
'Системная папка|%s' & @CRLF & _
'Устройство загрузки|%s' & @CRLF & _
'Язык системы|%s' & @CRLF & _
'Аппаратно-зависимый уровень (HAL)|Версия = "%s"' & @CRLF & _
'Имя пользователя|%s' & @CRLF & _
'Часовой пояс|%s' & @CRLF & _
'Установленная оперативная память (RAM)|%s' & @CRLF & _
'Полный объем физической памяти|%s' & @CRLF & _
'Доступно физической памяти|%s' & @CRLF & _
'Всего виртуальной памяти|%s' & @CRLF & _
'Доступно виртуальной памяти|%s' & @CRLF & _
'Размер файла подкачки|%s' & @CRLF & _
'Файл подкачки|%s'
Else
$sMsInfo32_Str_Byte = 'Byte'
$sMsInfo32_Str_KB = 'KB'
$sMsInfo32_Str_MB = 'MB'
$sMsInfo32_Str_GB = 'GB'
$sMsInfo32_Str_TB = 'TB'
$sMsInfo32_Str_NA = 'Not Available'
$sMsInfo32_Str = _
'OS Name|%s' & @CRLF & _
'Version|%s %s Build %s' & @CRLF & _
'Other OS Description|%s' & @CRLF & _
'OS Manufacturer|%s' & @CRLF & _
'System Name|%s' & @CRLF & _
'System Manufacturer|%s' & @CRLF & _
'System Model|%s' & @CRLF & _
'System Type|%s' & @CRLF & _
'Processor|%s, %s Mhz, %s Core(s), %s Logical Processor(s)' & @CRLF & _
'BIOS Version/Date|%s, %s' & @CRLF & _
'SMBIOS Version|%s' & @CRLF & _
'Windows Directory|%s' & @CRLF & _
'System Directory|%s' & @CRLF & _
'Boot Device|%s' & @CRLF & _
'Locale|%s' & @CRLF & _
'Hardware Abstraction Layer|Version = "%s"' & @CRLF & _
'User Name|%s' & @CRLF & _
'Time Zone|%s' & @CRLF & _
'Installed Physical Memory (RAM)|%s' & @CRLF & _
'Total Physical Memory|%s' & @CRLF & _
'Available Physical Memory|%s' & @CRLF & _
'Total Virtual Memory|%s' & @CRLF & _
'Available Virtual Memory|%s' & @CRLF & _
'Page File Space|%s' & @CRLF & _
'Page File|%s'
EndIf
EndIf
_Debug()
$oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\CIMV2')
If @error Then Exit 1
Global Enum $iOS, $iCS, $iPR, $iBS, $iTZ, $iPF, $iPM
Global $aTable[7][2] = _
[ _
['Win32_OperatingSystem', 'Caption,Version,CSDVersion,BuildNumber,Description,Manufacturer,CSName,WindowsDirectory,SystemDirectory,BootDevice,FreePhysicalMemory,TotalVirtualMemorySize,FreeVirtualMemory'], _
['Win32_ComputerSystem', 'Manufacturer,Model,SystemType,UserName,TotalPhysicalMemory'], _
['Win32_Processor', 'Name,MaxClockSpeed,NumberOfCores,NumberOfLogicalProcessors'], _
['Win32_BIOS', 'Manufacturer,SMBIOSBIOSVersion,ReleaseDate,SMBIOSMajorVersion,SMBIOSMinorVersion'], _
['Win32_TimeZone', 'StandardName'], _
['Win32_PageFileUsage', 'AllocatedBaseSize,Name'], _
['Win32_PhysicalMemory', 'Capacity'] _
]
Global $oOS_Items = $oWMI.ExecQuery('SELECT ' & $aTable[$iOS][1] & ' FROM ' & $aTable[$iOS][0], 'WQL', 0x30)
Global $oCS_Items = $oWMI.ExecQuery('SELECT ' & $aTable[$iCS][1] & ' FROM ' & $aTable[$iCS][0], 'WQL', 0x30)
Global $oPR_Items = $oWMI.ExecQuery('SELECT ' & $aTable[$iPR][1] & ' FROM ' & $aTable[$iPR][0], 'WQL', 0x30)
Global $oBS_Items = $oWMI.ExecQuery('SELECT ' & $aTable[$iBS][1] & ' FROM ' & $aTable[$iBS][0], 'WQL', 0x30)
Global $oTZ_Items = $oWMI.ExecQuery('SELECT ' & $aTable[$iTZ][1] & ' FROM ' & $aTable[$iTZ][0], 'WQL', 0x30)
Global $oPF_Items = $oWMI.ExecQuery('SELECT ' & $aTable[$iPF][1] & ' FROM ' & $aTable[$iPF][0], 'WQL', 0x30)
Global $oPM_Items = $oWMI.ExecQuery('SELECT ' & $aTable[$iPM][1] & ' FROM ' & $aTable[$iPM][0], 'WQL', 0x30)
Global $sOS_Cptn, $sOS_Vrsn, $sOS_CSDVrsn, $sOS_BldNmbr, $sOS_Dscrptn, $sOS_Mnfctr, $sOS_CSName, $sOS_WinDir, $sOS_SysDir, $sOS_BootDvc, $sOS_FreePhsclMem, $sOS_TotlVrtlMemSz, $sOS_FreeVrtlMem
Global $sCS_Mnfctr, $sCS_Mdl, $sCS_SysType, $sCS_UsrName, $sCS_TotlPhsclMem
Global $sPR_Name, $sPR_MaxClckSpd, $sPR_NmbrOfCrs, $sPR_NmbrOfLgclPrcs
Global $sBS_Mnfctr, $sBS_SMBSBSVrsn, $sBS_RlsDate, $sBS_SMBSMjrVrsn, $sBS_SMBSMnrVrsn
Global $sTZ_StndrdName
Global $sPF_AllctdBaseSz, $sPF_Name
Global $sPM_Cpcty
Global $sReg_Date_Sep = RegRead('HKCU\Control Panel\International', 'sDate')
Global $iReg_Digits = 2 ;RegRead('HKCU\Control Panel\International', 'iDigits') ;MsInfo32 uses %.2f, not system decimal digit
Global $sReg_Lang = RegRead('HKCU\Control Panel\International', 'sCountry')
Global $sReg_HAL = _SystemGetHalVersion() ;RegRead('HKLM\SOFTWARE\Microsoft\DataAccess', 'Version')
If IsObj($oOS_Items) Then
For $oItem In $oOS_Items
With $oItem
$sOS_Cptn = _DataGet(.Caption)
$sOS_Vrsn = _DataGet(.Version)
$sOS_CSDVrsn = _DataGet(.CSDVersion, .Version = '' And .BuildNumber = '')
$sOS_BldNmbr = _DataGet(.BuildNumber)
$sOS_Dscrptn = _DataGet(.Description)
$sOS_Mnfctr = _DataGet(.Manufacturer)
$sOS_CSName = _DataGet(.CSName)
$sOS_WinDir = _DataGet(.WindowsDirectory)
$sOS_SysDir = _DataGet(.SystemDirectory)
$sOS_BootDvc = _DataGet(.BootDevice)
$sOS_FreePhsclMem = _DataGet(.FreePhysicalMemory)
$sOS_TotlVrtlMemSz = _DataGet(.TotalVirtualMemorySize)
$sOS_FreeVrtlMem = _DataGet(.FreeVirtualMemory)
EndWith
Next
EndIf
If IsObj($oCS_Items) Then
For $oItem In $oCS_Items
With $oItem
$sCS_Mnfctr = _DataGet(.Manufacturer)
$sCS_Mdl = _DataGet(.Model)
$sCS_SysType = _DataGet(.SystemType)
$sCS_UsrName = _DataGet(.UserName)
$sCS_TotlPhsclMem = _DataGet(.TotalPhysicalMemory)
EndWith
Next
EndIf
If IsObj($oPR_Items) Then
For $oItem In $oPR_Items
With $oItem
$sPR_Name = _DataGet(.Name)
$sPR_MaxClckSpd = _DataGet(.MaxClockSpeed)
$sPR_NmbrOfCrs = _DataGet(.NumberOfCores)
$sPR_NmbrOfLgclPrcs = _DataGet(.NumberOfLogicalProcessors)
EndWith
Next
EndIf
If IsObj($oBS_Items) Then
For $oItem In $oBS_Items
With $oItem
$sBS_Mnfctr = _DataGet(.Manufacturer)
$sBS_SMBSBSVrsn = _DataGet(.SMBIOSBIOSVersion)
$sBS_RlsDate = _DataGet(.ReleaseDate)
$sBS_SMBSMjrVrsn = _DataGet(.SMBIOSMajorVersion)
$sBS_SMBSMnrVrsn = _DataGet(.SMBIOSMinorVersion)
EndWith
Next
Local $aRls_Date = StringRegExp($sBS_RlsDate, '(\d{4})(\d{2})(\d{2}).*', 3)
If UBound($aRls_Date) = 3 Then
$sBS_RlsDate = _DateTimeFormat($aRls_Date[0] & '/' & $aRls_Date[1] & '/' & $aRls_Date[2], 2)
Local $iDayOfWeek = _DateToDayOfWeek($aRls_Date[0], $aRls_Date[1], $aRls_Date[2])
Local $aDay = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'ulong', 0, 'dword', Mod($iDayOfWeek + 5, 7) + 42 + 1 * 7, 'wstr', '', 'int', 2048)
If UBound($aDay) >= 3 And StringRegExp($sBS_RlsDate, '(Sun|Mon|Tue|Wed|Thu|Fri|Sat)$') Then
$sBS_RlsDate = StringTrimRight($sBS_RlsDate, 3) & $aDay[3]
EndIf
EndIf
EndIf
If IsObj($oTZ_Items) Then
For $oItem In $oTZ_Items
With $oItem
$sTZ_StndrdName = _DataGet(.StandardName)
EndWith
Next
EndIf
If IsObj($oPF_Items) Then
For $oItem In $oPF_Items
With $oItem
$sPF_AllctdBaseSz = _DataGet(.AllocatedBaseSize)
$sPF_Name = _DataGet(.Name)
EndWith
Next
If Hex($__WINVER, 4) < 0600 Then ;Lower than Win Vista
$aMemStats = MemGetStats()
$sPF_AllctdBaseSz = $aMemStats[3] / 1024
EndIf
EndIf
If IsObj($oPM_Items) Then
For $oItem In $oPM_Items
With $oItem
$sPM_Cpcty += _DataGet(.Capacity)
EndWith
Next
EndIf
$sMsInfo32_Str = _
StringFormat($sMsInfo32_Str, _
$sOS_Cptn, $sOS_Vrsn, $sOS_CSDVrsn, $sOS_BldNmbr, $sOS_Dscrptn, $sOS_Mnfctr, $sOS_CSName, $sCS_Mnfctr, $sCS_Mdl, $sCS_SysType, _
$sPR_Name, $sPR_MaxClckSpd, $sPR_NmbrOfCrs, $sPR_NmbrOfLgclPrcs, _
$sBS_Mnfctr & ' ' & $sBS_SMBSBSVrsn, $sBS_RlsDate, _
$sBS_SMBSMjrVrsn & '.' & $sBS_SMBSMnrVrsn, $sOS_WinDir, $sOS_SysDir, $sOS_BootDvc, $sReg_Lang, $sReg_HAL, $sCS_UsrName, $sTZ_StndrdName, _
_StringGetBytesDisplaySize($sPM_Cpcty, 0, $iReg_Digits, $sDecimal_Format), _
_StringGetBytesDisplaySize($sCS_TotlPhsclMem, 0, $iReg_Digits, $sDecimal_Format), _
_StringGetBytesDisplaySize($sOS_FreePhsclMem, 1, $iReg_Digits, $sDecimal_Format), _
_StringGetBytesDisplaySize($sOS_TotlVrtlMemSz, 1, $iReg_Digits, $sDecimal_Format), _
_StringGetBytesDisplaySize($sOS_FreeVrtlMem, 1, $iReg_Digits, $sDecimal_Format), _
_StringGetBytesDisplaySize($sPF_AllctdBaseSz, 2, $iReg_Digits, $sDecimal_Format), _
$sPF_Name _
)
$sMsInfo32_Str = StringRegExpReplace($sMsInfo32_Str, '\h+(\r?\n)|(\r?\n)\h+', '\1\2')
$sMsInfo32_Str = StringRegExpReplace($sMsInfo32_Str, '\h+\|', '|')
$sMsInfo32_Str = StringRegExpReplace($sMsInfo32_Str, '\h{2,}', ' ')
;~ ShellExecute('msinfo32.exe')
_Display_MSInfo32($sMsInfo32_Str)
Func _Display_MSInfo32($sStr)
$hGUI = GUICreate('MsInfo32', @DesktopWidth - 200, @DesktopHeight - 300)
$iLV = GUICtrlCreateListView('Title|Value', 20, 20, @DesktopWidth - 240, @DesktopHeight - 380)
$aSplit = StringSplit(StringStripCR($sStr), @LF)
For $i = 1 To $aSplit[0]
GUICtrlCreateListViewItem($aSplit[$i], $iLV)
Next
GUICtrlSendMsg($iLV, $LVM_SETCOLUMNWIDTH, 0, -1)
GUICtrlSendMsg($iLV, $LVM_SETCOLUMNWIDTH, 1, -1)
GUISetState(@SW_SHOW, $hGUI)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
GUIDelete($hGUI)
EndFunc
Func _Debug($sData = '')
If Not $bDebug Then
Return
EndIf
If $sData <> '' Then
ConsoleWrite($sData)
Else
Dim $aStrs = _
StringSplit( _
'Имя ОС|Версия|Дополнительное описание ОС|Изготовитель ОС|Имя системы|Изготовитель|Модель|Тип|Процессор|Версия BIOS|Версия SMBIOS|' & _
'Папка Windows|Системная папка|Устройство загрузки|Язык системы|Аппаратно-зависимый уровень (HAL)|Версия|Имя пользователя|Часовой пояс|' & _
'Установленная оперативная память (RAM)|Полный объем физической памяти|Доступно физической памяти|Всего виртуальной памяти|Доступно виртуальной памяти|Размер файла подкачки|Файл подкачки', _
'|')
ConsoleWrite(@CRLF & @CRLF & '------------ Indexes msinfo32 data ------------' & @CRLF & @CRLF)
For $i = 1 To $aStrs[0]
$iIndex = _ArraySearch($aMsInfo32_Strs, $aStrs[$i], 0, 0, 0, 1)
If $iIndex <> -1 Then
ConsoleWrite($i & ') ' & $iIndex & ':' & @CRLF & @TAB & StringReplace($aMsInfo32_Strs[$iIndex], @LF, @LF & @TAB) & @CRLF)
Else
ConsoleWrite($i & ') NOT FOUND' & @CRLF)
EndIf
Next
ConsoleWrite(@CRLF & @CRLF & '------------ Raw msinfo32 data ------------' & $sMsInfo32_Str & @CRLF & @CRLF)
;_ArrayDisplay($aMsInfo32_Strs)
Exit
EndIf
EndFunc
Func _DataGet($sData, $bIif = -1)
If IsBool($bIif) Then
Return _Iif($sData, $sData, _Iif($bIif, $sMsInfo32_Str_NA, ''))
Else
Return _Iif($sData, $sData, $sMsInfo32_Str_NA)
EndIf
EndFunc
Func _SystemGetHalVersion()
Local $h_Search, $s_File, $s_Version = 'Not available'
$h_Search = FileFindFirstFile(@SystemDir & '\hal*.dll')
If $h_Search = -1 Then Return $s_Version
While 1
$s_File = FileFindNextFile($h_Search)
If @error Then ExitLoop
If @OSVersion = 'WIN_XP' Then
$s_Version = FileGetVersion(@SystemDir & '\' & $s_File, 'FileVersion')
Else
$s_Version = FileGetVersion(@SystemDir & '\' & $s_File)
EndIf
If Not @error Then ExitLoop
WEnd
FileClose($h_Search)
Return $s_Version
EndFunc
Func _SystemEnumStrings($vModule, $sResType = $RT_STRING, $sModulePath = @SystemDir)
Local $aRet[1]
Local $aModules, $hLibrary, $aData, $hInfo, $hResource, $pData, $iOffset, $iLength
If IsString($vModule) Then
$aModules = StringSplit($vModule, '|')
Else
$aModules = $vModule
EndIf
For $i = 1 To UBound($aModules)-1
$hLibrary = _WinAPI_LoadLibraryEx($sModulePath & '\' & $aModules[$i], $LOAD_LIBRARY_AS_DATAFILE)
$aData = _WinAPI_EnumResourceNames($hLibrary, $sResType)
For $j = 1 To UBound($aData)-1
$hInfo = _WinAPI_FindResource($hLibrary, $sResType, $aData[$j])
$hResource = _WinAPI_LoadResource($hLibrary, $hInfo)
$pData = _WinAPI_LockResource($hResource)
$iOffset = 0
For $ij = 0 To 15
$iLength = DllStructGetData(DllStructCreate('ushort', $pData + $iOffset), 1)
If $iLength Then
$aRet[0] += 1
ReDim $aRet[$aRet[0]+1]
$aRet[$aRet[0]] = DllStructGetData(DllStructCreate('wchar[' & $iLength & ']', $pData + $iOffset + 2), 1)
EndIf
$iOffset += 2 * ($iLength + 1)
Next
Next
_WinAPI_FreeLibrary($hLibrary)
Next
Return $aRet
EndFunc
Func _StringGetBytesDisplaySize($iInputSize, $iInputUnit = 0, $iRound = 2, $sFormat = '', $iInputBits = False, $iOutputBits = False, $iOutputUnit = -4)
Local $aUnitNames[9] = ['', StringLeft($sMsInfo32_Str_KB, 1), StringLeft($sMsInfo32_Str_MB, 1), StringLeft($sMsInfo32_Str_GB, 1), StringLeft($sMsInfo32_Str_TB, 1), 'P', 'E', 'Z', 'Y']
Local $iBytes = $iInputSize * 1024 ^ $iInputUnit
Local $sB = StringRight($sMsInfo32_Str_KB, 1)
If $sFormat = '' Then
$sFormat = '%d'
Else
$iRound = -1
EndIf
If $iInputBits Then
$iBytes /= 8
EndIf
If $iOutputBits Then
$iBytes *= 8
$sB = StringLower($sB)
EndIf
If $iOutputUnit < 0 Then
Local $iOutputMax = Abs($iOutputUnit)
$iOutputUnit = Int(Log($iBytes) / Log(1024))
If $iOutputUnit > $iOutputMax Then $iOutputUnit = $iOutputMax
EndIf
If $aUnitNames[$iOutputUnit] = '' Then
$sB = $sMsInfo32_Str_Byte
EndIf
If $iRound = -1 Then
Return StringFormat($sFormat, ($iBytes / 1024 ^ $iOutputUnit)) & ' ' & $aUnitNames[$iOutputUnit] & $sB
EndIf
Return StringFormat($sFormat, Round($iBytes / 1024 ^ $iOutputUnit, $iRound)) & ' ' & $aUnitNames[$iOutputUnit] & $sB
EndFunc