VirtualBox

Changeset 17773 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Mar 12, 2009 6:19:03 PM (16 years ago)
Author:
vboxsync
Message:

NetAdp/win: make the network connection be named properly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/win/NetIfList-win.cpp

    r17713 r17773  
    12651265}
    12661266
    1267 extern "C" HRESULT RenameConnection (PCWSTR GuidString, PCWSTR NewName)
     1267static HRESULT netIfRenameConnection (PCWSTR GuidString, PCWSTR NewName)
    12681268{
    12691269    typedef HRESULT (WINAPI *lpHrRenameConnection) (const GUID *, PCWSTR);
     
    13041304    return S_OK;
    13051305}
     1306#define VBOX_CONNECTION_NAME L"Virtualbox Host-Only Network"
     1307static HRESULT netIfGenConnectionName (PCWSTR DevName, WCHAR *pBuf, PULONG pcbBuf)
     1308{
     1309    WCHAR * pSuffix = wcsrchr( DevName, L'#' );
     1310    ULONG cbSize = sizeof(VBOX_CONNECTION_NAME);
     1311    ULONG cbSufSize = 0;
     1312
     1313    if(pSuffix)
     1314    {
     1315        cbSize += wcslen(pSuffix) * 2;
     1316    }
     1317
     1318    if(*pcbBuf < cbSize)
     1319    {
     1320        *pcbBuf = cbSize;
     1321        return E_FAIL;
     1322    }
     1323
     1324    wcscpy(pBuf, VBOX_CONNECTION_NAME);
     1325    if(pSuffix)
     1326    {
     1327        wcscat(pBuf, pSuffix);
     1328    }
     1329
     1330    return S_OK;
     1331}
    13061332
    13071333#define DRIVERHWID _T("sun_VBoxNetAdp")
     
    16061632                    Bstr str(name);
    16071633                    str.detachTo(pName);
     1634                    WCHAR ConnectoinName[128];
     1635                    ULONG cbBuf = sizeof(ConnectoinName);
     1636
     1637                    /* return back the bracket */
     1638                    pCfgGuidString [_tcslen (pCfgGuidString)] = '}';
     1639
     1640                    hr = netIfGenConnectionName (name, ConnectoinName, &cbBuf);
     1641                    if(hr == S_OK)
     1642                    {
     1643                        hr = netIfRenameConnection (pCfgGuidString, ConnectoinName);
     1644                    }
    16081645
    16091646                    CoTaskMemFree (name);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette