找回密码
 加入
搜索
查看: 2477|回复: 4

[系统综合] 怎样得到系统的硬件配置?

[复制链接]
发表于 2012-8-21 12:59:32 | 显示全部楼层 |阅读模式
各位:

怎样获取系统的硬件配置,如果不调用wmi,是否有现成的udf可以做到(硬件配置包括内存,cpu,硬盘大小,显卡类型)
发表于 2012-8-21 13:14:51 | 显示全部楼层
device api
发表于 2012-8-21 14:13:59 | 显示全部楼层
本帖最后由 xiehuahere 于 2012-8-21 15:44 编辑

回复 1# vr4u


API通用性强,兼容性好。
但还是WMI用起来更加方便,就是在没有WMI的简化版Windows上要麻烦了。
   
官网的一个例子:
Getting system CPU info
仍旧是用的WMI

另一个官网例子(仍旧是WMI,用的AutoIt版本太老了,我改了下,3.3.7.15版本测试通过):
#region Start-up Vars
ProgressOn("Loading...", "Gathering Data...", "0%", -1, -1)

    Global $SelectAll = 0
    Dim $Key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall"
ProgressSet(10, "10%")
    Dim $Title = "Display Uninstall"
    Dim $EnableList = 1
    Dim $RemoteComputer
    $SelectedCount = 0
ProgressSet(20, "20%")
    HotKeySet("{Esc}", "Stop")
    HotKeySet('^a', 'SelectAll')
   ; Opt("RunErrorsFatal", 0)
    $vid_card = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\0004", "DriverDesc")
    If @error Then
        $vid_card = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\0000", "DriverDesc")
    EndIf
ProgressSet(25, "25%")
    $processer = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E966-E325-11CE-BFC1-08002BE10318}\0000", "DriverDesc")
ProgressSet(30, "30%")
    $sound_card = Regread("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{71A27CDD-812A-11D0-BEC7-08002BE2092F}\0000", "DriverDesc")
ProgressSet(40, "40%")  
    Dim $Bin = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductID")
    Dim $key4RegisteredOwner = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
ProgressSet(45, "45%")
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    $colSettings = $objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
ProgressSet(50, "50%")
    $colMemory = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
    $colCPU = $objWMIService.ExecQuery ("Select * from CIM_Processor")
ProgressSet(60, "60%")
;~     $colVideoinfo = $objWMIService.ExecQuery ("Select * from Win32_VideoController")
    Dim $pcinfo, $pcinfo2, $clockspeed
    Dim $ffcase = 0
    Dim $labelinc = 0
    Dim $spy1 = 0

    For $object In $colSettings
        $wininfo = String($object.Caption)
        $winsp = String($object.CSDVersion)
;~         $clockspeed = String(Int(Number($object.CurrentClockSpeed))) / 1000
    Next
ProgressSet(70, "70%")
    For $object In $colCPU
        $pcinfo = String($object.Name)
        $clockspeed = String(Int(Number($object.CurrentClockSpeed))) / 1000
    Next

    For $object In $colMemory
        $primaryowner = String($object.PrimaryOwnerName)
        $pcinfo2 = String(Int(Number($object.TotalPhysicalMemory) / (1024))) & " KB" & "   (" & String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024)) + 1) & " MB)"
    Next

    $audiocardquery = $objWMIService.ExecQuery ("Select * from Win32_SoundDevice")
ProgressSet(80, "80%")
    $cpu = StringFormat("%.2f", $clockspeed)

    Dim $audiocardinfo,$devices

    For $object In $audiocardquery
    $devices = String($object.DeviceID)
ProgressSet(90, "90%")
    $firstaudiocard = $objWMIService.ExecQuery ("Select * from Win32_SoundDevice.DeviceID=" & $devices)

    $audiocardinfo = String($object.Name)  
    $audiocardinfo2 = String($object.Status) 
ProgressSet(100, "100%")    
    ConsoleWrite(@CRLF & $audiocardinfo & @CRLF)
ProgressOff()
    
Next
#endregion Start-up Vars



#region Main Script

#include <File.au3>
#include <Constants.au3>
#Include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>


$mainWindows = GUICreate("Computer Details", 495 + 350, 700, -1, -1)

