\r
CNDProvider::CNDProvider()\r
{\r
- WvGetObject(IID_IWVProvider, (LPVOID *) &m_pWvProvider);\r
+ m_pWvProvider = NULL;\r
+}\r
+\r
+STDMETHODIMP CNDProvider::\r
+Init()\r
+{\r
+ HRESULT hr;\r
+\r
+ hr = WvGetObject(IID_IWVProvider, (LPVOID *) &m_pWvProvider);\r
+ if (FAILED(hr)) {\r
+ return hr;\r
+ }\r
+\r
+ if (!SetFileCompletionNotificationModes(m_pWvProvider->GetFileHandle(),\r
+ FILE_SKIP_COMPLETION_PORT_ON_SUCCESS |\r
+ FILE_SKIP_SET_EVENT_ON_HANDLE)) {\r
+ return HRESULT_FROM_WIN32(GetLastError());\r
+ }\r
+\r
+ return ND_SUCCESS;\r
}\r
\r
CNDProvider::~CNDProvider()\r
\r
CNDProvider();\r
~CNDProvider();\r
+\r
void Delete() {delete this;}\r
+ static STDMETHODIMP\r
+ CreateInstance(CNDProvider **ppProvider)\r
+ {\r
+ HRESULT hr;\r
+ CNDProvider *provider;\r
+\r
+ provider = new CNDProvider(provider);\r
+ if (provider == NULL) {\r
+ hr = ND_NO_MEMORY;\r
+ goto err1;\r
+ }\r
+\r
+ hr = provider->Init();\r
+ if (FAILED(hr)) {\r
+ goto err2;\r
+ }\r
+\r
+ *ppProvider = provider;\r
+ return ND_SUCCESS;\r
+\r
+ err2:\r
+ provider->Release();\r
+ err1:\r
+ *ppProvider = NULL;\r
+ return hr;\r
+ }\r
\r
STDMETHODIMP QueryAdapterAddressList(SOCKET_ADDRESS_LIST* pAddressList,\r
SIZE_T* pcbAddressList, UINT64 adapterId);\r
IWVProvider *m_pWvProvider;\r
+\r
+private:\r
+ STDMETHODIMP Init();\r
};\r
\r
\r