6 const INetCfgComponent
* lpVtbl
;
8 NetCfgComponentItem
* pItem
;
9 INetCfgComponentPropertyUi
* pProperty
;
11 }INetCfgComponentImpl
;
15 const IEnumNetCfgComponent
* lpVtbl
;
17 NetCfgComponentItem
* pCurrent
;
18 NetCfgComponentItem
* pHead
;
20 }IEnumNetCfgComponentImpl
;
24 INetCfgComponent_fnQueryInterface(
25 INetCfgComponent
* iface
,
29 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
32 if (IsEqualIID (iid
, &IID_IUnknown
) ||
33 IsEqualIID (iid
, &IID_INetCfgComponent
))
36 INetCfg_AddRef(iface
);
45 INetCfgComponent_fnAddRef(
46 INetCfgComponent
* iface
)
48 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
49 ULONG refCount
= InterlockedIncrement(&This
->ref
);
56 INetCfgComponent_fnRelease(
57 INetCfgComponent
* iface
)
59 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
60 ULONG refCount
= InterlockedDecrement(&This
->ref
);
71 INetCfgComponent_fnGetDisplayName(
72 INetCfgComponent
* iface
,
73 LPWSTR
* ppszwDisplayName
)
77 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
79 if (This
== NULL
|| ppszwDisplayName
== NULL
)
82 if (This
->pItem
->szDisplayName
)
83 Length
= wcslen(This
->pItem
->szDisplayName
)+1;
87 szName
= CoTaskMemAlloc(Length
* sizeof(WCHAR
));
92 wcscpy(szName
, This
->pItem
->szDisplayName
);
96 *ppszwDisplayName
= szName
;
103 INetCfgComponent_fnSetDisplayName(
104 INetCfgComponent
* iface
,
105 LPCWSTR ppszwDisplayName
)
108 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
110 if (This
== NULL
|| ppszwDisplayName
== NULL
)
113 /* setting name is only supported for network cards */
114 if (!IsEqualGUID(&This
->pItem
->ClassGUID
, &GUID_DEVCLASS_NET
))
118 /// check for invalid characters
119 /// check for write lock
121 szName
= CoTaskMemAlloc((wcslen(ppszwDisplayName
)+1) * sizeof(WCHAR
));
123 return E_OUTOFMEMORY
;
125 wcscpy(szName
, ppszwDisplayName
);
126 CoTaskMemFree(This
->pItem
->szDisplayName
);
127 This
->pItem
->szDisplayName
= szName
;
128 This
->pItem
->bChanged
= TRUE
;
135 INetCfgComponent_fnGetHelpText(
136 INetCfgComponent
* iface
,
137 LPWSTR
* ppszwHelpText
)
141 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
143 if (This
== NULL
|| ppszwHelpText
== NULL
)
146 if (This
->pItem
->szHelpText
)
147 Length
= wcslen(This
->pItem
->szHelpText
)+1;
151 szHelp
= CoTaskMemAlloc(Length
* sizeof(WCHAR
));
153 return E_OUTOFMEMORY
;
156 wcscpy(szHelp
, This
->pItem
->szHelpText
);
160 *ppszwHelpText
= szHelp
;
167 INetCfgComponent_fnGetId(
168 INetCfgComponent
* iface
,
172 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
174 if (This
== NULL
|| ppszwId
== NULL
)
177 szId
= CoTaskMemAlloc((wcslen(This
->pItem
->szId
)+1) * sizeof(WCHAR
));
179 return E_OUTOFMEMORY
;
181 wcscpy(szId
, This
->pItem
->szId
);
189 INetCfgComponent_fnGetCharacteristics(
190 INetCfgComponent
* iface
,
191 DWORD
* pdwCharacteristics
)
193 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
195 if (This
== NULL
|| pdwCharacteristics
== NULL
)
198 *pdwCharacteristics
= This
->pItem
->dwCharacteristics
;
205 INetCfgComponent_fnGetInstanceGuid(
206 INetCfgComponent
* iface
,
209 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
211 if (This
== NULL
|| pGuid
== NULL
)
214 CopyMemory(pGuid
, &This
->pItem
->InstanceId
, sizeof(GUID
));
220 INetCfgComponent_fnGetPnpDevNodeId(
221 INetCfgComponent
* iface
,
222 LPWSTR
* ppszwDevNodeId
)
225 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
227 if (This
== NULL
|| ppszwDevNodeId
== NULL
)
230 if (!IsEqualGUID(&GUID_DEVCLASS_NET
, &This
->pItem
->ClassGUID
))
233 szNode
= CoTaskMemAlloc((wcslen(This
->pItem
->szNodeId
)+1) * sizeof(WCHAR
));
235 return E_OUTOFMEMORY
;
237 wcscpy(szNode
, This
->pItem
->szNodeId
);
238 *ppszwDevNodeId
= szNode
;
244 INetCfgComponent_fnGetClassGuid(
245 INetCfgComponent
* iface
,
248 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
250 if (This
== NULL
|| pGuid
== NULL
)
253 CopyMemory(pGuid
, &This
->pItem
->ClassGUID
, sizeof(GUID
));
259 INetCfgComponent_fnGetBindName(
260 INetCfgComponent
* iface
,
261 LPWSTR
* ppszwBindName
)
264 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
266 if (This
== NULL
|| ppszwBindName
== NULL
)
269 szBind
= CoTaskMemAlloc((wcslen(This
->pItem
->szBindName
)+1) * sizeof(WCHAR
));
271 return E_OUTOFMEMORY
;
273 wcscpy(szBind
, This
->pItem
->szBindName
);
274 *ppszwBindName
= szBind
;
281 INetCfgComponent_fnGetDeviceStatus(
282 INetCfgComponent
* iface
,
285 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
287 if (This
== NULL
|| pStatus
== NULL
)
290 if (!IsEqualGUID(&GUID_DEVCLASS_NET
, &This
->pItem
->ClassGUID
))
293 *pStatus
= This
->pItem
->Status
;
300 INetCfgComponent_fnOpenParamKey(
301 INetCfgComponent
* iface
,
304 WCHAR szBuffer
[200] = L
"SYSTEM\\CurrentControlSet\\Services\\";
305 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
307 if (This
== NULL
|| phkey
== NULL
)
310 wcscat(szBuffer
, This
->pItem
->szBindName
);
311 wcscat(szBuffer
, L
"\\Parameters");
313 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szBuffer
, 0, KEY_READ
| KEY_WRITE
, phkey
) == ERROR_SUCCESS
)
321 CreateNotificationObject(
322 INetCfgComponentImpl
* This
,
323 INetCfgComponent
* iface
,
328 DWORD dwSize
, dwType
;
329 GUID CLSID_NotifyObject
;
331 INetCfgComponentPropertyUi
* pNCCPU
;
332 INetCfgComponentControl
* pNCCC
;
336 //CLSID InstanceGUID;
338 wcscpy(szName
,L
"SYSTEM\\CurrentControlSet\\Control\\Network\\");
340 /* get the Class GUID */
341 hr
= INetCfgComponent_GetClassGuid(iface
, &ClassGUID
);
345 hr
= StringFromCLSID(&ClassGUID
, &pStr
);
349 wcscat(szName
, pStr
);
351 wcscat(szName
, L
"\\");
353 /* get the Instance GUID */
355 hr
= INetCfgComponent_GetInstanceGuid(iface
, &InstanceGUID
);
359 hr
= StringFromCLSID(&InstanceGUID
, &pStr
);
363 wcscat(szName
, pStr
);
366 // HACK HACK HACK HACK HACK
367 wcscat(szName
, L
"{RandomProtocolGUID_TCPIP}");
370 wcscat(szName
, L
"\\NDI");
372 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szName
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
375 dwSize
= sizeof(szName
);
376 lRet
= RegQueryValueExW(hKey
, L
"ClsID", NULL
, &dwType
, (LPBYTE
)szName
, &dwSize
);
379 if (lRet
!= ERROR_SUCCESS
&& dwType
!= REG_SZ
)
382 hr
= CLSIDFromString(szName
, &CLSID_NotifyObject
);
386 hr
= CoCreateInstance(&CLSID_NotifyObject
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetCfgComponentPropertyUi
, (LPVOID
*)&pNCCPU
);
390 hr
= INetCfgComponentPropertyUi_QueryInterface(pNCCPU
, &IID_INetCfgComponentControl
, (LPVOID
*)&pNCCC
);
393 INetCfgComponentPropertyUi_Release(pNCCPU
);
397 hr
= INetCfgComponentPropertyUi_QueryPropertyUi(pNCCPU
, pUnk
);
400 INetCfgComponentPropertyUi_Release(pNCCPU
);
404 hr
= INetCfgComponentControl_Initialize(pNCCC
, iface
, This
->pNCfg
, FALSE
);
407 INetCfgComponentControl_Release(pNCCC
);
408 INetCfgComponentPropertyUi_Release(pNCCPU
);
412 hr
= INetCfgComponentPropertyUi_SetContext(pNCCPU
, pUnk
);
415 INetCfgComponentPropertyUi_Release(pNCCPU
);
418 This
->pProperty
= pNCCPU
;
419 This
->pItem
->pNCCC
= pNCCC
;
426 INetCfgComponent_fnRaisePropertyUi(
427 INetCfgComponent
* iface
,
435 PROPSHEETHEADERW pinfo
;
436 HPROPSHEETPAGE
* hppages
;
438 INetCfgComponentImpl
* This
= (INetCfgComponentImpl
*)iface
;
440 if (!This
->pProperty
)
442 hr
= CreateNotificationObject(This
,iface
, pUnk
);
447 if (dwFlags
== NCRP_QUERY_PROPERTY_UI
)
453 hr
= INetCfgComponentPropertyUi_MergePropPages(This
->pProperty
, &dwDefPages
, (BYTE
**)&hppages
, &Pages
, hwndParent
, NULL
);
454 if (FAILED(hr
) || !Pages
)
458 ZeroMemory(&pinfo
, sizeof(PROPSHEETHEADERW
));
459 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
460 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
| PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
461 pinfo
.u3
.phpage
= hppages
;
462 pinfo
.hwndParent
= hwndParent
;
463 pinfo
.nPages
= Pages
;
464 pinfo
.pszCaption
= This
->pItem
->szDisplayName
;
466 iResult
= PropertySheetW(&pinfo
);
467 CoTaskMemFree(hppages
);
470 /* indicate that settings should be stored */
471 This
->pItem
->bChanged
= TRUE
;
476 static const INetCfgComponentVtbl vt_NetCfgComponent
=
478 INetCfgComponent_fnQueryInterface
,
479 INetCfgComponent_fnAddRef
,
480 INetCfgComponent_fnRelease
,
481 INetCfgComponent_fnGetDisplayName
,
482 INetCfgComponent_fnSetDisplayName
,
483 INetCfgComponent_fnGetHelpText
,
484 INetCfgComponent_fnGetId
,
485 INetCfgComponent_fnGetCharacteristics
,
486 INetCfgComponent_fnGetInstanceGuid
,
487 INetCfgComponent_fnGetPnpDevNodeId
,
488 INetCfgComponent_fnGetClassGuid
,
489 INetCfgComponent_fnGetBindName
,
490 INetCfgComponent_fnGetDeviceStatus
,
491 INetCfgComponent_fnOpenParamKey
,
492 INetCfgComponent_fnRaisePropertyUi
497 INetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
499 INetCfgComponentImpl
*This
;
504 This
= (INetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (INetCfgComponentImpl
));
506 return E_OUTOFMEMORY
;
509 This
->lpVtbl
= (const INetCfgComponent
*)&vt_NetCfgComponent
;
510 This
->pProperty
= NULL
;
514 if (!SUCCEEDED (INetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
516 INetCfgComponent_Release((INetCfg
*)This
);
517 return E_NOINTERFACE
;
520 INetCfgComponent_Release((INetCfgComponent
*)This
);
525 /***************************************************************
526 * IEnumNetCfgComponent
531 IEnumNetCfgComponent_fnQueryInterface(
532 IEnumNetCfgComponent
* iface
,
536 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
539 if (IsEqualIID (iid
, &IID_IUnknown
) ||
540 IsEqualIID (iid
, &IID_IEnumNetCfgComponent
))
543 INetCfg_AddRef(iface
);
547 return E_NOINTERFACE
;
553 IEnumNetCfgComponent_fnAddRef(
554 IEnumNetCfgComponent
* iface
)
556 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
557 ULONG refCount
= InterlockedIncrement(&This
->ref
);
564 IEnumNetCfgComponent_fnRelease(
565 IEnumNetCfgComponent
* iface
)
567 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
568 ULONG refCount
= InterlockedDecrement(&This
->ref
);
575 IEnumNetCfgComponent_fnNext(
576 IEnumNetCfgComponent
* iface
,
578 INetCfgComponent
**rgelt
,
582 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
584 if (!iface
|| !rgelt
)
593 hr
= INetCfgComponent_Constructor (NULL
, &IID_INetCfgComponent
, (LPVOID
*)rgelt
, This
->pCurrent
, This
->pNCfg
);
596 This
->pCurrent
= This
->pCurrent
->pNext
;
605 IEnumNetCfgComponent_fnSkip(
606 IEnumNetCfgComponent
* iface
,
609 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
614 while(celt
-- > 0 && This
->pCurrent
)
615 This
->pCurrent
= This
->pCurrent
->pNext
;
625 IEnumNetCfgComponent_fnReset(
626 IEnumNetCfgComponent
* iface
)
628 IEnumNetCfgComponentImpl
* This
= (IEnumNetCfgComponentImpl
*)iface
;
630 This
->pCurrent
= This
->pHead
;
636 IEnumNetCfgComponent_fnClone(
637 IEnumNetCfgComponent
* iface
,
638 IEnumNetCfgComponent
**ppenum
)
643 static const IEnumNetCfgComponentVtbl vt_EnumNetCfgComponent
=
645 IEnumNetCfgComponent_fnQueryInterface
,
646 IEnumNetCfgComponent_fnAddRef
,
647 IEnumNetCfgComponent_fnRelease
,
648 IEnumNetCfgComponent_fnNext
,
649 IEnumNetCfgComponent_fnSkip
,
650 IEnumNetCfgComponent_fnReset
,
651 IEnumNetCfgComponent_fnClone
656 IEnumNetCfgComponent_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
, NetCfgComponentItem
* pItem
, INetCfg
* pNCfg
)
658 IEnumNetCfgComponentImpl
*This
;
663 This
= (IEnumNetCfgComponentImpl
*) CoTaskMemAlloc(sizeof (IEnumNetCfgComponentImpl
));
665 return E_OUTOFMEMORY
;
668 This
->lpVtbl
= (const IEnumNetCfgComponent
*)&vt_EnumNetCfgComponent
;
669 This
->pCurrent
= pItem
;
673 if (!SUCCEEDED (IEnumNetCfgComponent_QueryInterface ((INetCfgComponent
*)This
, riid
, ppv
)))
675 IEnumNetCfgComponent_Release((INetCfg
*)This
);
676 return E_NOINTERFACE
;
679 IEnumNetCfgComponent_Release((IEnumNetCfgComponent
*)This
);