$label_1 = GUICtrlCreateLabel("Computer Name: ", 24, 8, 86, 17)
$Label_2 = GUICtrlCreateLabel(@ComputerName, 112, 8, 150, 17)
$ID = GUICtrlCreateLabel("UserName: " & @UserName, 200, 8, 155, 17)
$Group_8 = GUICtrlCreateGroup("Operating System", 176, 64, 127, 41)
$Label_9 = GUICtrlCreateLabel(@OSVersion, 192, 80, 110, 17)
$Group2 = GUICtrlCreateGroup("Monitor", 24, 56, 145, 121)
$Label_4 = GUICtrlCreateLabel("Width: " & @DesktopWidth & " Pixels", 40, 72, 120, 17)
$Label_5 = GUICtrlCreateLabel("Height: " & @DesktopHeight & " Pixels", 40, 96, 120, 17)
$Label_6 = GUICtrlCreateLabel("Refresh Rate: " & @DesktopRefresh & " Pixels", 40, 120, 120, 17)
$label_11 = GUICtrlCreateLabel("Depth: " & @DesktopDepth & " Pixels", 40, 140, 120, 17) 
$Label_14 = GUICtrlCreateLabel("The Full Path for this Program is: ", 24, 32, 159, 17)
$Label_14 = GUICtrlCreateLabel(@ScriptFullPath, 184, 36, 300, 17, $SS_SUNKEN)
$Group3 = GUICtrlCreateGroup("Internet", 24, 184, 281, 73)
$retest_c = GUICtrlCreateButton("Retest", 32, 200, 97, 25)
$Internet = GUICtrlCreateLabel("Testing Internet Connection...", 32, 232, 250, 17)
$Label_7 = GUICtrlCreateLabel("IP:" & @IPAddress1, 150, 205, 150, 17, $SS_SUNKEN)
$Group4 = GUICtrlCreateGroup("Drives", 24, 264, 233, 169)
$Button_11 = GUICtrlCreateButton("Find All Drives", 32, 280, 121, 25)
$Button_12 = GUICtrlCreateButton("Find CD-Drives", 32, 312, 121, 25)
$Button_13 = GUICtrlCreateButton("Find Removable Drives", 32, 344, 121, 25)
$Button_15 = GUICtrlCreateButton("Get Size of Drive:", 32, 376, 121, 25)
$cd_o = GUICtrlCreateButton("Open Drive", 168, 280, 73, 25)
$Label_10 = GUICtrlCreateLabel("Home Drive:" & @HomeDrive, 160, 320, 80, 17)
$Credits = GUICtrlCreateButton("Credits", 420, 10, 65, 25)
$Group5 = GUICtrlCreateGroup("Windows", 264, 264, 225, 169)
$winCombo_C = GUICtrlCreateCombo("", 272, 280, 209, 21)
$winClose_R = GUICtrlCreateRadio("Win Close", 272, 328, 73, 17)
$winKill_R = GUICtrlCreateRadio("Win Kill", 360, 328, 65, 17)
$winshow_R = GUICtrlCreateRadio("Win Show", 272, 304, 73, 17)
$winhide_R = GUICtrlCreateRadio("Win Hide", 360, 304, 65, 17)
$Go_B = GUICtrlCreateButton("Activate", 272, 376, 209, 25)
$status_L = GUICtrlCreateLabel("Ready...", 272, 408, 210, 17)
$GroupP = GUICtrlCreateGroup("Programs", 312, 156, 177, 101)
$processClose_R = GUICtrlCreateRadio("Process End", 320, 212, 161, 17)
$Go_A = GUICtrlCreateButton("Activate...", 320, 232, 161, 20)
$processCombo_C = GUICtrlCreateCombo("", 320, 180, 161, 21)
$tree = GuiCtrlCreateButton("Folder Tree", 355, 10, 65, 25)
$r_input = GUICtrlCreateInput("Enter program to run", 174, 117, 130, 20)
$rp_input = GUICtrlCreateInput("Enter path to program", 174, 137, 130, 20)
$rr_run = GUICtrlCreateButton("Run program", 174, 157, 130, 20)
$hard_group = GUICtrlCreateGroup("Hard Ware", 310, 50, 196, 100)
$vid_card_L = GUICtrlCreateLabel("Vid Card: " & $vid_card, 315, 66, 190, 20)
;~ $processer_L = GUICtrlCreateLabel("Processor: "  & $processer, 315, 86, 174, 20)
GUICtrlCreateLabel("Processer:                            " & $pcinfo, 315, 86, 174, 30)
;~ $sound_car_L = GUICtrlCreateLabel("Sound Card: " & $sound_card, 315, 116, 174, 20)
GUICtrlCreateLabel("Sound Card: " & $audiocardinfo & "      Status:  " & $audiocardinfo2, 315, 116, 174, 30)

;Windows Info
$microsoft_info = GUICtrlCreateGroup("Microsoft Information", 24, 445, 450, 220)
$status_L = GUICtrlCreateLabel("Information read out ...", 27, 475, 400, 20)
$description_L = GUICtrlCreateLabel("Description-----------------------------------", 27, 495, 103, 20)
$windowsType_L = GUICtrlCreateLabel("WindowsType------------------------------------", 27, 515, 103, 20)
$serialNumber_L = GUICtrlCreateLabel("SerialNumber-----------------------------------", 27, 535, 103, 20)
$ProductKey_L = GUICtrlCreateLabel("ProductKey-------------------------------------", 27, 555, 103, 20)
$InstallDate_L = GUICtrlCreateLabel("InstallDate--------------------------------", 27, 575, 103, 20)
$LastBootUpTime_L = GUICtrlCreateLabel("LastBootUpTime------------------------------", 27, 595, 103, 20)
$RegisteredOwner_L = GUICtrlCreateLabel("RegisteredOwner--------------------------------", 27, 615, 103, 20)
$officeKey_L = GUICtrlCreateLabel("OfficeKey----------------------------------", 27, 635, 113, 20)

$description_I = GUICtrlCreateInput("Description", 135, 495, 315, 21)
$windowsType_I = GUICtrlCreateInput("WindowsType", 135, 515, 315, 21)
$serialNumber_I = GUICtrlCreateInput("SerialNumber", 135, 535, 315, 21)
$ProductKey_I = GUICtrlCreateInput("ProductKey", 135, 555, 315, 21)
$InstallDate_I = GUICtrlCreateInput("InstallDate", 135, 575, 315, 21)
$LastBootUpTime_I = GUICtrlCreateInput("LastBootUpTime", 135, 595, 315, 21)
$RegisteredOwner_I = GUICtrlCreateInput("RegisteredOwner", 135, 615, 315, 21)
$officeKey_I = GUICtrlCreateInput("OfficeKey", 135, 635, 315, 21)

;Trans-=-Alpha
$trans = GUICtrlCreateSlider(510, 620, 300, 30)
GUICtrlSetLimit($trans, 255,50)
$transbutton = GUICtrlCreateButton("Set window alpha", 510, 590, 300, 20)

;Installed Programs List
$ulist = GUICtrlCreateListView("Icon|Display Name|Key Name", 510, 40, 285, 520, BitOR($LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
GUICtrlSetResizing($ulist, $GUI_DOCKBORDERS)
_GUICtrlListView_SetColumnWidth ($ulist, 0, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth ($ulist, 1, 310)
_GUICtrlListView_SetColumnWidth ($ulist, 2, 310)
$but1 = GUICtrlCreateButton("Refresh List", 520, 15, -1, -1, $BS_DEFPUSHBUTTON)
GUICtrlSetResizing($but1, $GUI_DOCKALL)
$but2 = GUICtrlCreateButton("Uninstall Programs", 600, 15)
GUICtrlSetResizing($but2, $GUI_DOCKALL)
GUICtrlSetState($but2, $GUI_DISABLE)
$chkbox = GUICtrlCreateCheckbox("Enable\Disable Silent Uninstall", 9000, 12)
GUICtrlSetResizing($chkbox, $GUI_DOCKALL)
$Label1 = GUICtrlCreateLabel('Remote Computer', 4700, 15, 85, 20)
GUICtrlSetResizing($Label1, $GUI_DOCKALL)
$Input1 = GUICtrlCreateInput('', 5600, 12, 130, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_UPPERCASE))
GUICtrlSetResizing($Input1, $GUI_DOCKALL)
$StatusBar1 = _GuiCtrlStatusBar_Create ($mainWindows, 400, "", $SBT_TOOLTIPS)
_GuiCtrlStatusBar_SetMinHeight ($StatusBar1, 15)
$Progress1 = GUICtrlCreateProgress(510, 560, 285, 20)
GUICtrlSetResizing($Progress1, $GUI_DOCKSTATEBAR)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW)
$List = ReadKeys()


GuiSetState()

_INITIATE()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $transbutton
        $var2 = GUICtrlRead($trans)
        WinSetTrans("Computer Details", "", $var2)
        MsgBox(0,$var2, "The Window alpha is now: " & $var2)
    Case $msg = $Button_11
        $pass = 1
        $dr_all = DriveGetDrive("all")
        If @error Then
            Msgbox(0, "ERROR", "No Drives found.")
            $pass = 0
        EndIf
        If $pass = 1 Then
            If NOT @error Then
                MsgBox(4096,"", "Found " & $dr_all[0] & " drives")
            For $i = 1 to $dr_all[0]
                MsgBox(4096,"Drive " & $i, $dr_all[$i])
            Next
            EndIf
        EndIf
    Case $msg = $Button_12
        $pass = 1
        $dr_cd = DriveGetDrive("CDROM")
        If @error Then
            Msgbox(0, "ERROR", "No CDROM Drives found.")
            $pass = 0
        EndIf
        If $pass = 1 Then
            If NOT @error Then
                MsgBox(4096,"", "Found " & $dr_cd[0] & " drives")
            For $i = 1 to $dr_cd[0]
                MsgBox(4096,"Drive " & $i, $dr_cd[$i])
            Next
            EndIf
        EndIf
    Case $msg = $Button_13
        $pass = 1
        $dr_removable = DriveGetDrive("REMOVABLE")
        If @error Then
            Msgbox(0, "ERROR", "No Removable Drives found.")
            $pass = 0
        EndIf
        If $pass = 1 Then
            If NOT @error Then
                MsgBox(4096,"", "Found " & $dr_removable[0] & " drives")
            For $i = 1 to $dr_removable[0]
                MsgBox(4096,"Drive " & $i, $dr_removable[$i])
            Next
            EndIf
        EndIf
    Case $msg = $Button_15
        $SD = InputBox("Selection", "Please Enter the drive path that you want the size of.", "C:\")
        $SDI = DriveSpaceTotal($SD)
        $SDI2 = DriveSpaceFree($SD)
        If Not @error Then
            MsgBox(0, "Drive Space for Drive: " & $SD, "Drive total space: " & Round($SDI/ 1024, 2) & " MegaBytes")
            MsgBox(0, "Drive Free Space for Drive: " & $SD, "Drive free space: " &  Round($SDI2/ 1024, 2) & " MegaBytes")
        EndIf
        If @error Then
            MsgBox(0, "ERROR: DRIVE NOT FOUND!!!", "---That is an invalid drive path, please enter correct path!!!---")
        EndIf
    Case $msg = $Go_B
            If GUICtrlRead($winClose_R) = $GUI_CHECKED Then _winClose()
            If GUICtrlRead($winKill_R) = $GUI_CHECKED Then _winKill()
            If GUICtrlRead($winshow_R) = $GUI_CHECKED Then _winshow()
            If GUICtrlRead($winhide_R) = $GUI_CHECKED Then _winhide()
    Case $msg = $processClose_R
        _processCombo()
    Case $msg = $winKill_R Or $msg = $winClose_R
        _winListCombo()
    Case $msg = $cd_o
        $o = InputBox("Open", "Please enter the Drive you want to open. If it is a CD drive the disk will eject", "C:\")
        CDTray($o, "OPEN")
        If @error = 0 Then
            Run('Explorer.exe "' & $o & '"', @WorkingDir, @SW_SHOW)
        EndIf
    Case $msg = $retest_c
        GuiCtrlSetData($Internet, GetToggle3r(GuiCtrlRead($Internet)))
        _Internet()
    Case $msg = $Credits
        MsgBox(0, "Credits", "This program was made by Firestorm.")
        MsgBox(0, "Q/C", "Questions? Comments? Errors? E-mail me at firestorm037@hotmail.com!")
    Case $msg = $tree
        $Path = FileSelectFolder("Choose a folder.", "")
        Run('Explorer.exe "' & $Path & '"', @WorkingDir, @SW_SHOW)
    Case $msg = $Go_A
        If GuiCtrlRead($processClose_R) = $GUI_CHECKED Then _processClose()
    Case $msg = $rr_run
        $program = GUICtrlRead($r_input)
        $program_path = GUICtrlRead($rp_input)
        Run($program & ".exe", $program_path)
        If @error = 1 Then
            MsgBox(48, "ERROR", "That is an invailid file or file path.")
        EndIf
    Case $MSG = $but1
            _GUICtrlListView_DeleteAllItems ($ulist)
            $RemoteComputer = StringReplace(GUICtrlRead($Input1), '', '')
            $List = ReadKeys($RemoteComputer)
            GUICtrlSetData($Input1, '')
        Case $MSG = $but2
            $ListIndices = _GUICtrlListView_GetSelectedIndices ($ulist, 1)
            If $ListIndices == $LV_ERR Then ContinueLoop
            If $ListIndices[0] > 1 Then GUICtrlSetState($Progress1, $GUI_SHOW)
            ;Opt('RunErrorsFatal', 0)
            $Count = 0
            ControlListView('', '', $ulist, "SelectClear")
            For $x = $ListIndices[0] To 1 Step - 1
                $Count += 1
                $SelectKey = ''
                GUICtrlSetData($Progress1, Int(($Count / $ListIndices[0]) * 100))
                $ListInfo = StringSplit($List[$ListIndices[$x]], '|');ListInfo[0] = 5, ListInfo[1] = Display Name, ListInfo[2] = Regkey Name, ListInfo[3] = Icon, ListInfo[4] = QuietUninstallString, ListInfo[5] = UnistallString
                If GUICtrlRead($chkbox) == $GUI_CHECKED Or $RemoteComputer <> '' Then
                    $SelectKey = $ListInfo[4]
                    If $SelectKey == '' Then $SelectKey = StringReplace($ListInfo[5], '/i', '/X', 1) & ' /qn /norestart'
                    _GuiCtrlStatusBar_SetText ($StatusBar1, ' Uninstalling Program ' & $Count & ' Of ' & $ListIndices[0] & '  ' & $ListInfo[1])
                EndIf
                If GUICtrlRead($chkbox) == $GUI_UNCHECKED And $SelectKey == '' Then
                    $SelectKey = $ListInfo[5]
                    _GuiCtrlStatusBar_SetText ($StatusBar1, ' Uninstalling Program ' & $Count & ' Of ' & $ListIndices[0] & '  ' & $ListInfo[1])
                EndIf
                If $RemoteComputer == '' Then
                    $Pid = Run($SelectKey, @WorkingDir, @SW_SHOW)
                Else
                    $Pid = Run('BeyondExec.exe ' & StringMid($RemoteComputer, 1, StringInStr($RemoteComputer, '', 0, -1) - 1) & ' -s -n -r ' & $SelectKey, @WorkingDir, @SW_HIDE)
                EndIf
                If @error Then
                    _FileWriteLog(@ScriptDir & '\UninstallFail.Log', $ListInfo[1] & ' | ' & $SelectKey)
                EndIf
                If Not @error And $RemoteComputer <> "" Then GUISetCursor(15, 1);set cursor to wait
                While ProcessExists($Pid)
                    Sleep(50)
                WEnd
                GUISetCursor(2, 1);set cursor to arrow
;ProcessWaitClose($Pid)
                SetError(0)
                RegRead($RemoteComputer & $Key & "\" & $ListInfo[2], 'UninstallString')
                If @error == 1 Then
                    _GUICtrlListView_DeleteItem ($ulist, $ListIndices[$x])
                    _ArrayDelete($List, $ListIndices[$x])
                EndIf
            Next
;$Pos = WinGetPos($Title)
;_GUICtrlListViewScroll($ulist, 0, Number('-' & $Pos[3] * 20))
            ;Opt('RunErrorsFatal', 1)
            GUICtrlSetData($Progress1, 0)
            If $ListIndices[0] > 1 Then GUICtrlSetState($Progress1, $GUI_HIDE)
            If $RemoteComputer == '' Then
                _GuiCtrlStatusBar_SetText ($StatusBar1, ' Local Computer: ' & _GUICtrlListView_GetItemCount ($ulist) & ' Objects, ' & _GUICtrlListView_GetSelectedCount ($ulist) & ' Objects Selected')
            Else
                _GuiCtrlStatusBar_SetText ($StatusBar1, ' Remote Computer: ' & '"' & StringReplace($RemoteComputer, '', '') & '"' & ', ' & _GUICtrlListView_GetItemCount ($ulist) & ' Objects, ' _
                         & _GUICtrlListView_GetSelectedCount ($ulist) & ' Objects Selected')
            EndIf
            GUICtrlSetState($but2, $GUI_DISABLE)
        Case $MSG = $GUI_EVENT_CLOSE
            Exit
; resize columns based on window size
        Case $MSG = $GUI_EVENT_MINIMIZE
            $width = ControlGetPos($mainWindows, "", $ulist)
            $Resize = $width[2] - _GUICtrlListView_GetColumnWidth ($ulist, 0)
            _GUICtrlListView_SetColumnWidth ($ulist, 1, $Resize / 2.1)
            _GUICtrlListView_SetColumnWidth ($ulist, 2, $Resize / 2.1)
            _GuiCtrlStatusBar_Resize ($StatusBar1)
        Case $MSG = $GUI_EVENT_MAXIMIZE
            $width = ControlGetPos($mainWindows, "", $ulist)
            $Resize = $width[2] - _GUICtrlListView_GetColumnWidth ($ulist, 0)
            _GUICtrlListView_SetColumnWidth ($ulist, 1, $Resize / 2.1)
            _GUICtrlListView_SetColumnWidth ($ulist, 2, $Resize / 2.1)
            _GuiCtrlStatusBar_Resize ($StatusBar1)
        Case $MSG = $GUI_EVENT_RESIZED
            $width = ControlGetPos($mainWindows, "", $ulist)
            $Resize = $width[2] - _GUICtrlListView_GetColumnWidth ($ulist, 0)
            _GUICtrlListView_SetColumnWidth ($ulist, 1, $Resize / 2.1)
            _GUICtrlListView_SetColumnWidth ($ulist, 2, $Resize / 2.1)
            _GuiCtrlStatusBar_Resize ($StatusBar1)
        Case $MSG = $GUI_EVENT_RESTORE
            $width = ControlGetPos($mainWindows, "", $ulist)
            $Resize = $width[2] - _GUICtrlListView_GetColumnWidth ($ulist, 0)
            _GUICtrlListView_SetColumnWidth ($ulist, 1, $Resize / 2.1)
            _GUICtrlListView_SetColumnWidth ($ulist, 2, $Resize / 2.1)
            _GuiCtrlStatusBar_Resize ($StatusBar1)
        Case Else
            If $EnableList And $SelectedCount == 1 Then
                $EnableList = 0
                GUICtrlSetState($but2, $GUI_ENABLE);enable uninstall button
            EndIf
            If Not $EnableList And $SelectedCount == 0 Then
                $EnableList = 1
                GUICtrlSetState($but2, $GUI_DISABLE);disable uninstall button
            EndIf
            If $SelectedCount <> _GUICtrlListView_GetSelectedCount ($ulist) Then
                $SelectedCount = _GUICtrlListView_GetSelectedCount ($ulist)
                If $RemoteComputer == '' Then
                    _GuiCtrlStatusBar_SetText ($StatusBar1, ' Local Computer: ' & _GUICtrlListView_GetItemCount ($ulist) & ' Objects, ' & _GUICtrlListView_GetSelectedCount ($ulist) & ' Objects Selected')
                Else
                    _GuiCtrlStatusBar_SetText ($StatusBar1, ' Remote Computer: ' & '"' & StringReplace($RemoteComputer, '', '') & '"' & ', ' & _GUICtrlListView_GetItemCount ($ulist) & ' Objects, ' _
                             & _GUICtrlListView_GetSelectedCount ($ulist) & ' Objects Selected')
                EndIf
            EndIf
    EndSelect
WEnd
Exit
#endregion Main Script

#region Functions

Func _INITIATE()
    GUICtrlSetData($trans,255)
    $product = "XP"
    _processCombo()
    _winListCombo()
    _Internet()
    For $objOperatingSystem In $colSettings
        Next
        GUICtrlSetData($description_I, StringMid($objOperatingSystem.Description, 1))
        GUICtrlSetData($windowsType_I, '(' & @OSVersion & ') ' & StringMid($objOperatingSystem.Caption, 19))
        GUICtrlSetData($serialNumber_I, StringMid($objOperatingSystem.SerialNumber, 1))
        GUICtrlSetData($ProductKey_I, DecodeProductKey($Bin))
        GUICtrlSetData($InstallDate_I, WMIDateStringToDate($objOperatingSystem.InstallDate))
        GUICtrlSetData($LastBootUpTime_I, WMIDateStringToDate($objOperatingSystem.LastBootUpTime))
        GUICtrlSetData($RegisteredOwner_I, RegRead($key4RegisteredOwner, "RegisteredOwner"))
        GUICtrlSetData($officeKey_I, getOfficeKey())
        GUICtrlSetData($officeKey_L, "Office " & $product & "-------------------")
EndFunc



Func _winClose()
    If WinExists(GUICtrlRead($winCombo_C)) Then
        WinClose(GUICtrlRead($winCombo_C))
    Else
        GUICtrlSetData($status_L, "Window doesn't exist")
        Sleep(2500)
        GUICtrlSetData($status_L, "Ready...")
    EndIf
EndFunc;==>_winClose

Func _winKill()
    If WinExists(GUICtrlRead($winCombo_C)) Then
        WinKill(GUICtrlRead($winCombo_C))
    Else
        GUICtrlSetData($status_L, "Window doesn't exist")
        Sleep(2500)
        GUICtrlSetData($status_L, "Ready...")
    EndIf
EndFunc;==>_winKill

Func _processClose()
    If ProcessExists(GUICtrlRead($processCombo_C)) Then
        ProcessClose(GUICtrlRead($processCombo_C))
    Else
        GUICtrlSetData($status_L, "Process doesn't exist")
        Sleep(2500)
        GUICtrlSetData($status_L, "Ready...") 
    EndIf
EndFunc;==>_processClose

;~ Func _killByPID()
;~     If _ProcessGetName(GUICtrlRead($processCombo_C)) <> '' Then
;~         $rc = _RunDOS("start taskkill /PID " & GUICtrlRead($processCombo_C) & " /T")
;~         GUICtrlSetData($status_L, "ProcessID " & GUICtrlRead($processCombo_C) & " - (" & _ProcessGetName(GUICtrlRead($processCombo_C)) & ")" & " killed")
;~         Sleep(2500)
;~         GUICtrlSetData($status_L, "Ready...")
;~     Else
;~         GUICtrlSetData($status_L, "ProcessID doesn't exist")
;~         Sleep(2500)
;~         GUICtrlSetData($status_L, "Ready...")
;~     EndIf
;~ EndFunc;==>_killByPID

Func _processCombo()
    Dim $processArray = ProcessList()
    For $i = 1 To $processArray[0][0]
        GUICtrlSetData($processCombo_C, $processArray[$i][0])
    Next
EndFunc;==>_processCombo

Func _winListCombo()
    Dim $windowArray = WinList()
    For $i = 1 To $windowArray[0][0]
  ; Only display visble windows that have a title
        If $windowArray[$i][0] <> "" Then;AND IsVisible($var[$i][1]) Then
            GUICtrlSetData($winCombo_C, $windowArray[$i][0])
        EndIf
    Next
EndFunc;==>_winListCombo

Func _winshow()
    If WinExists(GUICtrlRead($winCombo_C)) Then
        WinSetState(GUICtrlRead($winCombo_C),"", @SW_SHOW)
    Else
        GUICtrlSetData($status_L, "Window doesn't exist")
        Sleep(2500)
        GUICtrlSetData($status_L, "Ready...")
    EndIf
EndFunc;==>_winshow

Func _winhide()
    If WinExists(GUICtrlRead($winCombo_C)) Then
        WinSetState(GUICtrlRead($winCombo_C),"", @SW_HIDE)
    Else
        GUICtrlSetData($status_L, "Window doesn't exist")
        Sleep(2500)
        GUICtrlSetData($status_L, "Ready...")
    EndIf
EndFunc;==>_winhide

Func _Internet()
    Local $sInputBoxAnswer = InputBox("Test Connection","Do you want to test your internet connection?" & @CRLF & _
          "You may get a firewall warning dialog warning this will only ping the website you specify to test your connection.","www.yahoo.com")
    If @Error = 0 Then;The Okay button was pushed
        Sleep(500)
        $var = Ping($sInputBoxAnswer)
        If $var Then; also possible:  If @error = 0 Then ...
            GuiCtrlSetData($Internet, GetToggle1(GuiCtrlRead($Internet)))
        Else
            GuiCtrlSetData($Internet, GetToggle2(GuiCtrlRead($Internet)))
        EndIf
    ElseIf @Error = 1 Then;The Cancel button was pushed
        GuiCtrlSetData($Internet, 'Internet Connection Test canceled') 
    ElseIf @Error = 3 Then;error
        GuiCtrlSetData($Internet, 'Internet Connection Test an error has occured') 
    EndIf
EndFunc


Func GetToggle1($stext)
    if $stext = "Testing Internet Connection..." then
        GUICtrlSetColor($Internet, "0x0000ff")
        return "You are connected to the internet!"
        else
        return " "
    endif
EndFunc

Func GetToggle2($stext)
    if $stext = "Testing Internet Connection..." then
        GUICtrlSetColor($Internet, "0xff0000")
        return "WARNING! You are NOT connected to the internet!"
        else
        return " "
    endif
EndFunc

Func GetToggle3r($stext)
    if $stext = "WARNING! You are NOT connected to the internet!" OR "You are connected to the internet!" then
        GUICtrlSetColor($Internet, "0x000000")
        return "Testing Internet Connection..."
        else
        return " "
    endif
EndFunc

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 beta
; Author:         Unknown & Thorsten Meger <Thorsten.Meger@gmx.de>
;
; Script Function: Decode REG_BINARY
; ----------------------------------------------------------------------------

Func DecodeProductKey($BinaryDPID)
    Local $bKey[15]
    Local $sKey[29]
    Local $Digits[24]
    Local $Value = 0
    Local $hi = 0
    Local $n = 0
    Local $i = 0
    Local $dlen = 29
    Local $slen = 15
    Local $Result
    
    $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
    $BinaryDPID = StringMid($BinaryDPID, 105, 30)
    For $i = 1 To 29 Step 2
        $bKey[Int($i / 2) ] = Dec(StringMid($BinaryDPID, $i, 2))
    Next
    For $i = $dlen - 1 To 0 Step - 1
        If Mod(($i + 1), 6) = 0 Then
            $sKey[$i] = "-"
        Else
            $hi = 0
            For $n = $slen - 1 To 0 Step - 1
                $Value = BitOR(BitShift($hi, -8), $bKey[$n])
                $bKey[$n] = Int($Value / 24)
                $hi = Mod($Value, 24)
            Next
            $sKey[$i] = $Digits[$hi + 1]
        EndIf
    Next
    For $i = 0 To 28
        $Result = $Result & $sKey[$i]
    Next
    Return $Result
EndFunc   ;==>DecodeProductKey


; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 beta
; Author:         Unknown & Thorsten Meger <Thorsten.Meger@gmx.de>
;
; Script Function: WMIDateStringToDate (changed Date format)
; ----------------------------------------------------------------------------

Func WMIDateStringToDate($dtmDate)
    Return (StringMid($dtmDate, 7, 2) & "/" & _
            StringMid($dtmDate, 5, 2) & "/" & StringLeft($dtmDate, 4) _
             & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate, 13, 2))
EndFunc   ;==>WMIDateStringToDate


; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 beta
; Author:         Thorsten Meger <Thorsten.Meger@gmx.de>
;
; Script Function:Get & decode OfficeKey
; ----------------------------------------------------------------------------

Func getOfficeKey()
    Local $List[1]
    Local $i = 1
    $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot", "Path")
    If $var <> "" Then
        $product = "2003"
        Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration"
    Else
        $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Common\InstallRoot", "Path")
        If @error <> 0 Then
            GUICtrlSetData($status_L, "Info: Unable to find installationPath, maybe no Office installed!")
            Return "No Office XP or 2003 found"
        EndIf
        If $var <> "" Then
            $product = "XP"
            Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration"
        EndIf
    EndIf
    Dim $var = RegEnumKey($officeKey, $i)
    If @error <> 0 Then
        GUICtrlSetData($status_L, "Info: Unable to find REG_BINARY 'DigitalProductID', maybe no Office installed!")
        Return "No Office XP or 2003 found"
    Else
        $List[$i - 1] = RegRead($officeKey & "\" & $var, "DigitalProductID")
        If $List[$i - 1] = "" Then
            GUICtrlSetData($status_L, "Info: Unable to find REG_BINARY 'DigitalProductID', maybe no Office installed!")
        Else
            $key = $List[$i - 1]
            Return DecodeProductKey($key)
        EndIf
    EndIf
EndFunc   ;==>getOfficeKey


Func ReadKeys($s_RemoteComputer = '')
    _GuiCtrlStatusBar_SetText ($StatusBar1, ' Reading Registry Keys, Please Wait....')
    GUISetCursor(15, 1);set cursor to wait
    Local $even = 1
    Local $Count = 1
    Dim $avArray[1]
    
    If $s_RemoteComputer <> '' Then
        If StringMid($s_RemoteComputer, 1, 1) <> '' Or StringMid($s_RemoteComputer, 2, 1) <> '' Or StringRight($s_RemoteComputer, 1) <> '' Then
            $s_RemoteComputer = '\' & StringReplace($s_RemoteComputer, '', '') & ''
        EndIf
    EndIf
    Local Const $regkey = $s_RemoteComputer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    While 1
        $skey = RegEnumKey($regkey, $Count)
        If @error <> 0 Then ExitLoop
        $line = RegRead($regkey & '' & $skey, 'Displayname')
        $line = StringReplace($line, ' (remove only)', '')
        If $line == '' Then $line = "No Display Name"
        $SilentUnistall = RegRead($regkey & '' & $skey, 'QuietUninstallString')
        $Unistall = RegRead($regkey & '' & $skey, 'UninstallString')
        $Icon = RegRead($regkey & '' & $skey, 'DisplayIcon')
        $Icon = StringReplace(StringMid($Icon, 1, StringInStr($Icon, ',') - 1), '"', '')
        If $Icon = "" Then $Icon = "SHELL32.DLL"
        
        If $SilentUnistall <> '' Or $Unistall <> '' Then
            If (GUICtrlRead($chkbox) == $GUI_CHECKED And $SilentUnistall <> '') Or ($s_RemoteComputer <> '' And $SilentUnistall <> '') Then
                $avArray[UBound($avArray) - 1] = $line & '|' & $skey & '|' & $Icon & '|' & $SilentUnistall & '|'
                ReDim $avArray[UBound($avArray) + 1]
            ElseIf ($s_RemoteComputer == '' And GUICtrlRead($chkbox) == $GUI_UNCHECKED) Or (GUICtrlRead($chkbox) == $GUI_CHECKED And StringInStr($Unistall, 'msiexec.exe')) Or ($s_RemoteComputer <> '' And StringInStr($Unistall, 'msiexec.exe')) Then
                $avArray[UBound($avArray) - 1] = $line & '|' & $skey & '|' & $Icon & '|' & $SilentUnistall & '|' & $Unistall
                ReDim $avArray[UBound($avArray) + 1]
            EndIf
        EndIf
        $Count += 1
    WEnd
    If (UBound($avArray) - 1) == 0 Then
        If $RemoteComputer == '' Then _GuiCtrlStatusBar_SetText ($StatusBar1, ' Local Computer: ' & _GUICtrlListView_GetItemCount ($ulist) & ' Objects, ' & _GUICtrlListView_GetSelectedCount ($ulist) & ' Objects Selected')
        If $RemoteComputer <> '' And _GUICtrlListView_GetItemCount ($ulist) Then
            _GuiCtrlStatusBar_SetText ($StatusBar1, ' Remote Computer: ' & '"' & StringReplace($RemoteComputer, '', '') & '"' & ', ' & _GUICtrlListView_GetItemCount ($ulist) & ' Objects, ' _
                     & _GUICtrlListView_GetSelectedCount ($ulist) & ' Objects Selected')
            $RemoteComputer = '\' & $RemoteComputer & ''
        ElseIf $RemoteComputer <> '' And _GUICtrlListView_GetItemCount ($ulist) == 0 Then
            _GuiCtrlStatusBar_SetText ($StatusBar1, ' Could Not Connect To Remote Computer ' & '"' & StringReplace($RemoteComputer, '', '') & '"')
            $RemoteComputer = ''
        EndIf
    Else
        ReDim $avArray[UBound($avArray) - 1]
        _ArraySort($avArray)
        GUICtrlSetState($Progress1, $GUI_SHOW)
        For $i = 0 To UBound($avArray) - 1
            GUICtrlSetData($Progress1, Int(($i / (UBound($avArray) - 1)) * 100))
            $Item = StringSplit($avArray[$i], '|')
            Local $lv_item = GUICtrlCreateListViewItem("" & "|" & $Item[1] & "|" & $Item[2], $ulist)
            GUICtrlSetImage(-1, $Item[3])
            If $even Then
                $even = 0
                GUICtrlSetBkColor($lv_item, 0x5CACEE)
            Else
                GUICtrlSetBkColor($lv_item, 0x9FB6CD)
                $even = 1
            EndIf
            Sleep(15)
        Next
        Sleep(1000)
        If $RemoteComputer == '' Then _GuiCtrlStatusBar_SetText ($StatusBar1, ' Local Computer: ' & _GUICtrlListView_GetItemCount ($ulist) & ' Objects, ' & _GUICtrlListView_GetSelectedCount ($ulist) & ' Objects Selected')
        If $RemoteComputer <> '' And _GUICtrlListView_GetItemCount ($ulist) Then
            _GuiCtrlStatusBar_SetText ($StatusBar1, ' Remote Computer: ' & '"' & StringReplace($RemoteComputer, '', '') & '"' & ', ' & _GUICtrlListView_GetItemCount ($ulist) & ' Objects, ' _
                     & _GUICtrlListView_GetSelectedCount ($ulist) & ' Objects Selected')
            $RemoteComputer = '\' & $RemoteComputer & ''
        ElseIf $RemoteComputer <> '' And _GUICtrlListView_GetItemCount ($ulist) == 0 Then
            _GuiCtrlStatusBar_SetText ($StatusBar1, ' Could Not Connect To Remote Computer ' & '"' & StringReplace($RemoteComputer, '', '') & '"')
            $RemoteComputer = ''
        EndIf
    EndIf
    GUICtrlSetState($Progress1, $GUI_HIDE)
    GUISetCursor(2, 1);set cursor to arrow
    Return ($avArray)
EndFunc;==>ReadKeys

Func SelectAll()
    If $SelectAll Then
        $SelectAll = 0
        GUICtrlSetState($but2, $GUI_DISABLE)
    Else
        $SelectAll = 1
        GUICtrlSetState($but2, $GUI_ENABLE)
    EndIf
    _GUICtrlListView_SetItemState($ulist, -1, $LVIS_FOCUSED, $SelectAll)
EndFunc;==>SelectAll

Func Stop();exit the gui
    Exit
EndFunc;==>Stop
#endregion Functions
 楼主| 发表于 2012-9-6 09:43:34 | 显示全部楼层
@ xiehuahere
测试一下,感谢分享,这是查看本地硬件信息,如果想查看局域网内其他机器的硬件信息,咋办?

不吝赐教。
发表于 2021-1-25 08:58:31 | 显示全部楼层
vr4u 发表于 2012-9-6 09:43
@ xiehuahere
测试一下,感谢分享,这是查看本地硬件信息,如果想查看局域网内其他机器的硬件信息,咋办 ...

没办法,只能安装网管软件,或者你自己做一个网管软件。网络上默认只会返回IP,mac,设备名,开放端口,端口返回协议。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-26 15:43 , Processed in 0.076092 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表