Juan Lang : setupapi: Implement SetupDiDeleteDevRegKey.
Alexandre Julliard
julliard at winehq.org
Mon Oct 15 11:27:49 CDT 2007
Module: wine
Branch: master
Commit: 8b5faacfb400279641b3c88801fed9775aafc700
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8b5faacfb400279641b3c88801fed9775aafc700
Author: Juan Lang <juan.lang at gmail.com>
Date: Fri Oct 12 08:26:31 2007 -0700
setupapi: Implement SetupDiDeleteDevRegKey.
---
dlls/setupapi/devinst.c | 125 ++++++++++++++++++++++++++++++++++++++++++-
dlls/setupapi/setupapi.spec | 2 +-
include/setupapi.h | 2 +-
3 files changed, 125 insertions(+), 4 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 0a6bed8..4087710 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -439,8 +439,8 @@ static HKEY SETUPDI_CreateDrvKey(struct DeviceInfo *devInfo)
KEY_ALL_ACCESS, NULL, &classKey, NULL);
if (!l)
{
- static const WCHAR fmt[] = { '%','0','4','d',0 };
- WCHAR devId[5];
+ static const WCHAR fmt[] = { '%','0','4','u',0 };
+ WCHAR devId[10];
sprintfW(devId, fmt, devInfo->devId);
RegCreateKeyExW(classKey, devId, 0, NULL, 0, KEY_READ | KEY_WRITE,
@@ -3678,3 +3678,124 @@ HKEY WINAPI SetupDiOpenDevRegKey(
}
return key;
}
+
+static BOOL SETUPDI_DeleteDevKey(struct DeviceInfo *devInfo)
+{
+ HKEY enumKey;
+ BOOL ret = FALSE;
+ LONG l;
+
+ l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_ALL_ACCESS,
+ NULL, &enumKey, NULL);
+ if (!l)
+ {
+ ret = RegDeleteTreeW(enumKey, devInfo->instanceId);
+ RegCloseKey(enumKey);
+ }
+ else
+ SetLastError(l);
+ return ret;
+}
+
+static BOOL SETUPDI_DeleteDrvKey(struct DeviceInfo *devInfo)
+{
+ static const WCHAR slash[] = { '\\',0 };
+ WCHAR classKeyPath[MAX_PATH];
+ HKEY classKey;
+ LONG l;
+ BOOL ret = FALSE;
+
+ lstrcpyW(classKeyPath, ControlClass);
+ lstrcatW(classKeyPath, slash);
+ SETUPDI_GuidToString(&devInfo->set->ClassGuid,
+ classKeyPath + lstrlenW(classKeyPath));
+ l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
+ KEY_ALL_ACCESS, NULL, &classKey, NULL);
+ if (!l)
+ {
+ static const WCHAR fmt[] = { '%','0','4','u',0 };
+ WCHAR devId[10];
+
+ sprintfW(devId, fmt, devInfo->devId);
+ ret = RegDeleteTreeW(classKey, devId);
+ RegCloseKey(classKey);
+ }
+ else
+ SetLastError(l);
+ return ret;
+}
+
+/***********************************************************************
+ * SetupDiOpenDevRegKey (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiDeleteDevRegKey(
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ DWORD Scope,
+ DWORD HwProfile,
+ DWORD KeyType)
+{
+ struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
+ struct DeviceInfo *devInfo;
+ BOOL ret = FALSE;
+
+ TRACE("%p %p %d %d %d\n", DeviceInfoSet, DeviceInfoData, Scope, HwProfile,
+ KeyType);
+
+ if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
+ || !DeviceInfoData->Reserved)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ if (Scope != DICS_FLAG_GLOBAL && Scope != DICS_FLAG_CONFIGSPECIFIC)
+ {
+ SetLastError(ERROR_INVALID_FLAGS);
+ return FALSE;
+ }
+ if (KeyType != DIREG_DEV && KeyType != DIREG_DRV)
+ {
+ SetLastError(ERROR_INVALID_FLAGS);
+ return FALSE;
+ }
+ devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
+ if (devInfo->set != set)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ if (devInfo->phantom)
+ {
+ SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
+ return FALSE;
+ }
+ if (Scope != DICS_FLAG_GLOBAL)
+ FIXME("unimplemented for scope %d\n", Scope);
+ switch (KeyType)
+ {
+ case DIREG_DEV:
+ ret = SETUPDI_DeleteDevKey(devInfo);
+ break;
+ case DIREG_DRV:
+ ret = SETUPDI_DeleteDrvKey(devInfo);
+ break;
+ case DIREG_BOTH:
+ ret = SETUPDI_DeleteDevKey(devInfo);
+ if (ret)
+ ret = SETUPDI_DeleteDrvKey(devInfo);
+ break;
+ default:
+ WARN("unknown KeyType %d\n", KeyType);
+ }
+ return ret;
+}
diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec
index f6ed8ed..8f5d78c 100644
--- a/dlls/setupapi/setupapi.spec
+++ b/dlls/setupapi/setupapi.spec
@@ -292,7 +292,7 @@
@ stdcall SetupDiCreateDeviceInterfaceW(ptr ptr ptr wstr long ptr)
@ stdcall SetupDiCreateDeviceInterfaceRegKeyA(ptr ptr long long ptr ptr)
@ stdcall SetupDiCreateDeviceInterfaceRegKeyW(ptr ptr long long ptr ptr)
-@ stub SetupDiDeleteDevRegKey
+@ stdcall SetupDiDeleteDevRegKey(ptr ptr long long long)
@ stub SetupDiDeleteDeviceInfo
@ stub SetupDiDeleteDeviceInterfaceData
@ stdcall SetupDiDeleteDeviceInterfaceRegKey(ptr ptr long)
diff --git a/include/setupapi.h b/include/setupapi.h
index 9379725..8e14f91 100644
--- a/include/setupapi.h
+++ b/include/setupapi.h
@@ -1469,7 +1469,7 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD
BOOL WINAPI SetupDiDeleteDeviceInfo(HDEVINFO, PSP_DEVINFO_DATA);
BOOL WINAPI SetupDiDeleteDeviceInterfaceData(HDEVINFO, PSP_DEVICE_INTERFACE_DATA);
BOOL WINAPI SetupDiDeleteDeviceInterfaceRegKey(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD);
-BOOL WINAPI SetupDiDeleteDevRegKey(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD, DWORD, DWORD);
+BOOL WINAPI SetupDiDeleteDevRegKey(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD);
BOOL WINAPI SetupDiDestroyClassImageList(PSP_CLASSIMAGELIST_DATA);
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO);
BOOL WINAPI SetupDiDestroyDriverInfoList(HDEVINFO, PSP_DEVINFO_DATA, DWORD);
More information about the wine-cvs
mailing list