#include <Constants.au3>
#include <WinAPI.au3>
Global $sHardwareID = "ACPI\PNP0C02\1" ; ID do hardware da porta ACPI
Global Const $DICS_ENABLE = 0x0
Global Const $DICS_DISABLE = 0x1
; Desativa o dispositivo correspondente ao hardware ID
Func DisableDevice($sHardwareID)
Local $hDevInfo, $i, $tSPDevInfoData, $bResult
; Obtém a lista de dispositivos presentes no sistema
$hDevInfo = _WinAPI_SetupDiGetClassDevs($tagGUID_DEVCLASS_SYSTEM, Null, Null, $DIGCF_PRESENT)
If $hDevInfo = $INVALID_HANDLE_VALUE Then
Return False
EndIf
; Procura pelo dispositivo com o hardware ID correspondente
$i = 0
Do
$tSPDevInfoData = _WinAPI_GetDeviceDataStruct($hDevInfo, $i)
If _WinAPI_DevicePropertyString($tSPDevInfoData, $SPDRP_HARDWAREID) = $sHardwareID Then
; Desativa o dispositivo encontrado
$bResult = _WinAPI_SetupDiSetDeviceState($hDevInfo, $tSPDevInfoData, $DICS_DISABLE, $DICS_FLAG_GLOBAL)
ExitLoop
EndIf
$i += 1
Until _WinAPI_SetupDiGetDeviceData($hDevInfo, $tSPDevInfoData)
_WinAPI_SetupDiDestroyDeviceInfoList($hDevInfo)
Return $bResult
EndFunc
; Desativa o dispositivo com o hardware ID especificado
DisableDevice($sHardwareID)