HRESULT HrFindInstance (INetCfg *pnc, GUID &guidInstance, INetCfgComponent **ppnccMiniport) { IEnumNetCfgComponent *pencc; INetCfgComponent *pncc; GUID guid; WCHAR szGuid[MAX_PATH+1]; ULONG ulCount; BOOL found; HRESULT hr; TraceMsg( L"-->HrFindInstance.\n" ); hr = pnc->EnumComponents( &GUID_DEVCLASS_NET, &pencc ); if ( hr == S_OK ) { StringFromGUID2( guidInstance, szGuid, MAX_PATH+1 ); TraceMsg( L" Looking for component with InstanceGuid %s\n", szGuid ); hr = pencc->Next( 1, &pncc, &ulCount ); for ( found=FALSE; (hr == S_OK) && (found == FALSE); ) { hr = pncc->GetInstanceGuid( &guid ); if ( hr == S_OK ) { StringFromGUID2( guid, szGuid, MAX_PATH+1 ); TraceMsg( L" Found component with InstanceGuid %s\n", szGuid ); found = IsEqualGUID( guid, guidInstance ); if ( found == FALSE ) { ReleaseObj( pncc ); hr = pencc->Next( 1, &pncc, &ulCount ); } else { *ppnccMiniport = pncc; } } } ReleaseObj( pencc ); } else { TraceMsg( L" EnumComponents failed(HRESULT = %x).\n", hr ); } TraceMsg( L"<--HrFindInstance(HRESULT = %x).\n", hr ); return hr; }
HRESULT CMuxVirtualMiniport::Install (VOID) { INetCfgClass *pncClass; INetCfgClassSetup *pncClassSetup; INetCfgComponent *pnccMiniport; HRESULT hr; LPWSTR *pmszwRefs=NULL; OBO_TOKEN *pOboToken=NULL; DWORD dwSetupFlags=0; LPCWSTR pszwAnswerFile=NULL; LPCWSTR pszwAnswerSections=NULL; TraceMsg( L"-->CMuxVirtualMiniport::Install.\n" ); hr = m_pnc->QueryNetCfgClass( &GUID_DEVCLASS_NET, IID_INetCfgClass, (void **)&pncClass ); if ( hr == S_OK ) { hr = pncClass->QueryInterface( IID_INetCfgClassSetup, (void **)&pncClassSetup ); if ( hr == S_OK ) { hr = pncClassSetup->Install( c_szMuxMiniport, pOboToken, dwSetupFlags, 0, pszwAnswerFile, pszwAnswerSections, &pnccMiniport ); if ( hr == S_OK ) { hr = pnccMiniport->GetInstanceGuid( &m_guidMiniport ); if ( hr != S_OK ) { TraceMsg( L" Failed to get the instance guid, uninstalling " L" the miniport.\n" ); pncClassSetup->DeInstall( pnccMiniport, pOboToken, pmszwRefs ); } ReleaseObj( pnccMiniport ); } else { TraceMsg( L" Failed to install the miniport.\n" ); } ReleaseObj( pncClassSetup ); } else { TraceMsg( L" QueryInterface failed.\n" ); } ReleaseObj( pncClass ); } else { TraceMsg( L" QueryNetCfgClass failed.\n" ); } TraceMsg( L"<--CMuxVirtualMiniport::Install(HRESULT = %x).\n", hr ); return hr; }