Write connection name at the right place in registry.
Add PnpInstanceId and ShowIcon values
Modified: trunk/reactos/lib/netcfgx/netcfgx.c
_____
Modified: trunk/reactos/lib/netcfgx/netcfgx.c
--- trunk/reactos/lib/netcfgx/netcfgx.c 2005-11-27 20:59:09 UTC (rev
19698)
+++ trunk/reactos/lib/netcfgx/netcfgx.c 2005-11-27 21:00:09 UTC (rev
19699)
@@ -100,11 +100,13 @@
{
RPC_STATUS RpcStatus;
UUID Uuid;
+ LPWSTR InstanceId = NULL;
LPWSTR UuidRpcString = NULL;
LPWSTR UuidString = NULL;
LPWSTR DeviceName = NULL;
LPWSTR ExportName = NULL;
LONG rc;
+ DWORD dwShowIcon, dwLength;
HKEY hKey = INVALID_HANDLE_VALUE;
HKEY hLinkageKey = INVALID_HANDLE_VALUE;
HKEY hNetworkKey = INVALID_HANDLE_VALUE;
@@ -115,6 +117,27 @@
DPRINT("%lu %p %p\n", InstallFunction, DeviceInfoSet,
DeviceInfoData);
+ /* Get Instance ID */
+ if (SetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData,
NULL, 0, &dwLength))
+ {
+ DPRINT("SetupDiGetDeviceInstanceIdW() returned TRUE.
FALSE expected\n");
+ rc = ERROR_GEN_FAILURE;
+ goto cleanup;
+ }
+ InstanceId = HeapAlloc(GetProcessHeap(), 0, dwLength);
+ if (!InstanceId)
+ {
+ DPRINT("HeapAlloc() failed\n");
+ rc = ERROR_NOT_ENOUGH_MEMORY;
+ goto cleanup;
+ }
+ if (!SetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData,
InstanceId, dwLength, NULL))
+ {
+ rc = GetLastError();
+ DPRINT("SetupDiGetDeviceInstanceIdW() failed with error
0x%lx\n", rc);
+ goto cleanup;
+ }
+
/* Create a new UUID */
RpcStatus = UuidCreate(&Uuid);
if (RpcStatus != RPC_S_OK && RpcStatus != RPC_S_UUID_LOCAL_ONLY)
@@ -263,20 +286,39 @@
DPRINT("RegCreateKeyExW() failed with error 0x%lx\n",
rc);
goto cleanup;
}
- rc = RegCreateKeyExW(hNetworkKey, UuidString, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL);
+ rc = RegCreateKeyExW(hNetworkKey, UuidString, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL);
if (rc != ERROR_SUCCESS)
{
DPRINT("RegCreateKeyExW() failed with error 0x%lx\n",
rc);
goto cleanup;
}
- rc = RegSetValueExW(hKey, L"Name", 0, REG_SZ, (const
BYTE*)L"Network connection", (wcslen(L"Network connection") + 1) *
sizeof(WCHAR));
+ rc = RegCreateKeyExW(hKey, L"Connection", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hConnectionKey, NULL);
+ RegCloseKey(hKey);
+ hKey = INVALID_HANDLE_VALUE;
if (rc != ERROR_SUCCESS)
{
+ DPRINT("RegCreateKeyExW() failed with error 0x%lx\n",
rc);
+ goto cleanup;
+ }
+ rc = RegSetValueExW(hConnectionKey, L"Name", 0, REG_SZ, (const
BYTE*)L"Network connection", (wcslen(L"Network connection") + 1) *
sizeof(WCHAR));
+ if (rc != ERROR_SUCCESS)
+ {
DPRINT("RegSetValueExW() failed with error 0x%lx\n",
rc);
goto cleanup;
}
- RegCloseKey(hKey);
- hKey = INVALID_HANDLE_VALUE;
+ rc = RegSetValueExW(hConnectionKey, L"PnpInstanceId", 0, REG_SZ,
(const BYTE*)InstanceId, (wcslen(InstanceId) + 1) * sizeof(WCHAR));
+ if (rc != ERROR_SUCCESS)
+ {
+ DPRINT("RegSetValueExW() failed with error 0x%lx\n",
rc);
+ goto cleanup;
+ }
+ dwShowIcon = 1;
+ rc = RegSetValueExW(hConnectionKey, L"ShowIcon", 0, REG_DWORD,
(const BYTE*)&dwShowIcon, sizeof(dwShowIcon));
+ if (rc != ERROR_SUCCESS)
+ {
+ DPRINT("RegSetValueExW() failed with error 0x%lx\n",
rc);
+ goto cleanup;
+ }
/* Write linkage information in Tcpip service */
rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE | KEY_SET_VALUE, NULL, &hKey,
NULL);
@@ -309,6 +351,7 @@
cleanup:
if (UuidRpcString != NULL)
RpcStringFreeW(&UuidRpcString);
+ HeapFree(GetProcessHeap(), 0, InstanceId);
HeapFree(GetProcessHeap(), 0, UuidString);
HeapFree(GetProcessHeap(), 0, DeviceName);
HeapFree(GetProcessHeap(), 0, ExportName);