5 const INetCfgComponent
* lpVtbl
;
7 NetCfgComponentItem
* pItem
;
8 INetCfgComponentPropertyUi
* pProperty
;
10 }INetCfgComponentImpl
;
14 const IEnumNetCfgComponent
* lpVtbl
;
16 NetCfgComponentItem
* pCurrent
;
17 NetCfgComponentItem
* pHead
;
19 }IEnumNetCfgComponentImpl
;
23 INetCfgComponent_fnQueryInterface(
24 INetCfgComponent
* iface
,
28 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
31 if (IsEqualIID (iid
, &IID_IUnknown
) ||
32 IsEqualIID (iid
, &IID_INetCfgComponent
))
35 INetCfg_AddRef(iface
);
44 INetCfgComponent_fnAddRef(
45 INetCfgComponent
* iface
)
47 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
48 ULONG refCount
= InterlockedIncrement(&This
->ref
);
55 INetCfgComponent_fnRelease(
56 INetCfgComponent
* iface
)
58 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
59 ULONG refCount
= InterlockedDecrement(&This
->ref
);
70 INetCfgComponent_fnGetDisplayName(
71 INetCfgComponent
* iface
,
72 LPWSTR
* ppszwDisplayName
)
76 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
78 if (This
== NULL
|| ppszwDisplayName
== NULL
)
81 if (This
->pItem
->szDisplayName
)
82 Length
= wcslen(This
->pItem
->szDisplayName
)+1;
86 szName
= CoTaskMemAlloc(Length
* sizeof(WCHAR
));
91 wcscpy(szName
, This
->pItem
->szDisplayName
);
95 *ppszwDisplayName
= szName
;
102 INetCfgComponent_fnSetDisplayName(
103 INetCfgComponent
* iface
,
104 LPCWSTR ppszwDisplayName
)
107 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
109 if (This
== NULL
|| ppszwDisplayName
== NULL
)
112 /* setting name is only supported for network cards */
113 if (!IsEqualGUID(&This
->pItem
->ClassGUID
, &GUID_DEVCLASS_NET
))
117 /// check for invalid characters
118 /// check for write lock
120 szName
= CoTaskMemAlloc((wcslen(ppszwDisplayName
)+1) * sizeof(WCHAR
));
122 return E_OUTOFMEMORY
;
124 wcscpy(szName
, ppszwDisplayName
);
125 CoTaskMemFree(This
->pItem
->szDisplayName
);
126 This
->pItem
->szDisplayName
= szName
;
127 This
->pItem
->bChanged
= TRUE
;
134 INetCfgComponent_fnGetHelpText(
135 INetCfgComponent
* iface
,
136 LPWSTR
* ppszwHelpText
)
140 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
142 if (This
== NULL
|| ppszwHelpText
== NULL
)
145 if (This
->pItem
->szHelpText
)
146 Length
= wcslen(This
->pItem
->szHelpText
)+1;
150 szHelp
= CoTaskMemAlloc(Length
* sizeof(WCHAR
));
152 return E_OUTOFMEMORY
;
155 wcscpy(szHelp
, This
->pItem
->szHelpText
);
159 *ppszwHelpText
= szHelp
;
166 INetCfgComponent_fnGetId(
167 INetCfgComponent
* iface
,
171 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
173 if (This
== NULL
|| ppszwId
== NULL
)
176 szId
= CoTaskMemAlloc((wcslen(This
->pItem
->szId
)+1) * sizeof(WCHAR
));
178 return E_OUTOFMEMORY
;
180 wcscpy(szId
, This
->pItem
->szId
);
188 INetCfgComponent_fnGetCharacteristics(
189 INetCfgComponent
* iface
,
190 DWORD
* pdwCharacteristics
)
192 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
194 if (This
== NULL
|| pdwCharacteristics
== NULL
)
197 *pdwCharacteristics
= This
->pItem
->dwCharacteristics
;
204 INetCfgComponent_fnGetInstanceGuid(
205 INetCfgComponent
* iface
,
208 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
210 if (This
== NULL
|| pGuid
== NULL
)
213 CopyMemory(pGuid
, &This
->pItem
->InstanceId
, sizeof(GUID
));
219 INetCfgComponent_fnGetPnpDevNodeId(
220 INetCfgComponent
* iface
,
221 LPWSTR
* ppszwDevNodeId
)
224 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
226 if (This
== NULL
|| ppszwDevNodeId
== NULL
)
229 if (!IsEqualGUID(&GUID_DEVCLASS_NET
, &This
->pItem
->ClassGUID
))
232 szNode
= CoTaskMemAlloc((wcslen(This
->pItem
->szNodeId
)+1) * sizeof(WCHAR
));
234 return E_OUTOFMEMORY
;
236 wcscpy(szNode
, This
->pItem
->szNodeId
);
237 *ppszwDevNodeId
= szNode
;
243 INetCfgComponent_fnGetClassGuid(
244 INetCfgComponent
* iface
,
247 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
249 if (This
== NULL
|| pGuid
== NULL
)
252 CopyMemory(pGuid
, &This
->pItem
->ClassGUID
, sizeof(GUID
));
258 INetCfgComponent_fnGetBindName(
259 INetCfgComponent
* iface
,
260 LPWSTR
* ppszwBindName
)
263 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
265 if (This
== NULL
|| ppszwBindName
== NULL
)
268 szBind
= CoTaskMemAlloc((wcslen(This
->pItem
->szBindName
)+1) * sizeof(WCHAR
));
270 return E_OUTOFMEMORY
;
272 wcscpy(szBind
, This
->pItem
->szBindName
);
273 *ppszwBindName
= szBind
;
280 INetCfgComponent_fnGetDeviceStatus(
281 INetCfgComponent
* iface
,
284 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
286 if (This
== NULL
|| pStatus
== NULL
)
289 if (!IsEqualGUID(&GUID_DEVCLASS_NET
, &This
->pItem
->ClassGUID
))
292 *pStatus
= This
->pItem
->Status
;
299 INetCfgComponent_fnOpenParamKey(
300 INetCfgComponent
* iface
,
303 WCHAR szBuffer
[200] = L
"SYSTEM\\CurrentControlSet\\Services\\";
304 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
306 if (This
== NULL
|| phkey
== NULL
)
309 wcscat(szBuffer
, This
->pItem
->szBindName
);
310 wcscat(szBuffer
, L
"\\Parameters");
312 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szBuffer
, 0, KEY_READ
| KEY_WRITE
, phkey
) == ERROR_SUCCESS
)
320 CreateNotificationObject(
321 INetCfgComponentImpl
* This
,
322 INetCfgComponent
* iface
,
327 DWORD dwSize
, dwType
;
328 GUID CLSID_NotifyObject
;
330 INetCfgComponentPropertyUi
* pNCCPU
;
331 INetCfgComponentControl
* pNCCC
;
335 //CLSID InstanceGUID;
337 wcscpy(szName
,L
"SYSTEM\\CurrentControlSet\\Control\\Network\\");
339 /* get the Class GUID */
340 hr
= INetCfgComponent_GetClassGuid(iface
, &ClassGUID
);
344 hr
= StringFromCLSID(&ClassGUID
, &pStr
);
348 wcscat(szName
, pStr
);
350 wcscat(szName
, L
"\\");
352 /* get the Instance GUID */
354 hr
= INetCfgComponent_GetInstanceGuid(iface
, &InstanceGUID
);
358 hr
= StringFromCLSID(&InstanceGUID
, &pStr
);
362 wcscat(szName
, pStr
);
365 // HACK HACK HACK HACK HACK
366 wcscat(szName
, L
"{RandomProtocolGUID_TCPIP}");
369 wcscat(szName
, L
"\\NDI");
371 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szName
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
374 dwSize
= sizeof(szName
);
375 lRet
= RegQueryValueExW(hKey
, L
"ClsID", NULL
, &dwType
, (LPBYTE
)szName
, &dwSize
);
378 if (lRet
!= ERROR_SUCCESS
&& dwType
!= REG_SZ
)
381 hr
= CLSIDFromString(szName
, &CLSID_NotifyObject
);
385 hr
= CoCreateInstance(&CLSID_NotifyObject
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetCfgComponentPropertyUi
, (LPVOID
*)&pNCCPU
);
389 hr
= INetCfgComponentPropertyUi_QueryInterface(pNCCPU
, &IID_INetCfgComponentControl
, (LPVOID
*)&pNCCC
);
392 INetCfgComponentPropertyUi_Release(pNCCPU
);
396 hr
= INetCfgComponentPropertyUi_QueryPropertyUi(pNCCPU
, pUnk
);
399 INetCfgComponentPropertyUi_Release(pNCCPU
);
403 hr
= INetCfgComponentControl_Initialize(pNCCC
, iface
, This
->pNCfg
, FALSE
);
406 INetCfgComponentControl_Release(pNCCC
);
407 INetCfgComponentPropertyUi_Release(pNCCPU
);
411 hr
= INetCfgComponentPropertyUi_SetContext(pNCCPU
, pUnk
);
414 INetCfgComponentPropertyUi_Release(pNCCPU
);
417 This
->pProperty
= pNCCPU
;
418 This
->pItem
->pNCCC
= pNCCC
;
425 INetCfgComponent_fnRaisePropertyUi(
426 INetCfgComponent
* iface
,
434 PROPSHEETHEADERW pinfo
;
435 HPROPSHEETPAGE
* hppages
;
437 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
439 if (!This
->pProperty
)
441 hr
= CreateNotificationObject(This
,iface
, pUnk
);
446 if (dwFlags
== NCRP_QUERY_PROPERTY_UI
)
452 hr
= INetCfgComponentPropertyUi_MergePropPages(This
->pProperty
, &dwDefPages
, (BYTE
**)&hppages
, &Pages
, hwndParent
, NULL
);
453 if (FAILED(hr
) || !Pages
)
457 ZeroMemory(&pinfo
, sizeof(PROPSHEETHEADERW
));
458 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
459 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
| PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
460 pinfo
.u3
.phpage
= hppages
;
461 pinfo
.hwndParent
= hwndParent
;
462 pinfo
.nPages
= Pages
;
463 pinfo
.pszCaption
= This
->pItem
->szDisplayName
;
465 iResult
= PropertySheetW(&pinfo
);
466 CoTaskMemFree(hppages
);
469 /* indicate that settings should be stored */
470 This
->pItem
->bChanged
= TRUE
;
475 static const INetCfgComponentVtbl vt_NetCfgComponent
=
477 INetCfgComponent_fnQueryInterface
,
478 INetCfgComponent_fnAddRef
,
479 INetCfgComponent_fnRelease
,
480 INetCfgComponent_fnGetDisplayName
,
481 INetCfgComponent_fnSetDisplayName
,
482 INetCfgComponent_fnGetHelpText
,
483 INetCfgComponent_fnGetId
,
484 INetCfgComponent_fnGetCharacteristics
,
485 INetCfgComponent_fnGetInstanceGuid
,
486 INetCfgComponent_fnGetPnpDevNodeId
,
487 INetCfgComponent_fnGetClassGuid
,
488 INetCfgComponent_fnGetBindName
,
489 INetCfgComponent_fnGetDeviceStatus
,
490 INetCfgComponent_fnOpenParamKey
,
491 INetCfgComponent_fnRaisePropertyUi
496 INetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
498 INetCfgComponentImpl
*This
;
503 This
= (INetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (INetCfgComponentImpl
));
505 return E_OUTOFMEMORY
;
508 This
->lpVtbl
= (const INetCfgComponent
*)&vt_NetCfgComponent
;
509 This
->pProperty
= NULL
;
513 if (!SUCCEEDED (INetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
515 INetCfgComponent_Release((INetCfg
*)This
);
516 return E_NOINTERFACE
;
519 INetCfgComponent_Release((INetCfgComponent
*)This
);
524 /***************************************************************
525 * IEnumNetCfgComponent
530 IEnumNetCfgComponent_fnQueryInterface(
531 IEnumNetCfgComponent
* iface
,
535 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
538 if (IsEqualIID (iid
, &IID_IUnknown
) ||
539 IsEqualIID (iid
, &IID_IEnumNetCfgComponent
))
542 INetCfg_AddRef(iface
);
546 return E_NOINTERFACE
;
552 IEnumNetCfgComponent_fnAddRef(
553 IEnumNetCfgComponent
* iface
)
555 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
556 ULONG refCount
= InterlockedIncrement(&This
->ref
);
563 IEnumNetCfgComponent_fnRelease(
564 IEnumNetCfgComponent
* iface
)
566 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
567 ULONG refCount
= InterlockedDecrement(&This
->ref
);
574 IEnumNetCfgComponent_fnNext(
575 IEnumNetCfgComponent
* iface
,
577 INetCfgComponent
**rgelt
,
581 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
583 if (!iface
|| !rgelt
)
592 hr
= INetCfgComponent_Constructor (NULL
, &IID_INetCfgComponent
, (LPVOID
*)rgelt
, This
->pCurrent
, This
->pNCfg
);
595 This
->pCurrent
= This
->pCurrent
->pNext
;
604 IEnumNetCfgComponent_fnSkip(
605 IEnumNetCfgComponent
* iface
,
608 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
613 while(celt
-- > 0 && This
->pCurrent
)
614 This
->pCurrent
= This
->pCurrent
->pNext
;
624 IEnumNetCfgComponent_fnReset(
625 IEnumNetCfgComponent
* iface
)
627 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
629 This
->pCurrent
= This
->pHead
;
635 IEnumNetCfgComponent_fnClone(
636 IEnumNetCfgComponent
* iface
,
637 IEnumNetCfgComponent
**ppenum
)
642 static const IEnumNetCfgComponentVtbl vt_EnumNetCfgComponent
=
644 IEnumNetCfgComponent_fnQueryInterface
,
645 IEnumNetCfgComponent_fnAddRef
,
646 IEnumNetCfgComponent_fnRelease
,
647 IEnumNetCfgComponent_fnNext
,
648 IEnumNetCfgComponent_fnSkip
,
649 IEnumNetCfgComponent_fnReset
,
650 IEnumNetCfgComponent_fnClone
655 IEnumNetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
657 IEnumNetCfgComponentImpl
*This
;
662 This
= (IEnumNetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (IEnumNetCfgComponentImpl
));
664 return E_OUTOFMEMORY
;
667 This
->lpVtbl
= (const IEnumNetCfgComponent
*)&vt_EnumNetCfgComponent
;
668 This
->pCurrent
= pItem
;
672 if (!SUCCEEDED (IEnumNetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
674 IEnumNetCfgComponent_Release((INetCfg
*)This
);
675 return E_NOINTERFACE
;
678 IEnumNetCfgComponent_Release((IEnumNetCfgComponent
*)This
);