sergei
2005-03-31 07:25:57 UTC
Hi everybody.
I'm trying to show the TCP/IP properties dialog from the user mode
application. I'm using network configuration interfaces and
INetCfgComponent::RaisePropertyUi pops up a message box: "In order to
configure TCP/IP, you must install and enable a network adapter card."
Here is the code:
void InvokeTCPIPProperties(HWND hWndParent)
{
CComPtr<INetCfg> NetCfg;
CComQIPtr<INetCfgLock> NetCfgLock;
CComPtr<INetCfgComponent> NetCfgComponent;
HRESULT hr = S_OK;
LPWSTR ppszwrClient = NULL;
hr = CoCreateInstance(CLSID_CNetCfg, NULL, CLSCTX_SERVER,
IID_INetCfg, (LPVOID*)&NetCfg);
NetCfgLock = NetCfg;
hr = NetCfgLock->AcquireWriteLock(5, _T("MY CLIENT"),
&ppszwrClient);
hr = NetCfg->Initialize(NULL);
hr = NetCfg->FindComponent(NETCFG_TRANS_CID_MS_TCPIP,
&NetCfgComponent);
CLSID notifyObjectClsid = GUID_NULL;
CLSIDFromString(L"{A907657F-6FDF-11D0-8EFB-00C04FD912B2}",
¬ifyObjectClsid); //Microsoft TCP/IP Configuration Notify Object
CComPtr<INetCfgComponentControl> spControl;
hr = CoCreateInstance(notifyObjectClsid, NULL, CLSCTX_SERVER,
IID_INetCfgComponentControl, (LPVOID*)&spControl);
hr = spControl->Initialize(NetCfgComponent, NetCfg, FALSE);
hr = NetCfgComponent->RaisePropertyUi(hWndParent,
NCRP_SHOW_PROPERTY_UI, spControl);
hr = NetCfg->Apply();
hr = NetCfg->Uninitialize();
hr = NetCfgLock->ReleaseWriteLock();
}
All functions return S_OK except RaisePropertyUi that returns
0x80070491 (There was no match for the specified key in the index).
What I'm doing wrong?
Another question is how to get the CLSID of the notify object. I'm
using a guid found it in the registry that definitely is not a
legal/right way. (Maybe the problem is here?)
Any help greatly appreciated.
Sergey
I'm trying to show the TCP/IP properties dialog from the user mode
application. I'm using network configuration interfaces and
INetCfgComponent::RaisePropertyUi pops up a message box: "In order to
configure TCP/IP, you must install and enable a network adapter card."
Here is the code:
void InvokeTCPIPProperties(HWND hWndParent)
{
CComPtr<INetCfg> NetCfg;
CComQIPtr<INetCfgLock> NetCfgLock;
CComPtr<INetCfgComponent> NetCfgComponent;
HRESULT hr = S_OK;
LPWSTR ppszwrClient = NULL;
hr = CoCreateInstance(CLSID_CNetCfg, NULL, CLSCTX_SERVER,
IID_INetCfg, (LPVOID*)&NetCfg);
NetCfgLock = NetCfg;
hr = NetCfgLock->AcquireWriteLock(5, _T("MY CLIENT"),
&ppszwrClient);
hr = NetCfg->Initialize(NULL);
hr = NetCfg->FindComponent(NETCFG_TRANS_CID_MS_TCPIP,
&NetCfgComponent);
CLSID notifyObjectClsid = GUID_NULL;
CLSIDFromString(L"{A907657F-6FDF-11D0-8EFB-00C04FD912B2}",
¬ifyObjectClsid); //Microsoft TCP/IP Configuration Notify Object
CComPtr<INetCfgComponentControl> spControl;
hr = CoCreateInstance(notifyObjectClsid, NULL, CLSCTX_SERVER,
IID_INetCfgComponentControl, (LPVOID*)&spControl);
hr = spControl->Initialize(NetCfgComponent, NetCfg, FALSE);
hr = NetCfgComponent->RaisePropertyUi(hWndParent,
NCRP_SHOW_PROPERTY_UI, spControl);
hr = NetCfg->Apply();
hr = NetCfg->Uninitialize();
hr = NetCfgLock->ReleaseWriteLock();
}
All functions return S_OK except RaisePropertyUi that returns
0x80070491 (There was no match for the specified key in the index).
What I'm doing wrong?
Another question is how to get the CLSID of the notify object. I'm
using a guid found it in the registry that definitely is not a
legal/right way. (Maybe the problem is here?)
Any help greatly appreciated.
Sergey