5 const INetCfgComponent
*lpVtbl
;
6 const INetCfgComponentBindings
*lpVtblComponentBindings
;
8 NetCfgComponentItem
* pItem
;
9 INetCfgComponentPropertyUi
* pProperty
;
11 } INetCfgComponentImpl
;
15 const IEnumNetCfgComponent
* lpVtbl
;
17 NetCfgComponentItem
* pCurrent
;
18 NetCfgComponentItem
* pHead
;
20 } IEnumNetCfgComponentImpl
;
22 static __inline INetCfgComponentImpl
* impl_from_INetCfgComponentBindings(INetCfgComponentBindings
*iface
)
24 return (INetCfgComponentImpl
*)((char *)iface
- FIELD_OFFSET(INetCfgComponentImpl
, lpVtblComponentBindings
));
28 /***************************************************************
29 * INetCfgComponentBindings
34 INetCfgComponentBindings_fnQueryInterface(
35 INetCfgComponentBindings
*iface
,
39 INetCfgComponentImpl
*This
= impl_from_INetCfgComponentBindings(iface
);
40 return INetCfgComponent_QueryInterface((INetCfgComponent
*)This
, iid
, ppvObj
);
45 INetCfgComponentBindings_fnAddRef(
46 INetCfgComponentBindings
*iface
)
48 INetCfgComponentImpl
*This
= impl_from_INetCfgComponentBindings(iface
);
49 return INetCfgComponent_AddRef((INetCfgComponent
*)This
);
54 INetCfgComponentBindings_fnRelease(
55 INetCfgComponentBindings
*iface
)
57 INetCfgComponentImpl
*This
= impl_from_INetCfgComponentBindings(iface
);
58 return INetCfgComponent_Release((INetCfgComponent
*)This
);
63 INetCfgComponentBindings_fnBindTo(
64 INetCfgComponentBindings
*iface
,
65 INetCfgComponent
*pnccItem
)
72 INetCfgComponentBindings_fnUnbindFrom(
73 INetCfgComponentBindings
*iface
,
74 INetCfgComponent
*pnccItem
)
81 INetCfgComponentBindings_fnSupportsBindingInterface(
82 INetCfgComponentBindings
*iface
,
84 LPCWSTR pszwInterfaceName
)
91 INetCfgComponentBindings_fnIsBoundTo(
92 INetCfgComponentBindings
*iface
,
93 INetCfgComponent
*pnccItem
)
95 INetCfgComponentImpl
*pComponent
;
96 PWSTR pszBindName
, ptr
;
99 pComponent
= impl_from_INetCfgComponentBindings(iface
);
100 if (pComponent
== NULL
||
101 pComponent
->pItem
== NULL
||
102 pComponent
->pItem
->pszBinding
== NULL
)
105 if (pnccItem
== NULL
||
106 ((INetCfgComponentImpl
*)pnccItem
)->pItem
== NULL
||
107 ((INetCfgComponentImpl
*)pnccItem
)->pItem
->szBindName
== NULL
)
110 pszBindName
= ((INetCfgComponentImpl
*)pnccItem
)->pItem
->szBindName
;
112 ptr
= pComponent
->pItem
->pszBinding
;
113 while (*ptr
!= UNICODE_NULL
)
117 if (len
> 8 && _wcsicmp(&ptr
[8], pszBindName
) == 0)
128 INetCfgComponentBindings_fnIsBindableTo(
129 INetCfgComponentBindings
*iface
,
130 INetCfgComponent
*pnccItem
)
137 INetCfgComponentBindings_fnEnumBindingPaths(
138 INetCfgComponentBindings
*iface
,
140 IEnumNetCfgBindingPath
**ppIEnum
)
142 return IEnumNetCfgBindingPath_Constructor(NULL
, &IID_IEnumNetCfgBindingPath
, (LPVOID
*)ppIEnum
, dwFlags
);
147 INetCfgComponentBindings_fnMoveBefore(
148 INetCfgComponentBindings
*iface
,
150 INetCfgBindingPath
*pncbItemSrc
,
151 INetCfgBindingPath
*pncbItemDest
)
158 INetCfgComponentBindings_fnMoveAfter(
159 INetCfgComponentBindings
*iface
,
161 INetCfgBindingPath
*pncbItemSrc
,
162 INetCfgBindingPath
*pncbItemDest
)
167 static const INetCfgComponentBindingsVtbl vt_NetCfgComponentBindings
=
169 INetCfgComponentBindings_fnQueryInterface
,
170 INetCfgComponentBindings_fnAddRef
,
171 INetCfgComponentBindings_fnRelease
,
172 INetCfgComponentBindings_fnBindTo
,
173 INetCfgComponentBindings_fnUnbindFrom
,
174 INetCfgComponentBindings_fnSupportsBindingInterface
,
175 INetCfgComponentBindings_fnIsBoundTo
,
176 INetCfgComponentBindings_fnIsBindableTo
,
177 INetCfgComponentBindings_fnEnumBindingPaths
,
178 INetCfgComponentBindings_fnMoveBefore
,
179 INetCfgComponentBindings_fnMoveAfter
,
182 /***************************************************************
188 INetCfgComponent_fnQueryInterface(
189 INetCfgComponent
* iface
,
193 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
196 if (IsEqualIID (iid
, &IID_IUnknown
) ||
197 IsEqualIID (iid
, &IID_INetCfgComponent
))
200 INetCfg_AddRef(iface
);
203 else if (IsEqualIID (iid
, &IID_INetCfgComponentBindings
))
205 *ppvObj
= (LPVOID
)&This
->lpVtblComponentBindings
;
206 INetCfgComponentBindings_AddRef(iface
);
210 return E_NOINTERFACE
;
215 INetCfgComponent_fnAddRef(
216 INetCfgComponent
* iface
)
218 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
219 ULONG refCount
= InterlockedIncrement(&This
->ref
);
226 INetCfgComponent_fnRelease(
227 INetCfgComponent
* iface
)
229 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
230 ULONG refCount
= InterlockedDecrement(&This
->ref
);
241 INetCfgComponent_fnGetDisplayName(
242 INetCfgComponent
* iface
,
243 LPWSTR
* ppszwDisplayName
)
247 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
249 if (This
== NULL
|| ppszwDisplayName
== NULL
)
252 if (This
->pItem
->szDisplayName
)
253 Length
= wcslen(This
->pItem
->szDisplayName
)+1;
257 szName
= CoTaskMemAlloc(Length
* sizeof(WCHAR
));
259 return E_OUTOFMEMORY
;
262 wcscpy(szName
, This
->pItem
->szDisplayName
);
266 *ppszwDisplayName
= szName
;
273 INetCfgComponent_fnSetDisplayName(
274 INetCfgComponent
* iface
,
275 LPCWSTR ppszwDisplayName
)
278 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
280 if (This
== NULL
|| ppszwDisplayName
== NULL
)
283 /* setting name is only supported for network cards */
284 if (!IsEqualGUID(&This
->pItem
->ClassGUID
, &GUID_DEVCLASS_NET
))
288 /// check for invalid characters
289 /// check for write lock
291 szName
= CoTaskMemAlloc((wcslen(ppszwDisplayName
)+1) * sizeof(WCHAR
));
293 return E_OUTOFMEMORY
;
295 wcscpy(szName
, ppszwDisplayName
);
296 CoTaskMemFree(This
->pItem
->szDisplayName
);
297 This
->pItem
->szDisplayName
= szName
;
298 This
->pItem
->bChanged
= TRUE
;
305 INetCfgComponent_fnGetHelpText(
306 INetCfgComponent
* iface
,
307 LPWSTR
* ppszwHelpText
)
311 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
313 if (This
== NULL
|| ppszwHelpText
== NULL
)
316 if (This
->pItem
->szHelpText
)
317 Length
= wcslen(This
->pItem
->szHelpText
)+1;
321 szHelp
= CoTaskMemAlloc(Length
* sizeof(WCHAR
));
323 return E_OUTOFMEMORY
;
326 wcscpy(szHelp
, This
->pItem
->szHelpText
);
330 *ppszwHelpText
= szHelp
;
337 INetCfgComponent_fnGetId(
338 INetCfgComponent
* iface
,
342 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
344 if (This
== NULL
|| ppszwId
== NULL
)
347 szId
= CoTaskMemAlloc((wcslen(This
->pItem
->szId
)+1) * sizeof(WCHAR
));
349 return E_OUTOFMEMORY
;
351 wcscpy(szId
, This
->pItem
->szId
);
359 INetCfgComponent_fnGetCharacteristics(
360 INetCfgComponent
* iface
,
361 DWORD
* pdwCharacteristics
)
363 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
365 if (This
== NULL
|| pdwCharacteristics
== NULL
)
368 *pdwCharacteristics
= This
->pItem
->dwCharacteristics
;
375 INetCfgComponent_fnGetInstanceGuid(
376 INetCfgComponent
* iface
,
379 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
381 if (This
== NULL
|| pGuid
== NULL
)
384 CopyMemory(pGuid
, &This
->pItem
->InstanceId
, sizeof(GUID
));
390 INetCfgComponent_fnGetPnpDevNodeId(
391 INetCfgComponent
* iface
,
392 LPWSTR
* ppszwDevNodeId
)
395 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
397 if (This
== NULL
|| ppszwDevNodeId
== NULL
)
400 if (!IsEqualGUID(&GUID_DEVCLASS_NET
, &This
->pItem
->ClassGUID
))
403 szNode
= CoTaskMemAlloc((wcslen(This
->pItem
->szNodeId
)+1) * sizeof(WCHAR
));
405 return E_OUTOFMEMORY
;
407 wcscpy(szNode
, This
->pItem
->szNodeId
);
408 *ppszwDevNodeId
= szNode
;
414 INetCfgComponent_fnGetClassGuid(
415 INetCfgComponent
* iface
,
418 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
420 if (This
== NULL
|| pGuid
== NULL
)
423 CopyMemory(pGuid
, &This
->pItem
->ClassGUID
, sizeof(GUID
));
429 INetCfgComponent_fnGetBindName(
430 INetCfgComponent
* iface
,
431 LPWSTR
* ppszwBindName
)
434 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
436 if (This
== NULL
|| ppszwBindName
== NULL
)
439 szBind
= CoTaskMemAlloc((wcslen(This
->pItem
->szBindName
)+1) * sizeof(WCHAR
));
441 return E_OUTOFMEMORY
;
443 wcscpy(szBind
, This
->pItem
->szBindName
);
444 *ppszwBindName
= szBind
;
451 INetCfgComponent_fnGetDeviceStatus(
452 INetCfgComponent
* iface
,
455 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
457 if (This
== NULL
|| pStatus
== NULL
)
460 if (!IsEqualGUID(&GUID_DEVCLASS_NET
, &This
->pItem
->ClassGUID
))
463 *pStatus
= This
->pItem
->Status
;
470 INetCfgComponent_fnOpenParamKey(
471 INetCfgComponent
* iface
,
474 WCHAR szBuffer
[200] = L
"SYSTEM\\CurrentControlSet\\Services\\";
475 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
477 if (This
== NULL
|| phkey
== NULL
)
480 wcscat(szBuffer
, This
->pItem
->szBindName
);
481 wcscat(szBuffer
, L
"\\Parameters");
483 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szBuffer
, 0, KEY_READ
| KEY_WRITE
, phkey
) == ERROR_SUCCESS
)
491 CreateNotificationObject(
492 INetCfgComponentImpl
* This
,
493 INetCfgComponent
* iface
,
498 DWORD dwSize
, dwType
;
499 GUID CLSID_NotifyObject
;
501 INetCfgComponentPropertyUi
* pNCCPU
;
502 INetCfgComponentControl
* pNCCC
;
508 wcscpy(szName
,L
"SYSTEM\\CurrentControlSet\\Control\\Network\\");
510 /* get the Class GUID */
511 hr
= INetCfgComponent_GetClassGuid(iface
, &ClassGUID
);
515 hr
= StringFromCLSID(&ClassGUID
, &pStr
);
519 wcscat(szName
, pStr
);
521 wcscat(szName
, L
"\\");
523 /* get the Instance GUID */
524 hr
= INetCfgComponent_GetInstanceGuid(iface
, &InstanceGUID
);
528 hr
= StringFromCLSID(&InstanceGUID
, &pStr
);
532 wcscat(szName
, pStr
);
535 wcscat(szName
, L
"\\NDI");
537 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szName
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
540 dwSize
= sizeof(szName
);
541 lRet
= RegQueryValueExW(hKey
, L
"ClsID", NULL
, &dwType
, (LPBYTE
)szName
, &dwSize
);
544 if (lRet
!= ERROR_SUCCESS
&& dwType
!= REG_SZ
)
547 hr
= CLSIDFromString(szName
, &CLSID_NotifyObject
);
551 hr
= CoCreateInstance(&CLSID_NotifyObject
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetCfgComponentPropertyUi
, (LPVOID
*)&pNCCPU
);
555 hr
= INetCfgComponentPropertyUi_QueryInterface(pNCCPU
, &IID_INetCfgComponentControl
, (LPVOID
*)&pNCCC
);
558 INetCfgComponentPropertyUi_Release(pNCCPU
);
562 hr
= INetCfgComponentPropertyUi_QueryPropertyUi(pNCCPU
, pUnk
);
565 INetCfgComponentPropertyUi_Release(pNCCPU
);
569 hr
= INetCfgComponentControl_Initialize(pNCCC
, iface
, This
->pNCfg
, FALSE
);
572 INetCfgComponentControl_Release(pNCCC
);
573 INetCfgComponentPropertyUi_Release(pNCCPU
);
577 hr
= INetCfgComponentPropertyUi_SetContext(pNCCPU
, pUnk
);
580 INetCfgComponentPropertyUi_Release(pNCCPU
);
583 This
->pProperty
= pNCCPU
;
584 This
->pItem
->pNCCC
= pNCCC
;
590 PropSheetProc(HWND hwndDlg
, UINT uMsg
, LPARAM lParam
)
592 // NOTE: This callback is needed to set large icon correctly.
596 case PSCB_INITIALIZED
:
598 hIcon
= LoadIconW(netcfgx_hInstance
, MAKEINTRESOURCEW(IDI_INTERNET
));
599 SendMessageW(hwndDlg
, WM_SETICON
, ICON_BIG
, (LPARAM
)hIcon
);
608 INetCfgComponent_fnRaisePropertyUi(
609 INetCfgComponent
* iface
,
617 PROPSHEETHEADERW pinfo
;
618 HPROPSHEETPAGE
* hppages
;
620 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
622 if (!This
->pProperty
)
624 hr
= CreateNotificationObject(This
,iface
, pUnk
);
629 if (dwFlags
== NCRP_QUERY_PROPERTY_UI
)
635 hr
= INetCfgComponentPropertyUi_MergePropPages(This
->pProperty
, &dwDefPages
, (BYTE
**)&hppages
, &Pages
, hwndParent
, NULL
);
636 if (FAILED(hr
) || !Pages
)
640 ZeroMemory(&pinfo
, sizeof(PROPSHEETHEADERW
));
641 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
642 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
| PSH_PROPTITLE
| PSH_NOAPPLYNOW
|
643 PSH_USEICONID
| PSH_USECALLBACK
;
644 pinfo
.u3
.phpage
= hppages
;
645 pinfo
.hwndParent
= hwndParent
;
646 pinfo
.nPages
= Pages
;
647 pinfo
.hInstance
= netcfgx_hInstance
;
648 pinfo
.pszCaption
= This
->pItem
->szDisplayName
;
649 pinfo
.u
.pszIcon
= MAKEINTRESOURCEW(IDI_INTERNET
);
650 pinfo
.pfnCallback
= PropSheetProc
;
652 iResult
= PropertySheetW(&pinfo
);
653 CoTaskMemFree(hppages
);
656 /* indicate that settings should be stored */
657 This
->pItem
->bChanged
= TRUE
;
662 static const INetCfgComponentVtbl vt_NetCfgComponent
=
664 INetCfgComponent_fnQueryInterface
,
665 INetCfgComponent_fnAddRef
,
666 INetCfgComponent_fnRelease
,
667 INetCfgComponent_fnGetDisplayName
,
668 INetCfgComponent_fnSetDisplayName
,
669 INetCfgComponent_fnGetHelpText
,
670 INetCfgComponent_fnGetId
,
671 INetCfgComponent_fnGetCharacteristics
,
672 INetCfgComponent_fnGetInstanceGuid
,
673 INetCfgComponent_fnGetPnpDevNodeId
,
674 INetCfgComponent_fnGetClassGuid
,
675 INetCfgComponent_fnGetBindName
,
676 INetCfgComponent_fnGetDeviceStatus
,
677 INetCfgComponent_fnOpenParamKey
,
678 INetCfgComponent_fnRaisePropertyUi
683 INetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
685 INetCfgComponentImpl
*This
;
690 This
= (INetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (INetCfgComponentImpl
));
692 return E_OUTOFMEMORY
;
695 This
->lpVtbl
= (const INetCfgComponent
*)&vt_NetCfgComponent
;
696 This
->lpVtblComponentBindings
= (const INetCfgComponentBindings
*)&vt_NetCfgComponentBindings
;
697 This
->pProperty
= NULL
;
701 if (!SUCCEEDED (INetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
703 INetCfgComponent_Release((INetCfg
*)This
);
704 return E_NOINTERFACE
;
707 INetCfgComponent_Release((INetCfgComponent
*)This
);
712 /***************************************************************
713 * IEnumNetCfgComponent
718 IEnumNetCfgComponent_fnQueryInterface(
719 IEnumNetCfgComponent
* iface
,
723 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
726 if (IsEqualIID (iid
, &IID_IUnknown
) ||
727 IsEqualIID (iid
, &IID_IEnumNetCfgComponent
))
730 INetCfg_AddRef(iface
);
734 return E_NOINTERFACE
;
740 IEnumNetCfgComponent_fnAddRef(
741 IEnumNetCfgComponent
* iface
)
743 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
744 ULONG refCount
= InterlockedIncrement(&This
->ref
);
751 IEnumNetCfgComponent_fnRelease(
752 IEnumNetCfgComponent
* iface
)
754 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
755 ULONG refCount
= InterlockedDecrement(&This
->ref
);
762 IEnumNetCfgComponent_fnNext(
763 IEnumNetCfgComponent
* iface
,
765 INetCfgComponent
**rgelt
,
769 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
771 if (!iface
|| !rgelt
)
780 hr
= INetCfgComponent_Constructor (NULL
, &IID_INetCfgComponent
, (LPVOID
*)rgelt
, This
->pCurrent
, This
->pNCfg
);
783 This
->pCurrent
= This
->pCurrent
->pNext
;
792 IEnumNetCfgComponent_fnSkip(
793 IEnumNetCfgComponent
* iface
,
796 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
801 while(celt
-- > 0 && This
->pCurrent
)
802 This
->pCurrent
= This
->pCurrent
->pNext
;
812 IEnumNetCfgComponent_fnReset(
813 IEnumNetCfgComponent
* iface
)
815 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
817 This
->pCurrent
= This
->pHead
;
823 IEnumNetCfgComponent_fnClone(
824 IEnumNetCfgComponent
* iface
,
825 IEnumNetCfgComponent
**ppenum
)
830 static const IEnumNetCfgComponentVtbl vt_EnumNetCfgComponent
=
832 IEnumNetCfgComponent_fnQueryInterface
,
833 IEnumNetCfgComponent_fnAddRef
,
834 IEnumNetCfgComponent_fnRelease
,
835 IEnumNetCfgComponent_fnNext
,
836 IEnumNetCfgComponent_fnSkip
,
837 IEnumNetCfgComponent_fnReset
,
838 IEnumNetCfgComponent_fnClone
843 IEnumNetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
845 IEnumNetCfgComponentImpl
*This
;
850 This
= (IEnumNetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (IEnumNetCfgComponentImpl
));
852 return E_OUTOFMEMORY
;
855 This
->lpVtbl
= (const IEnumNetCfgComponent
*)&vt_EnumNetCfgComponent
;
856 This
->pCurrent
= pItem
;
860 if (!SUCCEEDED (IEnumNetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
862 IEnumNetCfgComponent_Release((INetCfg
*)This
);
863 return E_NOINTERFACE
;
866 IEnumNetCfgComponent_Release((IEnumNetCfgComponent
*)This
);