diff options
Diffstat (limited to 'setupapi/setupapi_windows.go')
-rw-r--r-- | setupapi/setupapi_windows.go | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/setupapi/setupapi_windows.go b/setupapi/setupapi_windows.go index 6e81a9e..31a0bff 100644 --- a/setupapi/setupapi_windows.go +++ b/setupapi/setupapi_windows.go @@ -7,40 +7,17 @@ package setupapi import ( "syscall" + "unsafe" "golang.org/x/sys/windows" ) -const ( - SP_MAX_MACHINENAME_LENGTH = windows.MAX_PATH + 3 -) - -type DIGCF uint32 - -const ( - DIGCF_DEFAULT DIGCF = 0x00000001 // only valid with DIGCF_DEVICEINTERFACE - DIGCF_PRESENT DIGCF = 0x00000002 - DIGCF_ALLCLASSES DIGCF = 0x00000004 - DIGCF_PROFILE DIGCF = 0x00000008 - DIGCF_DEVICEINTERFACE DIGCF = 0x00000010 -) - -type DevInfo windows.Handle - -// The SetupDiDestroyDeviceInfoList function deletes a device information set and frees all associated memory. -func (h DevInfo) Close() error { - if h != DevInfo(windows.InvalidHandle) { - return SetupDiDestroyDeviceInfoList(h) - } - - return nil -} - -//sys setupDiGetClassDevsEx(ClassGuid *windows.GUID, Enumerator *uint16, hwndParent uintptr, Flags DIGCF, DeviceInfoSet DevInfo, MachineName *uint16, reserved uintptr) (handle DevInfo, err error) [failretval==DevInfo(windows.InvalidHandle)] = setupapi.SetupDiGetClassDevsExW +//sys setupDiGetClassDevsEx(ClassGUID *windows.GUID, Enumerator *uint16, hwndParent uintptr, Flags DIGCF, DeviceInfoSet DevInfo, MachineName *uint16, reserved uintptr) (handle DevInfo, err error) [failretval==DevInfo(windows.InvalidHandle)] = setupapi.SetupDiGetClassDevsExW //sys SetupDiDestroyDeviceInfoList(DeviceInfoSet DevInfo) (err error) = setupapi.SetupDiDestroyDeviceInfoList +//sys setupDiGetDeviceInfoListDetail(DeviceInfoSet DevInfo, DeviceInfoSetDetailData *SP_DEVINFO_LIST_DETAIL_DATA) (err error) = setupapi.SetupDiGetDeviceInfoListDetailW -// The SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements for a local or a remote computer. -func SetupDiGetClassDevsEx(ClassGuid *windows.GUID, Enumerator string, hwndParent uintptr, Flags DIGCF, DeviceInfoSet DevInfo, MachineName string) (handle DevInfo, err error) { +// SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements for a local or a remote computer. +func SetupDiGetClassDevsEx(ClassGUID *windows.GUID, Enumerator string, hwndParent uintptr, Flags DIGCF, DeviceInfoSet DevInfo, MachineName string) (handle DevInfo, err error) { var _p0 *uint16 if Enumerator != "" { _p0, err = syscall.UTF16PtrFromString(Enumerator) @@ -55,5 +32,23 @@ func SetupDiGetClassDevsEx(ClassGuid *windows.GUID, Enumerator string, hwndParen return } } - return setupDiGetClassDevsEx(ClassGuid, _p0, hwndParent, Flags, DeviceInfoSet, _p1, 0) + return setupDiGetClassDevsEx(ClassGUID, _p0, hwndParent, Flags, DeviceInfoSet, _p1, 0) +} + +// SetupDiGetDeviceInfoListDetail function retrieves information associated with a device information set including the class GUID, remote computer handle, and remote computer name. +func SetupDiGetDeviceInfoListDetail(DeviceInfoSet DevInfo) (data *DevInfoListDetailData, err error) { + var _p0 SP_DEVINFO_LIST_DETAIL_DATA + _p0.Size = uint32(unsafe.Sizeof(_p0)) + + err = setupDiGetDeviceInfoListDetail(DeviceInfoSet, &_p0) + if err != nil { + return + } + + data = &DevInfoListDetailData{ + ClassGUID: _p0.ClassGUID, + RemoteMachineHandle: _p0.RemoteMachineHandle, + RemoteMachineName: windows.UTF16ToString(_p0.RemoteMachineName[:]), + } + return } |