LPCWSTR BusType)
{
LPWSTR InstanceId = NULL;
+ LPWSTR ComponentId = NULL;
LPWSTR DeviceName = NULL;
LPWSTR ExportName = NULL;
LONG rc;
HKEY hConnectionKey = NULL;
DWORD dwShowIcon, dwLength, dwValue;
WCHAR szBuffer[300];
+ PWSTR ptr;
+
+ /* Install the adapter */
+ if (!SetupDiInstallDevice(DeviceInfoSet, DeviceInfoData))
+ {
+ rc = GetLastError();
+ ERR("SetupDiInstallDevice() failed (Error %lu)\n", rc);
+ goto cleanup;
+ }
/* Get Instance ID */
if (SetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData, NULL, 0, &dwLength))
goto cleanup;
}
+ ComponentId = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
+ if (!ComponentId)
+ {
+ ERR("HeapAlloc() failed\n");
+ rc = ERROR_NOT_ENOUGH_MEMORY;
+ goto cleanup;
+ }
+
+ wcscpy(ComponentId, InstanceId);
+ ptr = wcsrchr(ComponentId, L'\\');
+ if (ptr != NULL)
+ *ptr = UNICODE_NULL;
+
/* Create device name */
DeviceName = HeapAlloc(GetProcessHeap(), 0, (wcslen(L"\\Device\\") + wcslen(UuidString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
if (!DeviceName)
goto cleanup;
}
+ rc = RegSetValueExW(hKey, L"ComponentId", 0, REG_SZ, (const BYTE*)ComponentId, (wcslen(ComponentId) + 1) * sizeof(WCHAR));
+ if (rc != ERROR_SUCCESS)
+ {
+ ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
+ goto cleanup;
+ }
+
if (BusType)
{
rc = RegSetValueExW(hKey, L"BusType", 0, REG_SZ, (const BYTE*)BusType, (wcslen(BusType) + 1) * sizeof(WCHAR));
goto cleanup;
}
- rc = RegSetValueExW(hConnectionKey, L"PnpInstanceId", 0, REG_SZ, (const BYTE*)InstanceId, (wcslen(InstanceId) + 1) * sizeof(WCHAR));
+ rc = RegSetValueExW(hConnectionKey, L"PnpInstanceID", 0, REG_SZ, (const BYTE*)InstanceId, (wcslen(InstanceId) + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
cleanup:
HeapFree(GetProcessHeap(), 0, InstanceId);
+ HeapFree(GetProcessHeap(), 0, ComponentId);
HeapFree(GetProcessHeap(), 0, DeviceName);
HeapFree(GetProcessHeap(), 0, ExportName);
if (hKey != NULL)
RegCloseKey(hLinkageKey);
if (hConnectionKey != NULL)
RegCloseKey(hConnectionKey);
+
return rc;
}
HeapFree(GetProcessHeap(), 0, BusType);
HeapFree(GetProcessHeap(), 0, UuidString);
- if (rc == ERROR_SUCCESS)
- rc = ERROR_DI_DO_DEFAULT;
TRACE("Returning 0x%lx\n", rc);
return rc;
}