我应该从我的程序中显示“本地连接”属性对话框(它是具有两个选项卡网络和共享的对话框)。
我该怎么做?
现在我使用这个功能:
void ShowPropertiesDialog(INetConnection * pConn)
{
HRESULT hr = S_OK;
CLSID clsid;
CComPtr<INetCfg> pNetCfg;
if (SUCCEEDED(pConn->GetUiObjectClassId(&clsid)))
{
CComPtr<IUnknown> pUnk;
if(SUCCEEDED(pUnk.CoCreateInstance(clsid)))
{
CComPtr<INetConnectionPropertyUi> pNetConnectionPropertyUi;
hr = pUnk->QueryInterface(IID_INetConnectionPropertyUi, (void**)&pNetConnectionPropertyUi);
hr = pNetConnectionPropertyUi->SetConnection(pConn);
hr = pNetCfg.CoCreateInstance(CLSID_CNetCfg);
if (SUCCEEDED(hr))
{
CComPtr<INetCfgLock> pNetCfgLock;
hr = pNetCfg->QueryInterface(IID_INetCfgLock, (void**)&pNetCfgLock);
if (SUCCEEDED(hr))
{
hr = pNetCfgLock->AcquireWriteLock(15000, TEXT("MY CLIENT"), NULL);
if (SUCCEEDED(hr))
{
hr = pNetCfg->Initialize(NULL);
if (SUCCEEDED(hr))
{
CComPtr<INetCfgComponent> pTcpIp;
if (SUCCEEDED(pNetCfg->FindComponent(NETCFG_TRANS_CID_MS_TCPIP, &pTcpIp)))
{
hr = pTcpIp->RaisePropertyUi(GetConsoleWindow(), NCRP_SHOW_PROPERTY_UI, pNetConnectionPropertyUi);
}
pNetCfg->Uninitialize();
}
pNetCfgLock->ReleaseWriteLock();
}
}
pNetCfg.Release();
}
}
}
}
利用:
hr = pENConnection->Next(1, &pConn, &ulCount);
....
hr = pConn->GetProperties(&pProps);
if (pProps->MediaType == NCM_LAN)
{
ShowPropertiesDialog(pConn);
}
但RaisePropertyUi
总是返回E_NOINTERFACE
:(
谢谢。