INetCfgComponent::RaisePropertyUi problem

Hi,

has anyone ever succeeded in programmatically displaying the standard
Windows TCP/IP properties dialog box for a specific Ethernet adapter in
W2K/XP with INetCfgComponent::RaisePropertyUi?

Below is what I have so far, it starts out promising but
INetCfgComponent::RaisePropertyUi always fails with E_NOINTERFACE. I’m
sure I’m not passing the right thing for the third parameter, but the
DDK docs are very confusing here.

If that matters, I’m using the “build environment” from the SNetCfg
sample in the XP DDK and everything compiles with no errors.

I’m really pulling my hair out and would greatly appreciate even the
smallest hint.

Thanks!

//=====================================================================

HRESULT hr = S_OK;

// Initialize COM
hr = CoInitializeEx(
NULL,
COINIT_DISABLE_OLE1DDE | COINIT_APARTMENTTHREADED
);

if (FAILED(hr))
{
printf(“CoInitializeEx failed!\n”);
goto cleanup;
}

// Setup INetCfg
INetCfg *pnetcfg = NULL;
hr = CoCreateInstance(
CLSID_CNetCfg,
NULL,
CLSCTX_INPROC_SERVER,
IID_INetCfg,
(LPVOID*)&pnetcfg
);

if (FAILED(hr))
{
printf(“CoCreateInstance failed!\n”);
goto cleanup;
}

INetCfgLock *pncfglock = NULL;
hr = pnetcfg->QueryInterface(IID_INetCfgLock, (LPVOID*)&pncfglock);

if (FAILED(hr))
{
printf(“QueryInterface for INetCfgLock failed!\n”);
goto cleanup;
}

LPWSTR ppszwrClient = NULL;
hr = pncfglock->AcquireWriteLock(2000, L"Private", &ppszwrClient);

if (FAILED(hr))
{
printf(“AcquireWriteLock failed!\n”);
goto cleanup;
}

hr = pnetcfg->Initialize (NULL);

if (FAILED(hr))
{
printf(“Initialize failed!\n”);
goto cleanup;
}

INetCfgComponent *pCompTCPIP = NULL;
hr = pnetcfg->FindComponent ( L"MS_TCPIP", &pCompTCPIP );

if (FAILED(hr) || (pCompTCPIP == NULL) )
{
printf(“FindComponent MS_TCPIP failed!\n”);
goto cleanup;
}

// Get the LAN device component (works OK)
INetCfgComponent *pCompNIC = NULL;
// This is the hardware ID for my 3com 3c905B-TX NIC
hr = pnetcfg->FindComponent ( L"PCI\VEN_10B7&DEV_9055&SUBSYS_905510B7",&pCompNIC );

if (FAILED(hr) || (pCompNIC == NULL))
{
printf(“FindComponent NIC failed!\n”);
goto cleanup;
}

// Get display name (works OK)
LPWSTR ppszwDisplayName;
hr = pCompNIC->GetDisplayName(&ppszwDisplayName);

if (FAILED(hr))
{
printf(“GetDisplayName failed!\n”);
}
else
{
printf(“%ls\n”, ppszwDisplayName);
CoTaskMemFree(ppszwDisplayName);
}

// All goes well until here. What the **** do I need to pass for the third parameter?
hr = pCompTCPIP->RaisePropertyUi (GetDesktopWindow(), NCRP_SHOW_PROPERTY_UI, pCompNIC );

// hr is now E_NOINTERFACE
if (FAILED(hr))
{
printf(“RaisePropertyUi method 1 failed with status 0x%lX!\n”, hr);
}

// Maybe it’s the other way around?
hr = pCompNIC->RaisePropertyUi (GetDesktopWindow(), NCRP_SHOW_PROPERTY_UI, pCompTCPIP);

// hr is now E_NOINTERFACE
if (FAILED(hr))
{
printf(“RaisePropertyUi method 2 failed with status 0x%lX!\n”, hr);
}

// Or maybe 3rd parameter should be INetLanConnectionUiInfo?
INetLanConnectionUiInfo *pnlcui = NULL;
hr = pCompNIC->QueryInterface( IID_INetLanConnectionUiInfo, (void**) &pnlcui);

// hr is now E_NOINTERFACE
if (FAILED(hr))
{
printf(“INetLanConnectionUiInfo failed with status 0x%lX!\n”, hr);
}
else
{
hr = pCompTCPIP->RaisePropertyUi (GetDesktopWindow(), NCRP_SHOW_PROPERTY_UI, pnlcui);

if (FAILED(hr))
{
printf(“RaisePropertyUi method 3 failed with status 0x%lX!\n”, hr);
}
}

cleanup:

// To Do: release interfaces, release write lock,
// uninitialize INetCfg

//=====================================================================

Ralf.