diff options
author | Simon Rozman <simon@rozman.si> | 2019-02-01 10:58:06 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-02-05 12:59:42 +0100 |
commit | d41bc015ccc06feedd21c0a87b0a44a02b74d530 (patch) | |
tree | eac0a0c74e2077ba1e605b6dcedc9acbda9f2510 /setupapi/setupapi_windows.go | |
parent | 31949136df477c5699d7476e909d9bf30a0904cc (diff) |
Finish support for setupapi.SetupDiGetClassDevsEx()
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'setupapi/setupapi_windows.go')
-rw-r--r-- | setupapi/setupapi_windows.go | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/setupapi/setupapi_windows.go b/setupapi/setupapi_windows.go index 22cacee..6e81a9e 100644 --- a/setupapi/setupapi_windows.go +++ b/setupapi/setupapi_windows.go @@ -6,6 +6,8 @@ package setupapi import ( + "syscall" + "golang.org/x/sys/windows" ) @@ -16,26 +18,42 @@ const ( type DIGCF uint32 const ( - Default DIGCF = 0x00000001 - Present DIGCF = 0x00000002 - AllClasses DIGCF = 0x00000004 - Profile DIGCF = 0x00000008 - DeviceInterface DIGCF = 0x00000010 - InterfaceDevice DIGCF = 0x00000010 + 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 -//sys setupDiGetClassDevsEx(ClassGuid *windows.GUID, Enumerator *string, hwndParent uintptr, Flags uint32, DeviceInfoSet uintptr, MachineName string, reserved uint32) (handle windows.Handle, err error) = setupapi.SetupDiGetClassDevsExW +// 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) + } -// 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) (DevInfo, error) { - enumerator := &Enumerator + return nil +} - if Enumerator == "" { - enumerator = 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 SetupDiDestroyDeviceInfoList(DeviceInfoSet DevInfo) (err error) = setupapi.SetupDiDestroyDeviceInfoList - h, err := setupDiGetClassDevsEx(ClassGuid, enumerator, hwndParent, uint32(Flags), uintptr(DeviceInfoSet), MachineName, 0) - return DevInfo(h), err +// 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) { + var _p0 *uint16 + if Enumerator != "" { + _p0, err = syscall.UTF16PtrFromString(Enumerator) + if err != nil { + return + } + } + var _p1 *uint16 + if MachineName != "" { + _p1, err = syscall.UTF16PtrFromString(MachineName) + if err != nil { + return + } + } + return setupDiGetClassDevsEx(ClassGuid, _p0, hwndParent, Flags, DeviceInfoSet, _p1, 0) } |