summaryrefslogtreecommitdiffhomepage
path: root/setupapi/setupapi_windows_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'setupapi/setupapi_windows_test.go')
-rw-r--r--setupapi/setupapi_windows_test.go34
1 files changed, 30 insertions, 4 deletions
diff --git a/setupapi/setupapi_windows_test.go b/setupapi/setupapi_windows_test.go
index 8aa7221..25e712f 100644
--- a/setupapi/setupapi_windows_test.go
+++ b/setupapi/setupapi_windows_test.go
@@ -43,7 +43,7 @@ func TestSetupDiGetDeviceInfoListDetailLocal(t *testing.T) {
if err != nil {
t.Errorf("Error calling SetupDiGetClassDevsEx: %s", err.Error())
}
- defer SetupDiDestroyDeviceInfoList(devInfoList)
+ defer devInfoList.Close()
data, err := SetupDiGetDeviceInfoListDetail(devInfoList)
if err != nil {
@@ -68,7 +68,7 @@ func TestSetupDiGetDeviceInfoListDetailRemote(t *testing.T) {
if err != nil {
t.Errorf("Error calling SetupDiGetClassDevsEx: %s", err.Error())
}
- defer SetupDiDestroyDeviceInfoList(devInfoList)
+ defer devInfoList.Close()
data, err := SetupDiGetDeviceInfoListDetail(devInfoList)
if err != nil {
@@ -93,10 +93,11 @@ func TestSetupDiEnumDeviceInfo(t *testing.T) {
if err != nil {
t.Errorf("Error calling SetupDiGetClassDevsEx: %s", err.Error())
}
- defer SetupDiDestroyDeviceInfoList(devInfoList)
+ defer devInfoList.Close()
+ var data SP_DEVINFO_DATA
for i := 0; true; i++ {
- data, err := SetupDiEnumDeviceInfo(devInfoList, i)
+ err := SetupDiEnumDeviceInfo(devInfoList, i, &data)
if err != nil {
if errWin, ok := err.(syscall.Errno); ok && errWin == 259 /*ERROR_NO_MORE_ITEMS*/ {
break
@@ -109,3 +110,28 @@ func TestSetupDiEnumDeviceInfo(t *testing.T) {
}
}
}
+
+func TestSetupDiOpenDevRegKey(t *testing.T) {
+ devInfoList, err := SetupDiGetClassDevsEx(&deviceClassNetGUID, "", 0, DIGCF_PRESENT, DevInfo(0), "")
+ if err != nil {
+ t.Errorf("Error calling SetupDiGetClassDevsEx: %s", err.Error())
+ }
+ defer devInfoList.Close()
+
+ var data SP_DEVINFO_DATA
+ for i := 0; true; i++ {
+ err := SetupDiEnumDeviceInfo(devInfoList, i, &data)
+ if err != nil {
+ if errWin, ok := err.(syscall.Errno); ok && errWin == 259 /*ERROR_NO_MORE_ITEMS*/ {
+ break
+ }
+ continue
+ }
+
+ key, err := SetupDiOpenDevRegKey(devInfoList, &data, DICS_FLAG_GLOBAL, 0, DIREG_DRV, windows.KEY_READ)
+ if err != nil {
+ t.Errorf("Error calling SetupDiOpenDevRegKey: %s", err.Error())
+ }
+ defer key.Close()
+ }
+}