Here is the function that worked for me.
; #FUNCTION# ====================================================================================================================
; Name...........: _DeviceAPI_RemoveDevice
; Description ...: Get class name from class GUID
; Syntax.........: -
; Parameters ....: -
; Return values .: Success - String
; Failure - NULL String, @ERROR set
; Author ........: Matthew Horn (weaponx)
; Modified.......: -
; Remarks .......: -
; Related .......: -
; Link ..........; @@MsdnLink@@ - http://msdn.microsoft.com/en-us/library/ms792990.aspx
; Example .......; Yes
; ===============================================================================================================================
Func _DeviceAPI_RemoveDevice()
Local $result = DllCall($setupapi_dll,"int","SetupDiCallClassInstaller","dword", 5,"hwnd", $hDevInfo,"ptr", $pSP_DEVINFO_DATA)
If @ERROR Then
Return SetError(@ERROR,@EXTENDED,"")
Else
;Check for WinAPI error
$WinAPI_Error = _WinAPI_GetLastError()
If $WinAPI_Error <> 0 Then
;ConsoleWrite("Error " & _WinAPI_GetLastError() & ": " & _WinAPI_GetLastErrorMessage())
;Exit
Return SetError(1,1,0)
Else
;Debug($result)
Return $result[3]
EndIf
EndIf
EndFunc