6 const INetCfgComponent
* lpVtbl
;
8 NetCfgComponentItem
* pItem
;
9 INetCfgComponentPropertyUi
* pProperty
;
10 INetCfgComponentControl
* pNCCC
;
12 }INetCfgComponentImpl
;
16 const IEnumNetCfgComponent
* lpVtbl
;
18 NetCfgComponentItem
* pCurrent
;
19 NetCfgComponentItem
* pHead
;
21 }IEnumNetCfgComponentImpl
;
27 INetCfgComponent_fnQueryInterface(
28 INetCfgComponent
* iface
,
32 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
35 if (IsEqualIID (iid
, &IID_IUnknown
) ||
36 IsEqualIID (iid
, &IID_INetCfgComponent
))
39 INetCfg_AddRef(iface
);
49 INetCfgComponent_fnAddRef(
50 INetCfgComponent
* iface
)
52 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
53 ULONG refCount
= InterlockedIncrement(&This
->ref
);
60 INetCfgComponent_fnRelease(
61 INetCfgComponent
* iface
)
63 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
64 ULONG refCount
= InterlockedDecrement(&This
->ref
);
75 INetCfgComponent_fnGetDisplayName(
76 INetCfgComponent
* iface
,
77 LPWSTR
* ppszwDisplayName
)
81 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
83 if (This
== NULL
|| ppszwDisplayName
== NULL
)
86 if (This
->pItem
->szDisplayName
)
87 Length
= wcslen(This
->pItem
->szDisplayName
)+1;
91 szName
= CoTaskMemAlloc(Length
* sizeof(WCHAR
));
96 wcscpy(szName
, This
->pItem
->szDisplayName
);
100 *ppszwDisplayName
= szName
;
107 INetCfgComponent_fnSetDisplayName(
108 INetCfgComponent
* iface
,
109 LPCWSTR ppszwDisplayName
)
112 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
114 if (This
== NULL
|| ppszwDisplayName
== NULL
)
117 /* setting name is only supported for network cards */
118 if (!IsEqualGUID(&This
->pItem
->ClassGUID
, &GUID_DEVCLASS_NET
))
122 /// check for invalid characters
123 /// check for write lock
125 szName
= CoTaskMemAlloc((wcslen(ppszwDisplayName
)+1) * sizeof(WCHAR
));
127 return E_OUTOFMEMORY
;
129 wcscpy(szName
, ppszwDisplayName
);
130 CoTaskMemFree(This
->pItem
->szDisplayName
);
131 This
->pItem
->szDisplayName
= szName
;
132 This
->pItem
->bChanged
= TRUE
;
139 INetCfgComponent_fnGetHelpText(
140 INetCfgComponent
* iface
,
141 LPWSTR
* ppszwHelpText
)
145 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
147 if (This
== NULL
|| ppszwHelpText
== NULL
)
150 if (This
->pItem
->szHelpText
)
151 Length
= wcslen(This
->pItem
->szHelpText
)+1;
155 szHelp
= CoTaskMemAlloc(Length
* sizeof(WCHAR
));
157 return E_OUTOFMEMORY
;
160 wcscpy(szHelp
, This
->pItem
->szHelpText
);
164 *ppszwHelpText
= szHelp
;
171 INetCfgComponent_fnGetId(
172 INetCfgComponent
* iface
,
176 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
178 if (This
== NULL
|| ppszwId
== NULL
)
181 szId
= CoTaskMemAlloc((wcslen(This
->pItem
->szId
)+1) * sizeof(WCHAR
));
183 return E_OUTOFMEMORY
;
185 wcscpy(szId
, This
->pItem
->szId
);
193 INetCfgComponent_fnGetCharacteristics(
194 INetCfgComponent
* iface
,
195 DWORD
* pdwCharacteristics
)
197 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
199 if (This
== NULL
|| pdwCharacteristics
== NULL
)
202 *pdwCharacteristics
= This
->pItem
->dwCharacteristics
;
209 INetCfgComponent_fnGetInstanceGuid(
210 INetCfgComponent
* iface
,
213 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
215 if (This
== NULL
|| pGuid
== NULL
)
218 CopyMemory(pGuid
, &This
->pItem
->InstanceId
, sizeof(GUID
));
224 INetCfgComponent_fnGetPnpDevNodeId(
225 INetCfgComponent
* iface
,
226 LPWSTR
* ppszwDevNodeId
)
229 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
231 if (This
== NULL
|| ppszwDevNodeId
== NULL
)
234 if (!IsEqualGUID(&GUID_DEVCLASS_NET
, &This
->pItem
->ClassGUID
))
237 szNode
= CoTaskMemAlloc((wcslen(This
->pItem
->szNodeId
)+1) * sizeof(WCHAR
));
239 return E_OUTOFMEMORY
;
241 wcscpy(szNode
, This
->pItem
->szNodeId
);
242 *ppszwDevNodeId
= szNode
;
248 INetCfgComponent_fnGetClassGuid(
249 INetCfgComponent
* iface
,
252 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
254 if (This
== NULL
|| pGuid
== NULL
)
257 CopyMemory(pGuid
, &This
->pItem
->ClassGUID
, sizeof(GUID
));
263 INetCfgComponent_fnGetBindName(
264 INetCfgComponent
* iface
,
265 LPWSTR
* ppszwBindName
)
268 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
270 if (This
== NULL
|| ppszwBindName
== NULL
)
273 szBind
= CoTaskMemAlloc((wcslen(This
->pItem
->szBindName
)+1) * sizeof(WCHAR
));
275 return E_OUTOFMEMORY
;
277 wcscpy(szBind
, This
->pItem
->szBindName
);
278 *ppszwBindName
= szBind
;
285 INetCfgComponent_fnGetDeviceStatus(
286 INetCfgComponent
* iface
,
289 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
291 if (This
== NULL
|| pStatus
== NULL
)
294 if (!IsEqualGUID(&GUID_DEVCLASS_NET
, &This
->pItem
->ClassGUID
))
297 *pStatus
= This
->pItem
->Status
;
304 INetCfgComponent_fnOpenParamKey(
305 INetCfgComponent
* iface
,
308 WCHAR szBuffer
[200] = L
"SYSTEM\\CurrentControlSet\\Services\\";
309 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
311 if (This
== NULL
|| phkey
== NULL
)
314 wcscat(szBuffer
, This
->pItem
->szBindName
);
315 wcscat(szBuffer
, L
"\\Parameters");
317 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szBuffer
, 0, KEY_READ
| KEY_WRITE
, phkey
) == ERROR_SUCCESS
)
325 CreateNotificationObject(
326 INetCfgComponentImpl
* This
,
327 INetCfgComponent
* iface
,
332 DWORD dwSize
, dwType
;
333 GUID CLSID_NotifyObject
;
335 INetCfgComponentPropertyUi
* pNCCPU
;
336 INetCfgComponentControl
* pNCCC
;
340 //CLSID InstanceGUID;
342 wcscpy(szName
,L
"SYSTEM\\CurrentControlSet\\Control\\Network\\");
344 /* get the Class GUID */
345 hr
= INetCfgComponent_GetClassGuid(iface
, &ClassGUID
);
349 hr
= StringFromCLSID(&ClassGUID
, &pStr
);
353 wcscat(szName
, pStr
);
355 wcscat(szName
, L
"\\");
357 /* get the Instance GUID */
359 hr
= INetCfgComponent_GetInstanceGuid(iface
, &InstanceGUID
);
363 hr
= StringFromCLSID(&InstanceGUID
, &pStr
);
367 wcscat(szName
, pStr
);
370 // HACK HACK HACK HACK HACK
371 wcscat(szName
, L
"{RandomProtocolGUID_TCPIP}");
374 wcscat(szName
, L
"\\NDI");
376 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szName
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
379 dwSize
= sizeof(szName
);
380 lRet
= RegQueryValueExW(hKey
, L
"ClsID", NULL
, &dwType
, (LPBYTE
)szName
, &dwSize
);
383 if (lRet
!= ERROR_SUCCESS
&& dwType
!= REG_SZ
)
386 hr
= CLSIDFromString(szName
, &CLSID_NotifyObject
);
390 hr
= CoCreateInstance(&CLSID_NotifyObject
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetCfgComponentPropertyUi
, (LPVOID
*)&pNCCPU
);
394 hr
= INetCfgComponentPropertyUi_QueryInterface(pNCCPU
, &IID_INetCfgComponentControl
, (LPVOID
*)&pNCCC
);
397 INetCfgComponentPropertyUi_Release(pNCCPU
);
401 hr
= INetCfgComponentPropertyUi_QueryPropertyUi(pNCCPU
, pUnk
);
404 INetCfgComponentPropertyUi_Release(pNCCPU
);
408 hr
= INetCfgComponentControl_Initialize(pNCCC
, iface
, This
->pNCfg
, FALSE
);
411 INetCfgComponentControl_Release(pNCCC
);
412 INetCfgComponentPropertyUi_Release(pNCCPU
);
416 hr
= INetCfgComponentPropertyUi_SetContext(pNCCPU
, pUnk
);
419 INetCfgComponentPropertyUi_Release(pNCCPU
);
422 This
->pProperty
= pNCCPU
;
430 INetCfgComponent_fnRaisePropertyUi(
431 INetCfgComponent
* iface
,
439 PROPSHEETHEADERW pinfo
;
440 HPROPSHEETPAGE
* hppages
;
442 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
444 if (!This
->pProperty
)
446 hr
= CreateNotificationObject(This
,iface
, pUnk
);
449 if (dwFlags
== NCRP_QUERY_PROPERTY_UI
)
456 hr
= INetCfgComponentPropertyUi_MergePropPages(This
->pProperty
, &dwDefPages
, (BYTE
**)&hppages
, &Pages
, hwndParent
, NULL
);
457 if (FAILED(hr
) || !Pages
)
461 ZeroMemory(&pinfo
, sizeof(PROPSHEETHEADERW
));
462 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
463 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
| PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
464 pinfo
.u3
.phpage
= hppages
;
465 pinfo
.hwndParent
= hwndParent
;
466 pinfo
.nPages
= Pages
;
467 pinfo
.pszCaption
= This
->pItem
->szDisplayName
;
469 iResult
= PropertySheetW(&pinfo
);
471 CoTaskMemFree(hppages
);
475 INetCfgComponentControl_CancelChanges(This
->pNCCC
);
481 INetCfgComponentControl_ApplyRegistryChanges(This
->pNCCC
);
485 static const INetCfgComponentVtbl vt_NetCfgComponent
=
487 INetCfgComponent_fnQueryInterface
,
488 INetCfgComponent_fnAddRef
,
489 INetCfgComponent_fnRelease
,
490 INetCfgComponent_fnGetDisplayName
,
491 INetCfgComponent_fnSetDisplayName
,
492 INetCfgComponent_fnGetHelpText
,
493 INetCfgComponent_fnGetId
,
494 INetCfgComponent_fnGetCharacteristics
,
495 INetCfgComponent_fnGetInstanceGuid
,
496 INetCfgComponent_fnGetPnpDevNodeId
,
497 INetCfgComponent_fnGetClassGuid
,
498 INetCfgComponent_fnGetBindName
,
499 INetCfgComponent_fnGetDeviceStatus
,
500 INetCfgComponent_fnOpenParamKey
,
501 INetCfgComponent_fnRaisePropertyUi
506 INetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
508 INetCfgComponentImpl
*This
;
513 This
= (INetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (INetCfgComponentImpl
));
515 return E_OUTOFMEMORY
;
518 This
->lpVtbl
= (const INetCfgComponent
*)&vt_NetCfgComponent
;
519 This
->pProperty
= NULL
;
523 if (!SUCCEEDED (INetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
525 INetCfgComponent_Release((INetCfg
*)This
);
526 return E_NOINTERFACE
;
529 INetCfgComponent_Release((INetCfgComponent
*)This
);
534 /***************************************************************
535 * IEnumNetCfgComponent
540 IEnumNetCfgComponent_fnQueryInterface(
541 IEnumNetCfgComponent
* iface
,
545 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
548 if (IsEqualIID (iid
, &IID_IUnknown
) ||
549 IsEqualIID (iid
, &IID_IEnumNetCfgComponent
))
552 INetCfg_AddRef(iface
);
556 return E_NOINTERFACE
;
562 IEnumNetCfgComponent_fnAddRef(
563 IEnumNetCfgComponent
* iface
)
565 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
566 ULONG refCount
= InterlockedIncrement(&This
->ref
);
573 IEnumNetCfgComponent_fnRelease(
574 IEnumNetCfgComponent
* iface
)
576 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
577 ULONG refCount
= InterlockedDecrement(&This
->ref
);
584 IEnumNetCfgComponent_fnNext(
585 IEnumNetCfgComponent
* iface
,
587 INetCfgComponent
**rgelt
,
591 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
593 if (!iface
|| !rgelt
)
602 hr
= INetCfgComponent_Constructor (NULL
, &IID_INetCfgComponent
, (LPVOID
*)rgelt
, This
->pCurrent
, This
->pNCfg
);
605 This
->pCurrent
= This
->pCurrent
->pNext
;
614 IEnumNetCfgComponent_fnSkip(
615 IEnumNetCfgComponent
* iface
,
618 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
623 while(celt
-- > 0 && This
->pCurrent
)
624 This
->pCurrent
= This
->pCurrent
->pNext
;
634 IEnumNetCfgComponent_fnReset(
635 IEnumNetCfgComponent
* iface
)
637 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
639 This
->pCurrent
= This
->pHead
;
645 IEnumNetCfgComponent_fnClone(
646 IEnumNetCfgComponent
* iface
,
647 IEnumNetCfgComponent
**ppenum
)
652 static const IEnumNetCfgComponentVtbl vt_EnumNetCfgComponent
=
654 IEnumNetCfgComponent_fnQueryInterface
,
655 IEnumNetCfgComponent_fnAddRef
,
656 IEnumNetCfgComponent_fnRelease
,
657 IEnumNetCfgComponent_fnNext
,
658 IEnumNetCfgComponent_fnSkip
,
659 IEnumNetCfgComponent_fnReset
,
660 IEnumNetCfgComponent_fnClone
665 IEnumNetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
667 IEnumNetCfgComponentImpl
*This
;
672 This
= (IEnumNetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (IEnumNetCfgComponentImpl
));
674 return E_OUTOFMEMORY
;
677 This
->lpVtbl
= (const IEnumNetCfgComponent
*)&vt_EnumNetCfgComponent
;
678 This
->pCurrent
= pItem
;
682 if (!SUCCEEDED (IEnumNetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
684 IEnumNetCfgComponent_Release((INetCfg
*)This
);
685 return E_NOINTERFACE
;
688 IEnumNetCfgComponent_Release((IEnumNetCfgComponent
*)This
);