Esempio n. 1
0
BOOL
CNetConnectionPropertyUi::GetINetCfgComponent(INetCfg *pNCfg, INetCfgComponent ** pOut)
{
    LPWSTR pName;
    HRESULT hr;
    INetCfgComponent * pNCg;
    ULONG Fetched;
    IEnumNetCfgComponent * pEnumCfg;

    hr = pNCfg->EnumComponents(&GUID_DEVCLASS_NET, &pEnumCfg);
    if (FAILED(hr))
    {
        return FALSE;
    }

    while (pEnumCfg->Next(1, &pNCg, &Fetched) == S_OK)
    {
        hr = pNCg->GetDisplayName(&pName);
        if (SUCCEEDED(hr))
        {
            if (!_wcsicmp(pName, pProperties->pszwDeviceName))
            {
                *pOut = pNCg;
                pEnumCfg->Release();
                return TRUE;
            }
            CoTaskMemFree(pName);
        }
        pNCg->Release();
    }
    pEnumCfg->Release();
    return FALSE;
}
Esempio n. 2
0
VOID
CNetConnectionPropertyUi::EnumComponents(HWND hDlgCtrl, INetCfg *pNCfg, const GUID *CompGuid, UINT Type)
{
    HRESULT hr;
    IEnumNetCfgComponent * pENetCfg;
    INetCfgComponent  *pNCfgComp, *pAdapterCfgComp;
    INetCfgComponentBindings * pCompBind;
    ULONG Num;
    DWORD dwCharacteristics;
    LPOLESTR pDisplayName, pHelpText;
    PNET_ITEM pItem;
    BOOL bChecked;

    hr = pNCfg->EnumComponents(CompGuid, &pENetCfg);
    if (FAILED(hr))
    {
        pNCfg->Release();
        return;
    }
    while(pENetCfg->Next(1, &pNCfgComp, &Num) == S_OK)
    {
        hr = pNCfgComp->GetCharacteristics(&dwCharacteristics);
        if (SUCCEEDED(hr) && (dwCharacteristics & NCF_HIDDEN))
        {
            pNCfgComp->Release();
            continue;
        }
        pDisplayName = NULL;
        pHelpText = NULL;
        hr = pNCfgComp->GetDisplayName(&pDisplayName);
        hr = pNCfgComp->GetHelpText(&pHelpText);
        bChecked = TRUE; //ReactOS hack
        hr = pNCfgComp->QueryInterface(IID_INetCfgComponentBindings, (LPVOID*)&pCompBind);
        if (SUCCEEDED(hr))
        {
            if (GetINetCfgComponent(pNCfg, &pAdapterCfgComp))
            {
                hr = pCompBind->IsBoundTo(pAdapterCfgComp);
                if (hr == S_OK)
                    bChecked = TRUE;
                else
                    bChecked = FALSE;
                pAdapterCfgComp->Release();
                pCompBind->Release();
            }
        }

        pItem = (NET_ITEM*)CoTaskMemAlloc(sizeof(NET_ITEM));
        if (!pItem)
            continue;

        pItem->dwCharacteristics = dwCharacteristics;
        pItem->szHelp = pHelpText;
        pItem->Type = (NET_TYPE)Type;
        pItem->pNCfgComp = pNCfgComp;
        pItem->NumPropDialogOpen = 0;

        AddItemToListView(hDlgCtrl, pItem, pDisplayName, bChecked);
        CoTaskMemFree(pDisplayName);
    }
    pENetCfg->Release();
}