| 本帖最后由 lixiaolong 于 2012-2-20 23:30 编辑 
 回复 12# 49666684
 
 启用,禁用系统中的所有音频设备.
 
 #include <SetupApi.au3>
Local $hDevs, $tDevInfo, $aSound[1][2] = [[0]]
$hDevs = _SetupDiGetClassDevs($DIGCF_PRESENT, "media")
While _SetupDiEnumDeviceInfo($hDevs, $aSound[0][0], $tDevInfo)
        $aSound[0][0] += 1
        $sDescr = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, $SPDRP_DEVICEDESC)
        $sName = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, $SPDRP_FRIENDLYNAME)
        If $sName <> "" Then $sDescr = $sName
        ReDim $aSound[$aSound[0][0] + 1][2]
        $aSound[$aSound[0][0]][0] = $sDescr 
        $aSound[$aSound[0][0]][1] = _SetupDiGetDeviceInstanceID($hDevs, $tDevInfo) 
        
        $fResult = _SetupDiDisableDevice($hDevs, $tDevInfo, True) ; 禁用
;~         $fResult = _SetupDiDisableDevice($hDevs, $tDevInfo, False) ; 启用
WEnd
 
 可以精简.
 
 #include <SetupApi.au3>
Local $hDevs, $tDevInfo, $aSound[1][2] = [[0]]
$hDevs = _SetupDiGetClassDevs($DIGCF_PRESENT, "media")
While _SetupDiEnumDeviceInfo($hDevs, $aSound[0][0], $tDevInfo)
        $aSound[0][0] += 1
;~         $fResult = _SetupDiDisableDevice($hDevs, $tDevInfo, True) ; 禁用
        $fResult = _SetupDiDisableDevice($hDevs, $tDevInfo, False) ; 启用
WEnd
 |