5 const INetCfg
* lpVtbl
;
6 const INetCfgLock
* lpVtblLock
;
7 const INetCfgPnpReconfigCallback
*lpVtblPnpReconfigCallback
;
11 NetCfgComponentItem
*pNet
;
12 NetCfgComponentItem
* pService
;
13 NetCfgComponentItem
* pClient
;
14 NetCfgComponentItem
* pProtocol
;
15 } INetCfgImpl
, *LPINetCfgImpl
;
17 static __inline LPINetCfgImpl
impl_from_INetCfgLock(INetCfgLock
*iface
)
19 return (INetCfgImpl
*)((char *)iface
- FIELD_OFFSET(INetCfgImpl
, lpVtblLock
));
22 static __inline LPINetCfgImpl
impl_from_INetCfgPnpReconfigCallback(INetCfgPnpReconfigCallback
*iface
)
24 return (INetCfgImpl
*)((char *)iface
- FIELD_OFFSET(INetCfgImpl
, lpVtblPnpReconfigCallback
));
30 INetCfgLock_fnQueryInterface(
35 INetCfgImpl
* This
= impl_from_INetCfgLock(iface
);
36 return INetCfg_QueryInterface((INetCfg
*)This
, iid
, ppvObj
);
45 INetCfgImpl
* This
= impl_from_INetCfgLock(iface
);
47 return INetCfg_AddRef((INetCfg
*)This
);
52 INetCfgLock_fnRelease(
55 INetCfgImpl
* This
= impl_from_INetCfgLock(iface
);
56 return INetCfg_Release((INetCfg
*)This
);
61 INetCfgLock_fnAcquireWriteLock(
64 LPCWSTR pszwClientDescription
,
65 LPWSTR
*ppszwClientDescription
)
70 INetCfgImpl
* This
= impl_from_INetCfgLock(iface
);
72 if (This
->bInitialized
)
73 return NETCFG_E_ALREADY_INITIALIZED
;
75 dwResult
= WaitForSingleObject(This
->hMutex
, cmsTimeout
);
76 if (dwResult
== WAIT_TIMEOUT
)
78 if (ppszwClientDescription
)
80 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Control\\Network\\NetCfgLockHolder", 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
82 dwResult
= sizeof(szValue
);
83 if (RegQueryValueExW(hKey
, NULL
, NULL
, NULL
, (LPBYTE
)szValue
, &dwResult
) == ERROR_SUCCESS
)
85 szValue
[(sizeof(szValue
)/sizeof(WCHAR
))-1] = L
'\0';
86 *ppszwClientDescription
= CoTaskMemAlloc((wcslen(szValue
)+1) * sizeof(WCHAR
));
87 if (*ppszwClientDescription
)
88 wcscpy(*ppszwClientDescription
, szValue
);
95 else if (dwResult
== WAIT_OBJECT_0
)
97 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Control\\Network\\NetCfgLockHolder", 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
) == ERROR_SUCCESS
)
99 RegSetValueExW(hKey
, NULL
, 0, REG_SZ
, (LPBYTE
)pszwClientDescription
, (wcslen(pszwClientDescription
)+1) * sizeof(WCHAR
));
110 INetCfgLock_fnReleaseWriteLock(
113 INetCfgImpl
* This
= impl_from_INetCfgLock(iface
);
115 if (This
->bInitialized
)
116 return NETCFG_E_ALREADY_INITIALIZED
;
119 if (ReleaseMutex(This
->hMutex
))
127 INetCfgLock_fnIsWriteLocked(
129 LPWSTR
*ppszwClientDescription
)
133 DWORD dwSize
, dwType
;
136 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Control\\Network\\NetCfgLockHolder", 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
139 dwSize
= sizeof(szValue
);
140 if (RegQueryValueExW(hKey
, NULL
, NULL
, &dwType
, (LPBYTE
)szValue
, &dwSize
) == ERROR_SUCCESS
&& dwType
== REG_SZ
)
143 szValue
[(sizeof(szValue
)/sizeof(WCHAR
))-1] = L
'\0';
144 *ppszwClientDescription
= CoTaskMemAlloc((wcslen(szValue
)+1) * sizeof(WCHAR
));
145 if (*ppszwClientDescription
)
146 wcscpy(*ppszwClientDescription
, szValue
);
158 static const INetCfgLockVtbl vt_NetCfgLock
=
160 INetCfgLock_fnQueryInterface
,
161 INetCfgLock_fnAddRef
,
162 INetCfgLock_fnRelease
,
163 INetCfgLock_fnAcquireWriteLock
,
164 INetCfgLock_fnReleaseWriteLock
,
165 INetCfgLock_fnIsWriteLocked
168 /***************************************************************
169 * INetCfgPnpReconfigCallback
174 INetCfgPnpReconfigCallback_fnQueryInterface(
175 INetCfgPnpReconfigCallback
* iface
,
179 INetCfgImpl
* This
= impl_from_INetCfgPnpReconfigCallback(iface
);
180 return INetCfg_QueryInterface((INetCfg
*)This
, iid
, ppvObj
);
185 INetCfgPnpReconfigCallback_fnAddRef(
186 INetCfgPnpReconfigCallback
* iface
)
188 INetCfgImpl
* This
= impl_from_INetCfgPnpReconfigCallback(iface
);
190 return INetCfg_AddRef((INetCfg
*)This
);
195 INetCfgPnpReconfigCallback_fnRelease(
196 INetCfgPnpReconfigCallback
* iface
)
198 INetCfgImpl
* This
= impl_from_INetCfgPnpReconfigCallback(iface
);
199 return INetCfg_Release((INetCfg
*)This
);
204 INetCfgPnpReconfigCallback_fnSendPnpReconfig(
205 INetCfgPnpReconfigCallback
* iface
,
206 NCPNP_RECONFIG_LAYER Layer
,
216 static const INetCfgPnpReconfigCallbackVtbl vt_NetCfgPnpReconfigCallback
=
218 INetCfgPnpReconfigCallback_fnQueryInterface
,
219 INetCfgPnpReconfigCallback_fnAddRef
,
220 INetCfgPnpReconfigCallback_fnRelease
,
221 INetCfgPnpReconfigCallback_fnSendPnpReconfig
225 /***************************************************************
231 NetCfgComponentItem
*Item
)
235 DWORD dwType
, dwSize
;
237 if (Item
== NULL
|| Item
->szBindName
== NULL
)
240 wcscpy(szBuffer
, L
"SYSTEM\\CurrentControlSet\\Services\\");
241 wcscat(szBuffer
, Item
->szBindName
);
242 wcscat(szBuffer
, L
"\\Linkage");
244 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szBuffer
, 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
247 RegQueryValueExW(hKey
, L
"Bind", NULL
, &dwType
, NULL
, &dwSize
);
251 Item
->pszBinding
= CoTaskMemAlloc(dwSize
);
252 if (Item
->pszBinding
== NULL
)
253 return E_OUTOFMEMORY
;
255 RegQueryValueExW(hKey
, L
"Bind", NULL
, &dwType
, (LPBYTE
)Item
->pszBinding
, &dwSize
);
265 EnumClientServiceProtocol(HKEY hKey
, const GUID
* pGuid
, NetCfgComponentItem
** pHead
)
272 HKEY hSubKey
, hNDIKey
;
273 NetCfgComponentItem
* pLast
= NULL
, *pCurrent
;
280 dwSize
= sizeof(szName
)/sizeof(WCHAR
);
281 if (RegEnumKeyExW(hKey
, dwIndex
++, szName
, &dwSize
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
283 pCurrent
= CoTaskMemAlloc(sizeof(NetCfgComponentItem
));
285 return E_OUTOFMEMORY
;
287 ZeroMemory(pCurrent
, sizeof(NetCfgComponentItem
));
288 CopyMemory(&pCurrent
->ClassGUID
, pGuid
, sizeof(GUID
));
290 if (FAILED(CLSIDFromString(szName
, &pCurrent
->InstanceId
)))
292 /// ReactOS tcpip guid is not yet generated
293 //CoTaskMemFree(pCurrent);
296 if (RegOpenKeyExW(hKey
, szName
, 0, KEY_READ
, &hSubKey
) == ERROR_SUCCESS
)
298 /* retrieve Characteristics */
299 dwSize
= sizeof(DWORD
);
301 RegQueryValueExW(hSubKey
, L
"Characteristics", NULL
, &dwType
, (LPBYTE
)&pCurrent
->dwCharacteristics
, &dwSize
);
302 if (dwType
!= REG_DWORD
)
303 pCurrent
->dwCharacteristics
= 0;
305 /* retrieve ComponentId */
306 dwSize
= sizeof(szText
);
307 if (RegQueryValueExW(hSubKey
, L
"ComponentId", NULL
, &dwType
, (LPBYTE
)szText
, &dwSize
) == ERROR_SUCCESS
)
309 if (dwType
== REG_SZ
)
311 szText
[(sizeof(szText
)/sizeof(WCHAR
))-1] = L
'\0';
312 pCurrent
->szId
= CoTaskMemAlloc((wcslen(szText
)+1)* sizeof(WCHAR
));
314 wcscpy(pCurrent
->szId
, szText
);
318 /* retrieve Description */
319 dwSize
= sizeof(szText
);
320 if (RegQueryValueExW(hSubKey
, L
"Description", NULL
, &dwType
, (LPBYTE
)szText
, &dwSize
) == ERROR_SUCCESS
)
322 if (dwType
== REG_SZ
)
324 szText
[(sizeof(szText
)/sizeof(WCHAR
))-1] = L
'\0';
325 pCurrent
->szDisplayName
= CoTaskMemAlloc((wcslen(szText
)+1)* sizeof(WCHAR
));
326 if (pCurrent
->szDisplayName
)
327 wcscpy(pCurrent
->szDisplayName
, szText
);
331 if (RegOpenKeyExW(hSubKey
, L
"NDI", 0, KEY_READ
, &hNDIKey
) == ERROR_SUCCESS
)
333 /* retrieve HelpText */
334 dwSize
= sizeof(szText
);
335 if (RegQueryValueExW(hNDIKey
, L
"HelpText", NULL
, &dwType
, (LPBYTE
)szText
, &dwSize
) == ERROR_SUCCESS
)
337 if (dwType
== REG_SZ
)
339 szText
[(sizeof(szText
)/sizeof(WCHAR
))-1] = L
'\0';
340 pCurrent
->szHelpText
= CoTaskMemAlloc((wcslen(szText
)+1)* sizeof(WCHAR
));
341 if (pCurrent
->szHelpText
)
342 wcscpy(pCurrent
->szHelpText
, szText
);
346 /* retrieve Service */
347 dwSize
= sizeof(szText
);
348 if (RegQueryValueExW(hNDIKey
, L
"Service", NULL
, &dwType
, (LPBYTE
)szText
, &dwSize
) == ERROR_SUCCESS
)
350 if (dwType
== REG_SZ
)
352 szText
[(sizeof(szText
)/sizeof(WCHAR
))-1] = L
'\0';
353 pCurrent
->szBindName
= CoTaskMemAlloc((wcslen(szText
)+1)* sizeof(WCHAR
));
354 if (pCurrent
->szBindName
)
355 wcscpy(pCurrent
->szBindName
, szText
);
358 RegCloseKey(hNDIKey
);
360 RegCloseKey(hSubKey
);
362 ReadBindingString(pCurrent
);
367 pLast
->pNext
= pCurrent
;
382 EnumerateNetworkComponent(
383 const GUID
*pGuid
, NetCfgComponentItem
** pHead
)
390 hr
= StringFromCLSID(pGuid
, &pszGuid
);
393 swprintf(szName
, L
"SYSTEM\\CurrentControlSet\\Control\\Network\\%s", pszGuid
);
394 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szName
, 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
396 hr
= EnumClientServiceProtocol(hKey
, pGuid
, pHead
);
399 CoTaskMemFree(pszGuid
);
405 EnumerateNetworkAdapter(NetCfgComponentItem
** pHead
)
407 DWORD dwSize
, dwIndex
;
409 SP_DEVINFO_DATA DevInfo
;
412 WCHAR szAdapterNetCfg
[MAX_DEVICE_ID_LEN
];
413 WCHAR szDetail
[200] = L
"SYSTEM\\CurrentControlSet\\Control\\Class\\";
414 WCHAR szName
[130] = L
"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
415 NetCfgComponentItem
* pLast
= NULL
, *pCurrent
;
417 hInfo
= SetupDiGetClassDevs(&GUID_DEVCLASS_NET
, NULL
, NULL
, DIGCF_PRESENT
);
426 ZeroMemory(&DevInfo
, sizeof(SP_DEVINFO_DATA
));
427 DevInfo
.cbSize
= sizeof(DevInfo
);
429 /* get device info */
430 if (!SetupDiEnumDeviceInfo(hInfo
, dwIndex
++, &DevInfo
))
433 /* get device software registry path */
434 if (!SetupDiGetDeviceRegistryPropertyW(hInfo
, &DevInfo
, SPDRP_DRIVER
, NULL
, (LPBYTE
)&szDetail
[39], sizeof(szDetail
)/sizeof(WCHAR
) - 40, &dwSize
))
437 /* open device registry key */
438 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szDetail
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
441 /* query NetCfgInstanceId for current device */
442 dwSize
= sizeof(szNetCfg
);
443 if (RegQueryValueExW(hKey
, L
"NetCfgInstanceId", NULL
, NULL
, (LPBYTE
)szNetCfg
, &dwSize
) != ERROR_SUCCESS
)
449 /* allocate new INetConnectionItem */
450 pCurrent
= CoTaskMemAlloc(sizeof(NetCfgComponentItem
));
454 ZeroMemory(pCurrent
, sizeof(NetCfgComponentItem
));
455 CopyMemory(&pCurrent
->ClassGUID
, &GUID_DEVCLASS_NET
, sizeof(GUID
));
456 CLSIDFromString(szNetCfg
, &pCurrent
->InstanceId
); //FIXME
459 pCurrent
->szBindName
= CoTaskMemAlloc((wcslen(szNetCfg
)+1) *sizeof(WCHAR
));
460 if (pCurrent
->szBindName
)
461 wcscpy(pCurrent
->szBindName
, szNetCfg
);
463 /* retrieve ComponentId */
464 dwSize
= sizeof(szAdapterNetCfg
);
465 if (RegQueryValueExW(hKey
, L
"ComponentId", NULL
, NULL
, (LPBYTE
)szAdapterNetCfg
, &dwSize
) == ERROR_SUCCESS
)
467 pCurrent
->szId
= CoTaskMemAlloc((wcslen(szAdapterNetCfg
)+1) * sizeof(WCHAR
));
469 wcscpy(pCurrent
->szId
, szAdapterNetCfg
);
471 /* set INetCfgComponent::GetDisplayName */
472 dwSize
= sizeof(szAdapterNetCfg
);
473 if (RegQueryValueExW(hKey
, L
"DriverDesc", NULL
, NULL
, (LPBYTE
)szAdapterNetCfg
, &dwSize
) == ERROR_SUCCESS
)
475 pCurrent
->szDisplayName
= CoTaskMemAlloc((wcslen(szAdapterNetCfg
)+1) * sizeof(WCHAR
));
476 if (pCurrent
->szDisplayName
)
477 wcscpy(pCurrent
->szDisplayName
, szAdapterNetCfg
);
481 /* open network connections details */
482 wcscpy(&szName
[80], szNetCfg
);
483 wcscpy(&szName
[118], L
"\\Connection");
485 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szName
, 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
487 /* retrieve pnp instance id */
488 dwSize
= sizeof(szAdapterNetCfg
);
489 if (RegQueryValueExW(hKey
, L
"PnpInstanceID", NULL
, NULL
, (LPBYTE
)szAdapterNetCfg
, &dwSize
) == ERROR_SUCCESS
)
491 pCurrent
->szNodeId
= CoTaskMemAlloc((wcslen(szAdapterNetCfg
)+1) * sizeof(WCHAR
));
492 if (pCurrent
->szNodeId
)
493 wcscpy(pCurrent
->szNodeId
, szAdapterNetCfg
);
498 if (SetupDiGetDeviceRegistryPropertyW(hInfo
, &DevInfo
, SPDRP_DEVICEDESC
, NULL
, (PBYTE
)szNetCfg
, sizeof(szNetCfg
)/sizeof(WCHAR
), &dwSize
))
500 szNetCfg
[(sizeof(szNetCfg
)/sizeof(WCHAR
))-1] = L
'\0';
501 pCurrent
->szDisplayName
= CoTaskMemAlloc((wcslen(szNetCfg
)+1) * sizeof(WCHAR
));
502 if (pCurrent
->szDisplayName
)
503 wcscpy(pCurrent
->szDisplayName
, szNetCfg
);
507 pLast
->pNext
= pCurrent
;
515 SetupDiDestroyDeviceInfoList(hInfo
);
521 FindNetworkComponent(
522 NetCfgComponentItem
* pHead
,
523 LPCWSTR pszwComponentId
,
524 INetCfgComponent
**pComponent
,
529 if (!_wcsicmp(pHead
->szId
, pszwComponentId
))
531 return INetCfgComponent_Constructor(NULL
, &IID_INetCfgComponent
, (LPVOID
*)pComponent
, pHead
, iface
);
533 pHead
= pHead
->pNext
;
542 INetCfg_fnQueryInterface(
547 INetCfgImpl
* This
= (INetCfgImpl
*)iface
;
550 if (IsEqualIID (iid
, &IID_IUnknown
) ||
551 IsEqualIID (iid
, &IID_INetCfg
))
554 INetCfg_AddRef(iface
);
557 else if (IsEqualIID (iid
, &IID_INetCfgLock
))
559 if (This
->bInitialized
)
560 return NETCFG_E_ALREADY_INITIALIZED
;
562 *ppvObj
= (LPVOID
)&This
->lpVtblLock
;
563 This
->hMutex
= CreateMutexW(NULL
, FALSE
, L
"NetCfgLock");
565 INetCfgLock_AddRef(iface
);
568 else if (IsEqualIID (iid
, &IID_INetCfgPnpReconfigCallback
))
570 if (This
->bInitialized
)
571 return NETCFG_E_ALREADY_INITIALIZED
;
573 *ppvObj
= (LPVOID
)&This
->lpVtblPnpReconfigCallback
;
574 INetCfgPnpReconfigCallback_AddRef(iface
);
578 return E_NOINTERFACE
;
586 INetCfgImpl
* This
= (INetCfgImpl
*)iface
;
587 ULONG refCount
= InterlockedIncrement(&This
->ref
);
597 INetCfgImpl
* This
= (INetCfgImpl
*)iface
;
598 ULONG refCount
= InterlockedDecrement(&This
->ref
);
602 CoTaskMemFree (This
);
609 INetCfg_fnInitialize(
614 INetCfgImpl
*This
= (INetCfgImpl
*)iface
;
616 if (This
->bInitialized
)
617 return NETCFG_E_ALREADY_INITIALIZED
;
619 hr
= EnumerateNetworkAdapter(&This
->pNet
);
624 hr
= EnumerateNetworkComponent(&GUID_DEVCLASS_NETCLIENT
, &This
->pClient
);
628 hr
= EnumerateNetworkComponent(&GUID_DEVCLASS_NETSERVICE
, &This
->pService
);
633 hr
= EnumerateNetworkComponent(&GUID_DEVCLASS_NETTRANS
, &This
->pProtocol
);
637 This
->bInitialized
= TRUE
;
642 ApplyOrCancelChanges(
643 NetCfgComponentItem
*pHead
,
644 const CLSID
* lpClassGUID
,
655 if (IsEqualGUID(lpClassGUID
, &GUID_DEVCLASS_NET
))
659 if (StringFromCLSID(&pHead
->InstanceId
, &pszGuid
) == NOERROR
)
661 swprintf(szName
, L
"SYSTEM\\CurrentControlSet\\Control\\Network\\%s", pszGuid
);
662 CoTaskMemFree(pszGuid
);
664 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szName
, 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
666 RegSetValueExW(hKey
, NULL
, 0, REG_SZ
, (LPBYTE
)pHead
->szDisplayName
, (wcslen(pHead
->szDisplayName
)+1) * sizeof(WCHAR
));
672 else if (pHead
->pNCCC
)
676 INetCfgComponentControl_ApplyRegistryChanges(pHead
->pNCCC
);
678 // implement INetCfgPnpReconfigCallback and pass it to
679 //INetCfgComponentControl_ApplyPnpChanges(pHead->pNCCC, NULL);
683 INetCfgComponentControl_CancelChanges(pHead
->pNCCC
);
687 pHead
= pHead
->pNext
;
693 INetCfg_fnUninitialize(
696 INetCfgImpl
*This
= (INetCfgImpl
*)iface
;
698 if (!This
->bInitialized
)
699 return NETCFG_E_NOT_INITIALIZED
;
710 INetCfgImpl
*This
= (INetCfgImpl
*)iface
;
712 if (!This
->bInitialized
)
713 return NETCFG_E_NOT_INITIALIZED
;
715 ApplyOrCancelChanges(This
->pNet
, &GUID_DEVCLASS_NET
, TRUE
);
716 ApplyOrCancelChanges(This
->pClient
, &GUID_DEVCLASS_NETCLIENT
, TRUE
);
717 ApplyOrCancelChanges(This
->pService
, &GUID_DEVCLASS_NETSERVICE
, TRUE
);
718 ApplyOrCancelChanges(This
->pProtocol
, &GUID_DEVCLASS_NETTRANS
, TRUE
);
728 INetCfgImpl
*This
= (INetCfgImpl
*)iface
;
730 if (!This
->bInitialized
)
731 return NETCFG_E_NOT_INITIALIZED
;
733 ApplyOrCancelChanges(This
->pClient
, &GUID_DEVCLASS_NETCLIENT
, FALSE
);
734 ApplyOrCancelChanges(This
->pService
, &GUID_DEVCLASS_NETSERVICE
, FALSE
);
735 ApplyOrCancelChanges(This
->pProtocol
, &GUID_DEVCLASS_NETTRANS
, FALSE
);
742 INetCfg_fnEnumComponents(
744 const GUID
*pguidClass
,
745 IEnumNetCfgComponent
**ppenumComponent
)
747 INetCfgImpl
*This
= (INetCfgImpl
*)iface
;
749 if (!This
->bInitialized
)
750 return NETCFG_E_NOT_INITIALIZED
;
752 if (IsEqualGUID(&GUID_DEVCLASS_NET
, pguidClass
))
753 return IEnumNetCfgComponent_Constructor (NULL
, &IID_IEnumNetCfgComponent
, (LPVOID
*)ppenumComponent
, This
->pNet
, iface
);
754 else if (IsEqualGUID(&GUID_DEVCLASS_NETCLIENT
, pguidClass
))
755 return IEnumNetCfgComponent_Constructor (NULL
, &IID_IEnumNetCfgComponent
, (LPVOID
*)ppenumComponent
, This
->pClient
, iface
);
756 else if (IsEqualGUID(&GUID_DEVCLASS_NETSERVICE
, pguidClass
))
757 return IEnumNetCfgComponent_Constructor (NULL
, &IID_IEnumNetCfgComponent
, (LPVOID
*)ppenumComponent
, This
->pService
, iface
);
758 else if (IsEqualGUID(&GUID_DEVCLASS_NETTRANS
, pguidClass
))
759 return IEnumNetCfgComponent_Constructor (NULL
, &IID_IEnumNetCfgComponent
, (LPVOID
*)ppenumComponent
, This
->pProtocol
, iface
);
761 return E_NOINTERFACE
;
767 INetCfg_fnFindComponent(
769 LPCWSTR pszwComponentId
,
770 INetCfgComponent
**pComponent
)
773 INetCfgImpl
*This
= (INetCfgImpl
*)iface
;
775 if (!This
->bInitialized
)
776 return NETCFG_E_NOT_INITIALIZED
;
778 hr
= FindNetworkComponent(This
->pClient
, pszwComponentId
, pComponent
, iface
);
782 hr
= FindNetworkComponent(This
->pService
, pszwComponentId
, pComponent
, iface
);
786 hr
= FindNetworkComponent(This
->pProtocol
, pszwComponentId
, pComponent
, iface
);
795 INetCfg_fnQueryNetCfgClass(
797 const GUID
*pguidClass
,
804 static const INetCfgVtbl vt_NetCfg
=
806 INetCfg_fnQueryInterface
,
809 INetCfg_fnInitialize
,
810 INetCfg_fnUninitialize
,
813 INetCfg_fnEnumComponents
,
814 INetCfg_fnFindComponent
,
815 INetCfg_fnQueryNetCfgClass
,
818 HRESULT WINAPI
INetCfg_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
825 This
= (INetCfgImpl
*) CoTaskMemAlloc(sizeof (INetCfgImpl
));
827 return E_OUTOFMEMORY
;
830 This
->lpVtbl
= (const INetCfg
*)&vt_NetCfg
;
831 This
->lpVtblLock
= (const INetCfgLock
*)&vt_NetCfgLock
;
832 This
->lpVtblPnpReconfigCallback
= (const INetCfgPnpReconfigCallback
*)&vt_NetCfgPnpReconfigCallback
;
834 This
->bInitialized
= FALSE
;
836 This
->pClient
= NULL
;
837 This
->pService
= NULL
;
838 This
->pProtocol
= NULL
;
840 if (!SUCCEEDED (INetCfg_QueryInterface ((INetCfg
*)This
, riid
, ppv
)))
842 INetCfg_Release((INetCfg
*)This
);
843 return E_NOINTERFACE
;
846 INetCfg_Release((INetCfg
*)This
);