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
;
506 //CLSID InstanceGUID;
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 */
525 hr
= INetCfgComponent_GetInstanceGuid(iface
, &InstanceGUID
);
529 hr
= StringFromCLSID(&InstanceGUID
, &pStr
);
533 wcscat(szName
, pStr
);
536 // HACK HACK HACK HACK HACK
537 wcscat(szName
, L
"{RandomProtocolGUID_TCPIP}");
540 wcscat(szName
, L
"\\NDI");
542 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szName
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
545 dwSize
= sizeof(szName
);
546 lRet
= RegQueryValueExW(hKey
, L
"ClsID", NULL
, &dwType
, (LPBYTE
)szName
, &dwSize
);
549 if (lRet
!= ERROR_SUCCESS
&& dwType
!= REG_SZ
)
552 hr
= CLSIDFromString(szName
, &CLSID_NotifyObject
);
556 hr
= CoCreateInstance(&CLSID_NotifyObject
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetCfgComponentPropertyUi
, (LPVOID
*)&pNCCPU
);
560 hr
= INetCfgComponentPropertyUi_QueryInterface(pNCCPU
, &IID_INetCfgComponentControl
, (LPVOID
*)&pNCCC
);
563 INetCfgComponentPropertyUi_Release(pNCCPU
);
567 hr
= INetCfgComponentPropertyUi_QueryPropertyUi(pNCCPU
, pUnk
);
570 INetCfgComponentPropertyUi_Release(pNCCPU
);
574 hr
= INetCfgComponentControl_Initialize(pNCCC
, iface
, This
->pNCfg
, FALSE
);
577 INetCfgComponentControl_Release(pNCCC
);
578 INetCfgComponentPropertyUi_Release(pNCCPU
);
582 hr
= INetCfgComponentPropertyUi_SetContext(pNCCPU
, pUnk
);
585 INetCfgComponentPropertyUi_Release(pNCCPU
);
588 This
->pProperty
= pNCCPU
;
589 This
->pItem
->pNCCC
= pNCCC
;
595 PropSheetProc(HWND hwndDlg
, UINT uMsg
, LPARAM lParam
)
597 // NOTE: This callback is needed to set large icon correctly.
601 case PSCB_INITIALIZED
:
603 hIcon
= LoadIconW(netcfgx_hInstance
, MAKEINTRESOURCEW(IDI_INTERNET
));
604 SendMessageW(hwndDlg
, WM_SETICON
, ICON_BIG
, (LPARAM
)hIcon
);
613 INetCfgComponent_fnRaisePropertyUi(
614 INetCfgComponent
* iface
,
622 PROPSHEETHEADERW pinfo
;
623 HPROPSHEETPAGE
* hppages
;
625 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
627 if (!This
->pProperty
)
629 hr
= CreateNotificationObject(This
,iface
, pUnk
);
634 if (dwFlags
== NCRP_QUERY_PROPERTY_UI
)
640 hr
= INetCfgComponentPropertyUi_MergePropPages(This
->pProperty
, &dwDefPages
, (BYTE
**)&hppages
, &Pages
, hwndParent
, NULL
);
641 if (FAILED(hr
) || !Pages
)
645 ZeroMemory(&pinfo
, sizeof(PROPSHEETHEADERW
));
646 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
647 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
| PSH_PROPTITLE
| PSH_NOAPPLYNOW
|
648 PSH_USEICONID
| PSH_USECALLBACK
;
649 pinfo
.u3
.phpage
= hppages
;
650 pinfo
.hwndParent
= hwndParent
;
651 pinfo
.nPages
= Pages
;
652 pinfo
.hInstance
= netcfgx_hInstance
;
653 pinfo
.pszCaption
= This
->pItem
->szDisplayName
;
654 pinfo
.u
.pszIcon
= MAKEINTRESOURCEW(IDI_INTERNET
);
655 pinfo
.pfnCallback
= PropSheetProc
;
657 iResult
= PropertySheetW(&pinfo
);
658 CoTaskMemFree(hppages
);
661 /* indicate that settings should be stored */
662 This
->pItem
->bChanged
= TRUE
;
667 static const INetCfgComponentVtbl vt_NetCfgComponent
=
669 INetCfgComponent_fnQueryInterface
,
670 INetCfgComponent_fnAddRef
,
671 INetCfgComponent_fnRelease
,
672 INetCfgComponent_fnGetDisplayName
,
673 INetCfgComponent_fnSetDisplayName
,
674 INetCfgComponent_fnGetHelpText
,
675 INetCfgComponent_fnGetId
,
676 INetCfgComponent_fnGetCharacteristics
,
677 INetCfgComponent_fnGetInstanceGuid
,
678 INetCfgComponent_fnGetPnpDevNodeId
,
679 INetCfgComponent_fnGetClassGuid
,
680 INetCfgComponent_fnGetBindName
,
681 INetCfgComponent_fnGetDeviceStatus
,
682 INetCfgComponent_fnOpenParamKey
,
683 INetCfgComponent_fnRaisePropertyUi
688 INetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
690 INetCfgComponentImpl
*This
;
695 This
= (INetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (INetCfgComponentImpl
));
697 return E_OUTOFMEMORY
;
700 This
->lpVtbl
= (const INetCfgComponent
*)&vt_NetCfgComponent
;
701 This
->lpVtblComponentBindings
= (const INetCfgComponentBindings
*)&vt_NetCfgComponentBindings
;
702 This
->pProperty
= NULL
;
706 if (!SUCCEEDED (INetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
708 INetCfgComponent_Release((INetCfg
*)This
);
709 return E_NOINTERFACE
;
712 INetCfgComponent_Release((INetCfgComponent
*)This
);
717 /***************************************************************
718 * IEnumNetCfgComponent
723 IEnumNetCfgComponent_fnQueryInterface(
724 IEnumNetCfgComponent
* iface
,
728 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
731 if (IsEqualIID (iid
, &IID_IUnknown
) ||
732 IsEqualIID (iid
, &IID_IEnumNetCfgComponent
))
735 INetCfg_AddRef(iface
);
739 return E_NOINTERFACE
;
745 IEnumNetCfgComponent_fnAddRef(
746 IEnumNetCfgComponent
* iface
)
748 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
749 ULONG refCount
= InterlockedIncrement(&This
->ref
);
756 IEnumNetCfgComponent_fnRelease(
757 IEnumNetCfgComponent
* iface
)
759 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
760 ULONG refCount
= InterlockedDecrement(&This
->ref
);
767 IEnumNetCfgComponent_fnNext(
768 IEnumNetCfgComponent
* iface
,
770 INetCfgComponent
**rgelt
,
774 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
776 if (!iface
|| !rgelt
)
785 hr
= INetCfgComponent_Constructor (NULL
, &IID_INetCfgComponent
, (LPVOID
*)rgelt
, This
->pCurrent
, This
->pNCfg
);
788 This
->pCurrent
= This
->pCurrent
->pNext
;
797 IEnumNetCfgComponent_fnSkip(
798 IEnumNetCfgComponent
* iface
,
801 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
806 while(celt
-- > 0 && This
->pCurrent
)
807 This
->pCurrent
= This
->pCurrent
->pNext
;
817 IEnumNetCfgComponent_fnReset(
818 IEnumNetCfgComponent
* iface
)
820 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
822 This
->pCurrent
= This
->pHead
;
828 IEnumNetCfgComponent_fnClone(
829 IEnumNetCfgComponent
* iface
,
830 IEnumNetCfgComponent
**ppenum
)
835 static const IEnumNetCfgComponentVtbl vt_EnumNetCfgComponent
=
837 IEnumNetCfgComponent_fnQueryInterface
,
838 IEnumNetCfgComponent_fnAddRef
,
839 IEnumNetCfgComponent_fnRelease
,
840 IEnumNetCfgComponent_fnNext
,
841 IEnumNetCfgComponent_fnSkip
,
842 IEnumNetCfgComponent_fnReset
,
843 IEnumNetCfgComponent_fnClone
848 IEnumNetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
850 IEnumNetCfgComponentImpl
*This
;
855 This
= (IEnumNetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (IEnumNetCfgComponentImpl
));
857 return E_OUTOFMEMORY
;
860 This
->lpVtbl
= (const IEnumNetCfgComponent
*)&vt_EnumNetCfgComponent
;
861 This
->pCurrent
= pItem
;
865 if (!SUCCEEDED (IEnumNetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
867 IEnumNetCfgComponent_Release((INetCfg
*)This
);
868 return E_NOINTERFACE
;
871 IEnumNetCfgComponent_Release((IEnumNetCfgComponent
*)This
);