Commit dadcb201 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

setupapi: Implement SetupDiDeleteDeviceInterfaceRegKey.

parent e69520ab
...@@ -2224,6 +2224,33 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyA( ...@@ -2224,6 +2224,33 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyA(
return key; return key;
} }
static PWSTR SETUPDI_GetInstancePath(struct InterfaceInfo *ifaceInfo)
{
static const WCHAR hash[] = {'#',0};
PWSTR instancePath = NULL;
if (ifaceInfo->referenceString)
{
instancePath = HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(ifaceInfo->referenceString) + 2) * sizeof(WCHAR));
if (instancePath)
{
lstrcpyW(instancePath, hash);
lstrcatW(instancePath, ifaceInfo->referenceString);
}
else
SetLastError(ERROR_OUTOFMEMORY);
}
else
{
instancePath = HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(hash) + 1) * sizeof(WCHAR));
if (instancePath)
lstrcpyW(instancePath, hash);
}
return instancePath;
}
/*********************************************************************** /***********************************************************************
* SetupDiCreateDeviceInterfaceRegKeyW (SETUPAPI.@) * SetupDiCreateDeviceInterfaceRegKeyW (SETUPAPI.@)
*/ */
...@@ -2271,28 +2298,10 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW( ...@@ -2271,28 +2298,10 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(
if (!(l = RegCreateKeyExW(interfacesKey, bracedGuidString, 0, NULL, 0, if (!(l = RegCreateKeyExW(interfacesKey, bracedGuidString, 0, NULL, 0,
samDesired, NULL, &parent, NULL))) samDesired, NULL, &parent, NULL)))
{ {
static const WCHAR hash[] = {'#',0};
struct InterfaceInfo *ifaceInfo = struct InterfaceInfo *ifaceInfo =
(struct InterfaceInfo *)DeviceInterfaceData->Reserved; (struct InterfaceInfo *)DeviceInterfaceData->Reserved;
LPCWSTR instancePath = NULL; PWSTR instancePath = SETUPDI_GetInstancePath(ifaceInfo);
LPWSTR referencePath = NULL;
if (ifaceInfo->referenceString)
{
referencePath = HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(ifaceInfo->referenceString) + 2) *
sizeof(WCHAR));
if (referencePath)
{
lstrcpyW(referencePath, hash);
lstrcatW(referencePath, ifaceInfo->referenceString);
instancePath = referencePath;
}
else
SetLastError(ERROR_OUTOFMEMORY);
}
else
instancePath = hash;
if (instancePath) if (instancePath)
{ {
LONG l; LONG l;
...@@ -2307,7 +2316,7 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW( ...@@ -2307,7 +2316,7 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(
else if (InfHandle) else if (InfHandle)
FIXME("INF section installation unsupported\n"); FIXME("INF section installation unsupported\n");
} }
HeapFree(GetProcessHeap(), 0, referencePath); HeapFree(GetProcessHeap(), 0, instancePath);
RegCloseKey(parent); RegCloseKey(parent);
} }
else else
...@@ -2320,6 +2329,56 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW( ...@@ -2320,6 +2329,56 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(
} }
/*********************************************************************** /***********************************************************************
* SetupDiDeleteDeviceInterfaceRegKey (SETUPAPI.@)
*/
BOOL WINAPI SetupDiDeleteDeviceInterfaceRegKey(
HDEVINFO DeviceInfoSet,
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
DWORD Reserved)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
HKEY parent;
BOOL ret = FALSE;
TRACE("%p %p %d\n", DeviceInfoSet, DeviceInterfaceData, Reserved);
if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!DeviceInterfaceData ||
DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
!DeviceInterfaceData->Reserved)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
parent = SetupDiOpenClassRegKeyExW(&DeviceInterfaceData->InterfaceClassGuid,
KEY_ALL_ACCESS, DIOCR_INTERFACE, NULL, NULL);
if (parent != INVALID_HANDLE_VALUE)
{
struct InterfaceInfo *ifaceInfo =
(struct InterfaceInfo *)DeviceInterfaceData->Reserved;
PWSTR instancePath = SETUPDI_GetInstancePath(ifaceInfo);
if (instancePath)
{
LONG l = RegDeleteKeyW(parent, instancePath);
if (l)
SetLastError(l);
else
ret = TRUE;
HeapFree(GetProcessHeap(), 0, instancePath);
}
RegCloseKey(parent);
}
return ret;
}
/***********************************************************************
* SetupDiEnumDeviceInterfaces (SETUPAPI.@) * SetupDiEnumDeviceInterfaces (SETUPAPI.@)
* *
* PARAMS * PARAMS
......
...@@ -295,6 +295,7 @@ ...@@ -295,6 +295,7 @@
@ stub SetupDiDeleteDevRegKey @ stub SetupDiDeleteDevRegKey
@ stub SetupDiDeleteDeviceInfo @ stub SetupDiDeleteDeviceInfo
@ stub SetupDiDeleteDeviceInterfaceData @ stub SetupDiDeleteDeviceInterfaceData
@ stdcall SetupDiDeleteDeviceInterfaceRegKey(ptr ptr long)
@ stub SetupDiDeleteDeviceRegKey @ stub SetupDiDeleteDeviceRegKey
@ stub SetupDiDestroyClassImageList @ stub SetupDiDestroyClassImageList
@ stdcall SetupDiDestroyDeviceInfoList(long) @ stdcall SetupDiDestroyDeviceInfoList(long)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment