Simplify reading NetCfgInstanceId from registry
As querying non-existing registry value and reading non-existing registry string value both return ERROR_FILE_NOT_FOUND, we can use later only. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
cddfd9a0d8
commit
9041d38e2d
|
@ -386,8 +386,8 @@ func getInterfaceId(deviceInfoSet setupapi.DevInfo, deviceInfoData *setupapi.Dev
|
||||||
defer key.Close()
|
defer key.Close()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// Query the NetCfgInstanceId value. Using get_reg_string() right on might clutter the output with error messages while the registry is still being populated.
|
// Read the NetCfgInstanceId value.
|
||||||
_, _, err = key.GetValue("NetCfgInstanceId", nil)
|
value, err := getRegStringValue(key, "NetCfgInstanceId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_FILE_NOT_FOUND {
|
if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_FILE_NOT_FOUND {
|
||||||
numAttempts--
|
numAttempts--
|
||||||
|
@ -399,12 +399,6 @@ func getInterfaceId(deviceInfoSet setupapi.DevInfo, deviceInfoData *setupapi.Dev
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.New("RegQueryValueEx(\"NetCfgInstanceId\") failed: " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the NetCfgInstanceId value now.
|
|
||||||
value, err := getRegStringValue(key, "NetCfgInstanceId")
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.New("RegQueryStringValue(\"NetCfgInstanceId\") failed: " + err.Error())
|
return nil, errors.New("RegQueryStringValue(\"NetCfgInstanceId\") failed: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue