Changeset 18676 in vbox for trunk/src/VBox
- Timestamp:
- Apr 3, 2009 10:13:21 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/win/NetIfList-win.cpp
r18543 r18676 1436 1436 #define SetErrBreak(strAndArgs) \ 1437 1437 if (1) { \ 1438 aErrMsg = Utf8StrFmt strAndArgs; vrc = VERR_GENERAL_FAILURE; break; \ 1438 aErrMsg = Utf8StrFmt strAndArgs; vrc = VERR_GENERAL_FAILURE; \ 1439 Assert(0);\ 1440 break; \ 1439 1441 } else do {} while (0) 1440 1442 … … 1458 1460 BOOL registered = FALSE; 1459 1461 BOOL destroyList = FALSE; 1460 TCHAR pCfgGuidString [50]; 1462 WCHAR pWCfgGuidString [50]; 1463 WCHAR DevName[256]; 1461 1464 1462 1465 do … … 1672 1675 GetLastError())); 1673 1676 1674 cbSize = sizeof (p CfgGuidString);1677 cbSize = sizeof (pWCfgGuidString); 1675 1678 DWORD ret; 1676 ret = RegQueryValueEx (hkey, _T("NetCfgInstanceId"), NULL, 1677 &dwValueType, (LPBYTE) pCfgGuidString, &cbSize); 1679 ret = RegQueryValueExW (hkey, L"NetCfgInstanceId", NULL, 1680 &dwValueType, (LPBYTE) pWCfgGuidString, &cbSize); 1681 1678 1682 RegCloseKey (hkey); 1683 1684 if(!SetupDiGetDeviceRegistryPropertyW(hDeviceInfo, &DeviceInfoData, 1685 SPDRP_FRIENDLYNAME , /* IN DWORD Property,*/ 1686 NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/ 1687 (PBYTE)DevName, /*OUT PBYTE PropertyBuffer,*/ 1688 sizeof(DevName), /* IN DWORD PropertyBufferSize,*/ 1689 NULL /*OUT PDWORD RequiredSize OPTIONAL*/ 1690 )) 1691 { 1692 int err = GetLastError(); 1693 if(err != ERROR_INVALID_DATA) 1694 { 1695 SetErrBreak (("SetupDiGetDeviceRegistryProperty failed (0x%08X)", 1696 err)); 1697 } 1698 1699 if(!SetupDiGetDeviceRegistryPropertyW(hDeviceInfo, &DeviceInfoData, 1700 SPDRP_DEVICEDESC , /* IN DWORD Property,*/ 1701 NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/ 1702 (PBYTE)DevName, /*OUT PBYTE PropertyBuffer,*/ 1703 sizeof(DevName), /* IN DWORD PropertyBufferSize,*/ 1704 NULL /*OUT PDWORD RequiredSize OPTIONAL*/ 1705 )) 1706 { 1707 err = GetLastError(); 1708 SetErrBreak (("SetupDiGetDeviceRegistryProperty failed (0x%08X)", 1709 err)); 1710 } 1711 } 1679 1712 } 1680 1713 while (0); … … 1703 1736 if (RT_SUCCESS (vrc)) 1704 1737 { 1738 Bstr str(DevName); 1739 str.detachTo(pName); 1740 1741 WCHAR ConnectoinName[128]; 1742 ULONG cbName = sizeof(ConnectoinName); 1743 1744 HRESULT hr = VBoxNetCfgWinGenHostonlyConnectionName (DevName, ConnectoinName, &cbName); 1745 if(hr == S_OK) 1746 { 1747 hr = VBoxNetCfgWinRenameConnection (pWCfgGuidString, ConnectoinName); 1748 } 1749 1705 1750 /* remove the curly bracket at the end */ 1706 p CfgGuidString [_tcslen (pCfgGuidString) - 1] ='\0';1707 LogFlowFunc (("Network connection GUID string = {%ls}\n", p CfgGuidString + 1));1708 1709 aGUID = Guid (Utf8Str (p CfgGuidString + 1));1751 pWCfgGuidString [wcslen (pWCfgGuidString) - 1] = L'\0'; 1752 LogFlowFunc (("Network connection GUID string = {%ls}\n", pWCfgGuidString + 1)); 1753 1754 aGUID = Guid (Utf8Str (pWCfgGuidString + 1)); 1710 1755 LogFlowFunc (("Network connection GUID = {%RTuuid}\n", aGUID.raw())); 1711 1756 Assert (!aGUID.isEmpty()); 1712 1713 INetCfg *pNc;1714 INetCfgComponent *pMpNcc;1715 LPWSTR lpszApp;1716 WCHAR ConnectoinName[128];1717 1718 HRESULT hr = VBoxNetCfgWinQueryINetCfg( FALSE,1719 VBOX_APP_NAME,1720 &pNc,1721 &lpszApp );1722 if(hr == S_OK)1723 {1724 hr = VBoxNetCfgWinGetComponentByGuid(pNc,1725 &GUID_DEVCLASS_NET,1726 aGUID.asOutParam(),1727 &pMpNcc);1728 if(hr == S_OK)1729 {1730 LPWSTR name;1731 hr = pMpNcc->GetDisplayName(&name);1732 if(hr == S_OK)1733 {1734 Bstr str(name);1735 str.detachTo(pName);1736 ULONG cbBuf = sizeof(ConnectoinName);1737 1738 hr = VBoxNetCfgWinGenHostonlyConnectionName (name, ConnectoinName, &cbBuf);1739 1740 CoTaskMemFree (name);1741 }1742 1743 VBoxNetCfgWinReleaseRef(pMpNcc);1744 }1745 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE);1746 }1747 1748 if(hr == S_OK)1749 {1750 hr = VBoxNetCfgWinRenameConnection ((GUID*)aGUID.raw(), ConnectoinName);1751 }1752 1753 if(hr != S_OK)1754 {1755 vrc = VERR_GENERAL_FAILURE;1756 }1757 1758 1757 } 1759 1758
Note:
See TracChangeset
for help on using the changeset viewer.