Juan Lang : setupapi: Add helper function to open a device's hardware key.
Alexandre Julliard
julliard at winehq.org
Fri Oct 12 05:23:02 CDT 2007
Module: wine
Branch: master
Commit: 22724c2c8b6859f450778c9b5705cb14f0aa3c48
URL: http://source.winehq.org/git/wine.git/?a=commit;h=22724c2c8b6859f450778c9b5705cb14f0aa3c48
Author: Juan Lang <juan.lang at gmail.com>
Date: Thu Oct 11 13:24:42 2007 -0700
setupapi: Add helper function to open a device's hardware key.
---
dlls/setupapi/devinst.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 1f3d3b9..d549562 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -407,6 +407,22 @@ static BOOL SETUPDI_SetInterfaceSymbolicLink(SP_DEVICE_INTERFACE_DATA *iface,
return ret;
}
+static HKEY SETUPDI_CreateDevKey(struct DeviceInfo *devInfo)
+{
+ HKEY enumKey, key = INVALID_HANDLE_VALUE;
+ LONG l;
+
+ l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_ALL_ACCESS,
+ NULL, &enumKey, NULL);
+ if (!l)
+ {
+ RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, 0,
+ KEY_READ | KEY_WRITE, NULL, &key, NULL);
+ RegCloseKey(enumKey);
+ }
+ return key;
+}
+
static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
LPCWSTR instanceId, BOOL phantom)
{
@@ -420,23 +436,16 @@ static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
(lstrlenW(instanceId) + 1) * sizeof(WCHAR));
if (devInfo->instanceId)
{
- HKEY enumKey;
- LONG l;
-
devInfo->key = INVALID_HANDLE_VALUE;
devInfo->phantom = phantom;
lstrcpyW(devInfo->instanceId, instanceId);
struprW(devInfo->instanceId);
- l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0,
- KEY_ALL_ACCESS, NULL, &enumKey, NULL);
- if (!l)
+ devInfo->key = SETUPDI_CreateDevKey(devInfo);
+ if (devInfo->key != INVALID_HANDLE_VALUE)
{
- RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, 0,
- KEY_ALL_ACCESS, NULL, &devInfo->key, NULL);
if (phantom)
RegSetValueExW(devInfo->key, Phantom, 0, REG_DWORD,
(LPBYTE)&phantom, sizeof(phantom));
- RegCloseKey(enumKey);
}
list_init(&devInfo->interfaces);
}
More information about the wine-cvs
mailing list