赞
踩
MFC工程下使用方式:
- #include <NetCon.h>
- void OnNetTest()
- {
- INetConnectionManager *pNetManager;
- INetConnection *pNetConnection;
- IEnumNetConnection *pEnum;
- do
- {
- CoInitialize(NULL);
- if (S_OK != CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, IID_INetConnectionManager, (void**)&pNetManager))
- {
- break;
- }
-
- pNetManager->EnumConnections(NCME_DEFAULT, &pEnum);
- pNetManager->Release();
- if (NULL == pEnum)
- {
- break;
- }
-
- ULONG celtFetched;
- while (pEnum->Next(1, &pNetConnection, &celtFetched) == S_OK)
- {
- NETCON_PROPERTIES* properties;
- pNetConnection->GetProperties(&properties);
- CString name = properties->pszwName; //网络连接的名称
-
- pNetConnection->Disconnect(); //禁目连接
- pNetConnection->Connect(); //启用连接
- }
- } while (false);
-
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。