2 * Network Connections Shell Folder
4 * Copyright 2008 Johannes Anderwald <janderwald@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 WINE_DEFAULT_DEBUG_CHANNEL (shell
);
25 #define MAX_PROPERTY_SHEET_PAGE (10)
27 /***********************************************************************
28 * IShellFolder implementation
32 const IShellFolder2Vtbl
*lpVtbl
;
35 const IPersistFolder2Vtbl
*lpVtblPersistFolder2
;
36 const IShellExecuteHookWVtbl
*lpVtblShellExecuteHookW
;
37 //const IPersistIDListVtbl *lpVtblPersistIDList;
39 /* both paths are parsible from the desktop */
40 LPITEMIDLIST pidlRoot
; /* absolute pidl */
41 LPITEMIDLIST pidl
; /* enumerated pidl */
42 IOleCommandTarget
* lpOleCmd
;
43 } IGenericSFImpl
, *LPIGenericSFImpl
;
47 const IContextMenu3Vtbl
*lpVtblContextMenu
;
48 const IObjectWithSiteVtbl
*lpVtblObjectWithSite
;
49 const IQueryInfoVtbl
*lpVtblQueryInfo
;
50 const IExtractIconWVtbl
*lpVtblExtractIconW
;
54 IOleCommandTarget
* lpOleCmd
;
55 }IContextMenuImpl
, *LPIContextMenuImpl
;
57 static const shvheader NetConnectSFHeader
[] = {
58 {IDS_SHV_COLUMN_NAME
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 20},
59 {IDS_SHV_COLUMN_TYPE
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 8},
60 {IDS_SHV_COLUMN_STATE
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
61 {IDS_SHV_COLUMN_DEVNAME
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 12},
62 {IDS_SHV_COLUMN_PHONE
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
63 {IDS_SHV_COLUMN_OWNER
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 5}
66 #define NETCONNECTSHELLVIEWCOLUMNS 6
70 #define COLUMN_STATUS 2
71 #define COLUMN_DEVNAME 3
72 #define COLUMN_PHONE 4
73 #define COLUMN_OWNER 5
75 HRESULT
ShowNetConnectionStatus(IOleCommandTarget
* lpOleCmd
, INetConnection
* pNetConnect
, HWND hwnd
);
77 static const IContextMenu3Vtbl vt_ContextMenu3
;
78 static const IObjectWithSiteVtbl vt_ObjectWithSite
;
79 static const IQueryInfoVtbl vt_QueryInfo
;
80 static const IExtractIconWVtbl vt_ExtractIconW
;
82 static __inline LPIContextMenuImpl
impl_from_IExtractIcon(IExtractIconW
*iface
)
84 return (LPIContextMenuImpl
)((char *)iface
- FIELD_OFFSET(IContextMenuImpl
, lpVtblExtractIconW
));
88 static __inline LPIContextMenuImpl
impl_from_IObjectWithSite(IObjectWithSite
*iface
)
90 return (LPIContextMenuImpl
)((char *)iface
- FIELD_OFFSET(IContextMenuImpl
, lpVtblObjectWithSite
));
93 static __inline LPIGenericSFImpl
impl_from_IPersistFolder2(IPersistFolder2
*iface
)
95 return (LPIGenericSFImpl
)((char *)iface
- FIELD_OFFSET(IGenericSFImpl
, lpVtblPersistFolder2
));
98 static __inline LPIGenericSFImpl
impl_from_IShellExecuteHookW(IShellExecuteHookW
*iface
)
100 return (LPIGenericSFImpl
)((char *)iface
- FIELD_OFFSET(IGenericSFImpl
, lpVtblShellExecuteHookW
));
103 static __inline LPIContextMenuImpl
impl_from_IQueryInfo(IQueryInfo
*iface
)
105 return (LPIContextMenuImpl
)((char *)iface
- FIELD_OFFSET(IContextMenuImpl
, lpVtblQueryInfo
));
109 /**************************************************************************
110 * ISF_NetConnect_fnQueryInterface
113 * supports not IPersist/IPersistFolder
115 static HRESULT WINAPI
ISF_NetConnect_fnQueryInterface (IShellFolder2
*iface
, REFIID riid
, LPVOID
*ppvObj
)
117 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
121 if (IsEqualIID (riid
, &IID_IUnknown
) ||
122 IsEqualIID (riid
, &IID_IShellFolder
) ||
123 IsEqualIID (riid
, &IID_IShellFolder2
))
127 else if (IsEqualIID (riid
, &IID_IPersistFolder
) ||
128 IsEqualIID (riid
, &IID_IPersistFolder2
))
130 *ppvObj
= (LPVOID
*)&This
->lpVtblPersistFolder2
;
132 else if (IsEqualIID(riid
, &IID_IShellExecuteHookW
))
134 *ppvObj
= (LPVOID
*)&This
->lpVtblShellExecuteHookW
;
137 else if (IsEqualIID(riid
, &IID_IPersistIDList
))
139 //*ppvObj = (LPVOID *)&This->lpVtblPersistIDList;
144 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
149 * IID_IPersistFreeThreadedObject
150 * IID_IBrowserFrameOptions
151 * IID_IShellIconOverlay
156 return E_NOINTERFACE
;
159 static ULONG WINAPI
ISF_NetConnect_fnAddRef (IShellFolder2
* iface
)
161 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
162 ULONG refCount
= InterlockedIncrement(&This
->ref
);
167 static ULONG WINAPI
ISF_NetConnect_fnRelease (IShellFolder2
* iface
)
169 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
170 ULONG refCount
= InterlockedDecrement(&This
->ref
);
175 SHFree (This
->pidlRoot
);
181 /**************************************************************************
182 * ISF_NetConnect_fnParseDisplayName
184 static HRESULT WINAPI
ISF_NetConnect_fnParseDisplayName (IShellFolder2
* iface
,
185 HWND hwndOwner
, LPBC pbcReserved
, LPOLESTR lpszDisplayName
,
186 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
188 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
190 HRESULT hr
= E_UNEXPECTED
;
194 *pchEaten
= 0; /* strange but like the original */
199 /**************************************************************************
200 * CreateNetConnectEnumListss()
202 static BOOL
CreateNetConnectEnumList(IEnumIDList
*list
, DWORD dwFlags
)
205 INetConnectionManager
* INetConMan
;
206 IEnumNetConnection
* IEnumCon
;
207 INetConnection
* INetCon
;
211 /* get an instance to of IConnectionManager */
212 hr
= INetConnectionManager_Constructor(NULL
, &IID_INetConnectionManager
, (LPVOID
*)&INetConMan
);
216 hr
= INetConnectionManager_EnumConnections(INetConMan
, NCME_DEFAULT
, &IEnumCon
);
219 INetConnectionManager_Release(INetConMan
);
225 hr
= IEnumNetConnection_Next(IEnumCon
, 1, &INetCon
, &Count
);
228 pidl
= ILCreateNetConnectItem(INetCon
);
231 AddToEnumList(list
, pidl
);
240 IEnumNetConnection_Release(IEnumCon
);
241 INetConnectionManager_Release(INetConMan
);
246 /**************************************************************************
247 * ISF_NetConnect_fnEnumObjects
249 static HRESULT WINAPI
ISF_NetConnect_fnEnumObjects (IShellFolder2
* iface
,
250 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
252 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
254 *ppEnumIDList
= IEnumIDList_Constructor();
256 CreateNetConnectEnumList(*ppEnumIDList
, dwFlags
);
259 return (*ppEnumIDList
) ? S_OK
: E_OUTOFMEMORY
;
262 /**************************************************************************
263 * ISF_NetConnect_fnBindToObject
265 static HRESULT WINAPI
ISF_NetConnect_fnBindToObject (IShellFolder2
* iface
,
266 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
268 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
273 /**************************************************************************
274 * ISF_NetConnect_fnBindToStorage
276 static HRESULT WINAPI
ISF_NetConnect_fnBindToStorage (IShellFolder2
* iface
,
277 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
279 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
286 /**************************************************************************
287 * ISF_NetConnect_fnCompareIDs
290 static HRESULT WINAPI
ISF_NetConnect_fnCompareIDs (IShellFolder2
* iface
,
291 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
293 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
300 /**************************************************************************
301 * ISF_NetConnect_fnCreateViewObject
303 static HRESULT WINAPI
ISF_NetConnect_fnCreateViewObject (IShellFolder2
* iface
,
304 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
306 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
307 IShellView
* pShellView
;
309 HRESULT hr
= E_NOINTERFACE
;
316 if (IsEqualIID (riid
, &IID_IShellView
))
318 ZeroMemory(&cvf
, sizeof(cvf
));
319 cvf
.cbSize
= sizeof(cvf
);
320 cvf
.pshf
= (IShellFolder
*)iface
;
322 hr
= SHCreateShellFolderViewEx(&cvf
, &pShellView
);
325 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
326 IShellView_Release (pShellView
);
333 /**************************************************************************
334 * ISF_NetConnect_fnGetAttributesOf
336 static HRESULT WINAPI
ISF_NetConnect_fnGetAttributesOf (IShellFolder2
* iface
,
337 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
339 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
341 static const DWORD dwNetConnectAttributes
= SFGAO_STORAGE
| SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
342 SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_HASSUBFOLDER
| SFGAO_CANRENAME
| SFGAO_CANDELETE
;
344 static const DWORD dwNetConnectItemAttributes
= SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
345 SFGAO_FILESYSANCESTOR
| SFGAO_CANRENAME
;
357 *rgfInOut
= dwNetConnectAttributes
;
359 *rgfInOut
= dwNetConnectItemAttributes
;
361 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
362 *rgfInOut
&= ~SFGAO_VALIDATE
;
367 /**************************************************************************
368 * ISF_NetConnect_fnGetUIObjectOf
371 * hwndOwner [in] Parent window for any output
372 * cidl [in] array size
373 * apidl [in] simple pidl array
374 * riid [in] Requested Interface
375 * prgfInOut [ ] reserved
376 * ppvObject [out] Resulting Interface
379 static HRESULT
IContextMenuImpl_Constructor(REFIID riid
, LPCITEMIDLIST apidl
, LPVOID
* ppvOut
, IOleCommandTarget
* lpOleCmd
)
381 IUnknown
*pObj
= NULL
;
382 IContextMenuImpl
* pMenu
= CoTaskMemAlloc(sizeof(IContextMenuImpl
));
384 return E_OUTOFMEMORY
;
386 ZeroMemory(pMenu
, sizeof(IContextMenuImpl
));
388 pMenu
->apidl
= apidl
;
389 pMenu
->lpVtblContextMenu
= &vt_ContextMenu3
;
390 pMenu
->lpVtblObjectWithSite
= &vt_ObjectWithSite
;
391 pMenu
->lpVtblExtractIconW
= &vt_ExtractIconW
;
392 pMenu
->lpVtblQueryInfo
= &vt_QueryInfo
;
393 pMenu
->pUnknown
= NULL
;
394 pMenu
->lpOleCmd
= lpOleCmd
;
397 if (IsEqualIID(riid
, &IID_IContextMenu
) || IsEqualIID(riid
, &IID_IContextMenu2
)|| IsEqualIID(riid
, &IID_IContextMenu3
))
398 pObj
= (IUnknown
*)(&pMenu
->lpVtblContextMenu
);
399 else if(IsEqualIID(riid
, &IID_IQueryInfo
))
400 pObj
= (IUnknown
*)(&pMenu
->lpVtblQueryInfo
);
401 else if(IsEqualIID(riid
, &IID_IExtractIconW
))
402 pObj
= (IUnknown
*)(&pMenu
->lpVtblExtractIconW
);
404 return E_NOINTERFACE
;
406 IUnknown_AddRef(pObj
);
413 static HRESULT WINAPI
ISF_NetConnect_fnGetUIObjectOf (IShellFolder2
* iface
,
414 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
, REFIID riid
,
415 UINT
* prgfInOut
, LPVOID
* ppvOut
)
417 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
419 IUnknown
*pObj
= NULL
;
420 HRESULT hr
= E_INVALIDARG
;
427 if ((IsEqualIID (riid
, &IID_IContextMenu
) || IsEqualIID (riid
, &IID_IContextMenu2
) || IsEqualIID(riid
, &IID_IContextMenu3
) ||
428 IsEqualIID(riid
, &IID_IQueryInfo
) || IsEqualIID(riid
, &IID_IExtractIconW
)) && (cidl
>= 1))
430 return IContextMenuImpl_Constructor(riid
, apidl
[0], ppvOut
, This
->lpOleCmd
);
439 /**************************************************************************
440 * ISF_NetConnect_fnGetDisplayNameOf
443 static HRESULT WINAPI
ISF_NetConnect_fnGetDisplayNameOf (IShellFolder2
* iface
,
444 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
448 NETCON_PROPERTIES
* pProperties
;
450 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
455 pszName
= CoTaskMemAlloc(MAX_PATH
* sizeof(WCHAR
));
457 return E_OUTOFMEMORY
;
459 if (_ILIsNetConnect (pidl
))
461 if (LoadStringW(netshell_hInstance
, IDS_NETWORKCONNECTION
, pszName
, MAX_PATH
))
463 pszName
[MAX_PATH
-1] = L
'\0';
469 val
= _ILGetValueStruct(pidl
);
472 if (INetConnection_GetProperties(val
->pItem
, &pProperties
) == NOERROR
)
474 if (pProperties
->pszwName
)
476 wcscpy(pszName
, pProperties
->pszwName
);
479 NcFreeNetconProperties(pProperties
);
487 strRet
->uType
= STRRET_WSTR
;
488 strRet
->u
.pOleStr
= pszName
;
492 CoTaskMemFree(pszName
);
498 /**************************************************************************
499 * ISF_NetConnect_fnSetNameOf
500 * Changes the name of a file object or subfolder, possibly changing its item
501 * identifier in the process.
504 * hwndOwner [in] Owner window for output
505 * pidl [in] simple pidl of item to change
506 * lpszName [in] the items new display name
507 * dwFlags [in] SHGNO formatting flags
508 * ppidlOut [out] simple pidl returned
510 static HRESULT WINAPI
ISF_NetConnect_fnSetNameOf (IShellFolder2
* iface
,
511 HWND hwndOwner
, LPCITEMIDLIST pidl
, /*simple pidl */
512 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
514 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
519 static HRESULT WINAPI
ISF_NetConnect_fnGetDefaultSearchGUID (
520 IShellFolder2
* iface
, GUID
* pguid
)
522 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
527 static HRESULT WINAPI
ISF_NetConnect_fnEnumSearches (IShellFolder2
* iface
,
528 IEnumExtraSearch
** ppenum
)
530 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
535 static HRESULT WINAPI
ISF_NetConnect_fnGetDefaultColumn (IShellFolder2
* iface
,
536 DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
538 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
548 static HRESULT WINAPI
ISF_NetConnect_fnGetDefaultColumnState (
549 IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
551 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
553 if (!pcsFlags
|| iColumn
>= NETCONNECTSHELLVIEWCOLUMNS
)
555 *pcsFlags
= NetConnectSFHeader
[iColumn
].pcsFlags
;
559 static HRESULT WINAPI
ISF_NetConnect_fnGetDetailsEx (IShellFolder2
* iface
,
560 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
562 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
567 static HRESULT WINAPI
ISF_NetConnect_fnGetDetailsOf (IShellFolder2
* iface
,
568 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
570 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
571 WCHAR buffer
[MAX_PATH
] = {0};
574 NETCON_PROPERTIES
* pProperties
;
576 if (iColumn
>= NETCONNECTSHELLVIEWCOLUMNS
)
579 psd
->fmt
= NetConnectSFHeader
[iColumn
].fmt
;
580 psd
->cxChar
= NetConnectSFHeader
[iColumn
].cxChar
;
583 psd
->str
.uType
= STRRET_WSTR
;
584 if (LoadStringW(netshell_hInstance
, NetConnectSFHeader
[iColumn
].colnameid
, buffer
, MAX_PATH
))
585 hr
= SHStrDupW(buffer
, &psd
->str
.u
.pOleStr
);
590 if (iColumn
== COLUMN_NAME
)
592 psd
->str
.uType
= STRRET_WSTR
;
593 return IShellFolder2_GetDisplayNameOf(iface
, pidl
, SHGDN_NORMAL
, &psd
->str
);
596 val
= _ILGetValueStruct(pidl
);
603 if (INetConnection_GetProperties((INetConnection
*)val
->pItem
, &pProperties
) != NOERROR
)
610 if (pProperties
->MediaType
== NCM_LAN
|| pProperties
->MediaType
== NCM_SHAREDACCESSHOST_RAS
)
612 if (LoadStringW(netshell_hInstance
, IDS_TYPE_ETHERNET
, buffer
, MAX_PATH
))
614 psd
->str
.uType
= STRRET_WSTR
;
615 hr
= SHStrDupW(buffer
, &psd
->str
.u
.pOleStr
);
621 if (pProperties
->Status
== NCS_HARDWARE_DISABLED
)
622 LoadStringW(netshell_hInstance
, IDS_STATUS_NON_OPERATIONAL
, buffer
, MAX_PATH
);
623 else if (pProperties
->Status
== NCS_DISCONNECTED
)
624 LoadStringW(netshell_hInstance
, IDS_STATUS_UNREACHABLE
, buffer
, MAX_PATH
);
625 else if (pProperties
->Status
== NCS_MEDIA_DISCONNECTED
)
626 LoadStringW(netshell_hInstance
, IDS_STATUS_DISCONNECTED
, buffer
, MAX_PATH
);
627 else if (pProperties
->Status
== NCS_CONNECTING
)
628 LoadStringW(netshell_hInstance
, IDS_STATUS_CONNECTING
, buffer
, MAX_PATH
);
629 else if (pProperties
->Status
== NCS_CONNECTED
)
630 LoadStringW(netshell_hInstance
, IDS_STATUS_CONNECTED
, buffer
, MAX_PATH
);
634 buffer
[MAX_PATH
-1] = L
'\0';
635 psd
->str
.uType
= STRRET_WSTR
;
636 hr
= SHStrDupW(buffer
, &psd
->str
.u
.pOleStr
);
640 if (pProperties
->pszwDeviceName
)
642 wcscpy(buffer
, pProperties
->pszwDeviceName
);
643 buffer
[MAX_PATH
-1] = L
'\0';
644 psd
->str
.uType
= STRRET_WSTR
;
645 hr
= SHStrDupW(buffer
, &psd
->str
.u
.pOleStr
);
649 psd
->str
.u
.cStr
[0] = '\0';
650 psd
->str
.uType
= STRRET_CSTR
;
655 psd
->str
.u
.cStr
[0] = '\0';
656 psd
->str
.uType
= STRRET_CSTR
;
660 NcFreeNetconProperties(pProperties
);
664 static HRESULT WINAPI
ISF_NetConnect_fnMapColumnToSCID (IShellFolder2
* iface
,
665 UINT column
, SHCOLUMNID
* pscid
)
667 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
672 static const IShellFolder2Vtbl vt_ShellFolder2
= {
673 ISF_NetConnect_fnQueryInterface
,
674 ISF_NetConnect_fnAddRef
,
675 ISF_NetConnect_fnRelease
,
676 ISF_NetConnect_fnParseDisplayName
,
677 ISF_NetConnect_fnEnumObjects
,
678 ISF_NetConnect_fnBindToObject
,
679 ISF_NetConnect_fnBindToStorage
,
680 ISF_NetConnect_fnCompareIDs
,
681 ISF_NetConnect_fnCreateViewObject
,
682 ISF_NetConnect_fnGetAttributesOf
,
683 ISF_NetConnect_fnGetUIObjectOf
,
684 ISF_NetConnect_fnGetDisplayNameOf
,
685 ISF_NetConnect_fnSetNameOf
,
687 ISF_NetConnect_fnGetDefaultSearchGUID
,
688 ISF_NetConnect_fnEnumSearches
,
689 ISF_NetConnect_fnGetDefaultColumn
,
690 ISF_NetConnect_fnGetDefaultColumnState
,
691 ISF_NetConnect_fnGetDetailsEx
,
692 ISF_NetConnect_fnGetDetailsOf
,
693 ISF_NetConnect_fnMapColumnToSCID
696 //IInternetSecurityManager
698 /**************************************************************************
699 * IContextMenu2 Implementation
702 /************************************************************************
703 * ISF_NetConnect_IContextMenu_QueryInterface
705 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_QueryInterface(IContextMenu3
* iface
, REFIID iid
, LPVOID
* ppvObject
)
708 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
710 if (IsEqualIID(iid
, &IID_IContextMenu
) || IsEqualIID(iid
, &IID_IContextMenu2
) || IsEqualIID(iid
, &IID_IContextMenu3
))
712 *ppvObject
= (IUnknown
*) &This
->lpVtblContextMenu
;
713 InterlockedIncrement(&This
->ref
);
716 else if (IsEqualIID(iid
, &IID_IObjectWithSite
))
718 *ppvObject
= (IUnknown
*) &This
->lpVtblObjectWithSite
;
719 InterlockedIncrement(&This
->ref
);
722 else if (IsEqualIID(iid
, &IID_IQueryInfo
))
724 *ppvObject
= (IUnknown
*) &This
->lpVtblQueryInfo
;
725 InterlockedIncrement(&This
->ref
);
729 //StringFromCLSID(iid, &pStr);
730 //MessageBoxW(NULL, L"ISF_NetConnect_IContextMenu2_QueryInterface unhandled", pStr, MB_OK);
731 return E_NOINTERFACE
;
734 /************************************************************************
735 * ISF_NetConnect_IContextMenu_AddRef
737 static ULONG WINAPI
ISF_NetConnect_IContextMenu3_AddRef(IContextMenu3
* iface
)
740 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
742 refCount
= InterlockedIncrement(&This
->ref
);
747 /************************************************************************
748 * ISF_NetConnect_IContextMenu_Release
750 static ULONG WINAPI
ISF_NetConnect_IContextMenu3_Release(IContextMenu3
* iface
)
753 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
755 refCount
= InterlockedDecrement(&This
->ref
);
763 void WINAPI
_InsertMenuItemW (
775 ZeroMemory(&mii
, sizeof(mii
));
776 mii
.cbSize
= sizeof(mii
);
777 if (fType
== MFT_SEPARATOR
)
779 mii
.fMask
= MIIM_ID
| MIIM_TYPE
;
781 else if (fType
== MFT_STRING
)
783 mii
.fMask
= MIIM_ID
| MIIM_TYPE
| MIIM_STATE
;
784 if ((ULONG_PTR
)HIWORD((ULONG_PTR
)dwTypeData
) == 0)
786 if (LoadStringW(netshell_hInstance
, LOWORD((ULONG_PTR
)dwTypeData
), szText
, sizeof(szText
)/sizeof(WCHAR
)))
788 szText
[(sizeof(szText
)/sizeof(WCHAR
))-1] = 0;
789 mii
.dwTypeData
= szText
;
798 mii
.dwTypeData
= (LPWSTR
) dwTypeData
;
805 InsertMenuItemW( hmenu
, indexMenu
, fByPosition
, &mii
);
808 /**************************************************************************
809 * ISF_NetConnect_IContextMenu_QueryContextMenu()
811 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_QueryContextMenu(
812 IContextMenu3
*iface
,
819 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
821 NETCON_PROPERTIES
* pProperties
;
823 val
= _ILGetValueStruct(This
->apidl
);
827 if (INetConnection_GetProperties((INetConnection
*)val
->pItem
, &pProperties
) != NOERROR
)
831 if (pProperties
->Status
== NCS_HARDWARE_DISABLED
)
832 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_ACTIVATE
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_ACTIVATE
), MFS_DEFAULT
);
834 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_DEACTIVATE
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_DEACTIVATE
), MFS_ENABLED
);
836 if (pProperties
->Status
== NCS_HARDWARE_DISABLED
|| pProperties
->Status
== NCS_MEDIA_DISCONNECTED
|| pProperties
->Status
== NCS_DISCONNECTED
)
837 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_STATUS
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_STATUS
), MFS_GRAYED
);
838 else if (pProperties
->Status
== NCS_CONNECTED
)
839 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_STATUS
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_STATUS
), MFS_DEFAULT
);
841 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_STATUS
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_STATUS
), MFS_ENABLED
);
843 if (pProperties
->Status
== NCS_HARDWARE_DISABLED
|| pProperties
->Status
== NCS_MEDIA_DISCONNECTED
)
844 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_REPAIR
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_REPAIR
), MFS_GRAYED
);
846 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_REPAIR
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_REPAIR
), MFS_ENABLED
);
848 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, -1, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
849 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_CREATELINK
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_CREATELINK
), MFS_ENABLED
);
851 if (pProperties
->dwCharacter
& NCCF_ALLOW_REMOVAL
)
852 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_DELETE
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_DELETE
), MFS_ENABLED
);
854 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_DELETE
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_DELETE
), MFS_GRAYED
);
856 if (pProperties
->dwCharacter
& NCCF_ALLOW_RENAME
)
857 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_RENAME
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_RENAME
), MFS_ENABLED
);
859 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_RENAME
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_RENAME
), MFS_GRAYED
);
861 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, -1, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
862 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_PROPERTIES
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_PROPERTIES
), MFS_ENABLED
);
863 NcFreeNetconProperties(pProperties
);
864 return MAKE_HRESULT(SEVERITY_SUCCESS
, 0, 9);
869 PropSheetExCallback(HPROPSHEETPAGE hPage
, LPARAM lParam
)
871 PROPSHEETHEADERW
*pinfo
= (PROPSHEETHEADERW
*)lParam
;
873 if (pinfo
->nPages
< MAX_PROPERTY_SHEET_PAGE
)
875 pinfo
->u3
.phpage
[pinfo
->nPages
++] = hPage
;
882 ShowNetConnectionStatus(
883 IOleCommandTarget
* lpOleCmd
,
884 INetConnection
* pNetConnect
,
887 NETCON_PROPERTIES
* pProperties
;
893 if (INetConnection_GetProperties(pNetConnect
, &pProperties
) != NOERROR
)
896 hr
= IOleCommandTarget_Exec(lpOleCmd
, &pProperties
->guidId
, 2, OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
898 NcFreeNetconProperties(pProperties
);
903 ShowNetConnectionProperties(
904 INetConnection
* pNetConnect
,
909 PROPSHEETHEADERW pinfo
;
910 HPROPSHEETPAGE hppages
[MAX_PROPERTY_SHEET_PAGE
];
911 INetConnectionPropertyUi
* pNCP
;
912 NETCON_PROPERTIES
* pProperties
;
914 if (INetConnection_GetProperties(pNetConnect
, &pProperties
) != NOERROR
)
917 hr
= INetConnection_GetUiObjectClassId(pNetConnect
, &ClassID
);
920 NcFreeNetconProperties(pProperties
);
924 hr
= CoCreateInstance(&ClassID
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetConnectionPropertyUi
, (LPVOID
)&pNCP
);
927 NcFreeNetconProperties(pProperties
);
931 hr
= INetConnectionPropertyUi_SetConnection(pNCP
, pNetConnect
);
934 ZeroMemory(&pinfo
, sizeof(PROPSHEETHEADERW
));
935 ZeroMemory(hppages
, sizeof(hppages
));
936 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
937 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
| PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
938 pinfo
.u3
.phpage
= hppages
;
939 pinfo
.hwndParent
= hwnd
;
941 pinfo
.pszCaption
= pProperties
->pszwName
;
942 hr
= INetConnectionPropertyUi_AddPages(pNCP
, hwnd
, PropSheetExCallback
, (LPARAM
)&pinfo
);
945 if(PropertySheetW(&pinfo
) < 0)
949 INetConnectionPropertyUi_Release(pNCP
);
950 NcFreeNetconProperties(pProperties
);
955 /**************************************************************************
956 * ISF_NetConnect_IContextMenu_InvokeCommand()
958 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_InvokeCommand(
959 IContextMenu3
*iface
,
960 LPCMINVOKECOMMANDINFO lpcmi
)
962 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
965 val
= _ILGetValueStruct(This
->apidl
);
969 if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(IDS_NET_STATUS
) ||
970 lpcmi
->lpVerb
== MAKEINTRESOURCEA(IDS_NET_STATUS
-1)) //HACK for Windows XP
972 return ShowNetConnectionStatus(This
->lpOleCmd
, val
->pItem
, lpcmi
->hwnd
);
974 else if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(IDS_NET_PROPERTIES
) ||
975 lpcmi
->lpVerb
== MAKEINTRESOURCEA(10099)) //HACK for Windows XP
977 /* FIXME perform version checks */
978 return ShowNetConnectionProperties(val
->pItem
, lpcmi
->hwnd
);
984 /**************************************************************************
985 * ISF_NetConnect_IContextMenu_GetCommandString()
988 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_GetCommandString(
989 IContextMenu3
*iface
,
1001 /**************************************************************************
1002 * ISF_NetConnect_IContextMenu_HandleMenuMsg()
1004 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_HandleMenuMsg(
1005 IContextMenu3
*iface
,
1013 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_HandleMenuMsg2(
1014 IContextMenu3
*iface
,
1024 static const IContextMenu3Vtbl vt_ContextMenu3
=
1026 ISF_NetConnect_IContextMenu3_QueryInterface
,
1027 ISF_NetConnect_IContextMenu3_AddRef
,
1028 ISF_NetConnect_IContextMenu3_Release
,
1029 ISF_NetConnect_IContextMenu3_QueryContextMenu
,
1030 ISF_NetConnect_IContextMenu3_InvokeCommand
,
1031 ISF_NetConnect_IContextMenu3_GetCommandString
,
1032 ISF_NetConnect_IContextMenu3_HandleMenuMsg
,
1033 ISF_NetConnect_IContextMenu3_HandleMenuMsg2
1036 static HRESULT WINAPI
ISF_NetConnect_IObjectWithSite_QueryInterface (IObjectWithSite
* iface
,
1037 REFIID iid
, LPVOID
* ppvObj
)
1039 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1041 if (IsEqualIID(iid
, &IID_IObjectWithSite
))
1043 *ppvObj
= (IUnknown
*)&This
->lpVtblObjectWithSite
;
1046 return E_NOINTERFACE
;
1049 /************************************************************************
1050 * ISF_NetConnect_IQueryInfo_AddRef
1052 static ULONG WINAPI
ISF_NetConnect_IObjectWithSite_AddRef (IObjectWithSite
* iface
)
1054 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1056 return IContextMenu2_AddRef((IContextMenu2
*)This
);
1059 /************************************************************************
1060 * ISF_NetConnect_IQueryInfo_Release
1062 static ULONG WINAPI
ISF_NetConnect_IObjectWithSite_Release (IObjectWithSite
* iface
)
1064 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1066 return IContextMenu_Release((IContextMenu
*)This
);
1069 /************************************************************************
1070 * ISF_NetConnect_PersistFolder2_Release
1072 static HRESULT WINAPI
ISF_NetConnect_IObjectWithSite_GetSite (IObjectWithSite
* iface
, REFIID riid
, PVOID
*ppvSite
)
1076 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1078 if (!This
->pUnknown
)
1084 hr
= IUnknown_QueryInterface(This
->pUnknown
, riid
, (LPVOID
*)&pUnknown
);
1087 IUnknown_AddRef(pUnknown
);
1088 *ppvSite
= pUnknown
;
1096 static HRESULT WINAPI
ISF_NetConnect_IObjectWithSite_SetSite (IObjectWithSite
* iface
, IUnknown
*pUnkSite
)
1098 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1104 IUnknown_Release(This
->pUnknown
);
1105 This
->pUnknown
= NULL
;
1110 IUnknown_AddRef(pUnkSite
);
1112 IUnknown_Release(This
->pUnknown
);
1113 This
->pUnknown
= pUnkSite
;
1120 static const IObjectWithSiteVtbl vt_ObjectWithSite
=
1122 ISF_NetConnect_IObjectWithSite_QueryInterface
,
1123 ISF_NetConnect_IObjectWithSite_AddRef
,
1124 ISF_NetConnect_IObjectWithSite_Release
,
1125 ISF_NetConnect_IObjectWithSite_SetSite
,
1126 ISF_NetConnect_IObjectWithSite_GetSite
1129 static HRESULT WINAPI
ISF_NetConnect_IExtractIconW_QueryInterface (IExtractIconW
* iface
,
1130 REFIID iid
, LPVOID
* ppvObj
)
1132 IContextMenuImpl
* This
= impl_from_IExtractIcon(iface
);
1134 if (IsEqualIID(iid
, &IID_IExtractIconW
))
1136 *ppvObj
= (IUnknown
*)&This
->lpVtblExtractIconW
;
1139 return E_NOINTERFACE
;
1142 /************************************************************************
1143 * ISF_NetConnect_IExtractIcon_AddRef
1145 static ULONG WINAPI
ISF_NetConnect_IExtractIconW_AddRef (IExtractIconW
* iface
)
1147 IContextMenuImpl
* This
= impl_from_IExtractIcon(iface
);
1149 return IContextMenu2_AddRef((IContextMenu2
*)This
);
1152 /************************************************************************
1153 * ISF_NetConnect_IExtractIcon_Release
1155 static ULONG WINAPI
ISF_NetConnect_IExtractIconW_Release (IExtractIconW
* iface
)
1157 IContextMenuImpl
* This
= impl_from_IExtractIcon(iface
);
1159 return IContextMenu_Release((IContextMenu
*)This
);
1162 /************************************************************************
1163 * ISF_NetConnect_IExtractIcon_GetIconLocation
1165 static HRESULT WINAPI
ISF_NetConnect_IExtractIconW_GetIconLocation(
1166 IExtractIconW
* iface
,
1174 NETCON_PROPERTIES
* pProperties
;
1175 IContextMenuImpl
* This
= impl_from_IExtractIcon(iface
);
1178 if (!GetModuleFileNameW(netshell_hInstance
, szIconFile
, cchMax
))
1181 val
= _ILGetValueStruct(This
->apidl
);
1185 if (INetConnection_GetProperties(val
->pItem
, &pProperties
) != NOERROR
)
1188 if (pProperties
->Status
== NCS_CONNECTED
|| pProperties
->Status
== NCS_CONNECTING
)
1189 *piIndex
= IDI_NET_IDLE
;
1191 *piIndex
= IDI_NET_OFF
;
1193 NcFreeNetconProperties(pProperties
);
1198 /************************************************************************
1199 * ISF_NetConnect_IExtractIcon_Extract
1201 static HRESULT WINAPI
ISF_NetConnect_IExtractIconW_Extract(
1202 IExtractIconW
* iface
,
1209 //IContextMenuImpl * This = impl_from_IExtractIcon(iface);
1210 if (nIconIndex
== IDI_NET_IDLE
)
1212 *phiconLarge
= LoadImage(netshell_hInstance
, MAKEINTRESOURCE(IDI_NET_IDLE
), IMAGE_ICON
, 32, 32, LR_DEFAULTCOLOR
);
1213 *phiconSmall
= LoadImage(netshell_hInstance
, MAKEINTRESOURCE(IDI_NET_IDLE
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
);
1216 else if (nIconIndex
== IDI_NET_OFF
)
1218 *phiconLarge
= LoadImage(netshell_hInstance
, MAKEINTRESOURCE(IDI_NET_OFF
), IMAGE_ICON
, 32, 32, LR_DEFAULTCOLOR
);
1219 *phiconSmall
= LoadImage(netshell_hInstance
, MAKEINTRESOURCE(IDI_NET_OFF
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
);
1226 static const IExtractIconWVtbl vt_ExtractIconW
=
1228 ISF_NetConnect_IExtractIconW_QueryInterface
,
1229 ISF_NetConnect_IExtractIconW_AddRef
,
1230 ISF_NetConnect_IExtractIconW_Release
,
1231 ISF_NetConnect_IExtractIconW_GetIconLocation
,
1232 ISF_NetConnect_IExtractIconW_Extract
1241 /************************************************************************
1242 * ISF_NetConnect_PersistFolder2_QueryInterface
1244 static HRESULT WINAPI
ISF_NetConnect_PersistFolder2_QueryInterface (IPersistFolder2
* iface
,
1245 REFIID iid
, LPVOID
* ppvObj
)
1247 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1249 return IShellFolder2_QueryInterface ((IShellFolder2
*)This
, iid
, ppvObj
);
1252 /************************************************************************
1253 * ISF_NetConnect_PersistFolder2_AddRef
1255 static ULONG WINAPI
ISF_NetConnect_PersistFolder2_AddRef (IPersistFolder2
* iface
)
1257 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1259 return IShellFolder2_AddRef((IShellFolder2
*)This
);
1262 /************************************************************************
1263 * ISF_NetConnect_PersistFolder2_Release
1265 static ULONG WINAPI
ISF_NetConnect_PersistFolder2_Release (IPersistFolder2
* iface
)
1267 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1269 return IShellFolder2_Release((IShellFolder2
*)This
);
1272 /************************************************************************
1273 * ISF_NetConnect_PersistFolder2_GetClassID
1275 static HRESULT WINAPI
ISF_NetConnect_PersistFolder2_GetClassID (
1276 IPersistFolder2
* iface
, CLSID
* lpClassId
)
1278 //IGenericSFImpl * This = impl_from_IPersistFolder2(iface);
1283 *lpClassId
= CLSID_NetworkConnections
;
1288 /************************************************************************
1289 * ISF_NetConnect_PersistFolder2_Initialize
1291 * NOTES: it makes no sense to change the pidl
1293 static HRESULT WINAPI
ISF_NetConnect_PersistFolder2_Initialize (
1294 IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
1296 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1298 SHFree(This
->pidlRoot
);
1299 This
->pidlRoot
= ILClone(pidl
);
1304 /**************************************************************************
1305 * ISF_NetConnect_PersistFolder2_GetCurFolder
1307 static HRESULT WINAPI
ISF_NetConnect_PersistFolder2_GetCurFolder (
1308 IPersistFolder2
* iface
, LPITEMIDLIST
* pidl
)
1310 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1316 *pidl
= ILClone (This
->pidlRoot
);
1321 static const IPersistFolder2Vtbl vt_PersistFolder2
=
1323 ISF_NetConnect_PersistFolder2_QueryInterface
,
1324 ISF_NetConnect_PersistFolder2_AddRef
,
1325 ISF_NetConnect_PersistFolder2_Release
,
1326 ISF_NetConnect_PersistFolder2_GetClassID
,
1327 ISF_NetConnect_PersistFolder2_Initialize
,
1328 ISF_NetConnect_PersistFolder2_GetCurFolder
1331 /************************************************************************
1332 * ISF_NetConnect_ShellExecuteHookW_QueryInterface
1334 static HRESULT WINAPI
ISF_NetConnect_ShellExecuteHookW_QueryInterface (IShellExecuteHookW
* iface
,
1335 REFIID iid
, LPVOID
* ppvObj
)
1337 IGenericSFImpl
* This
= impl_from_IShellExecuteHookW(iface
);
1339 return IShellFolder2_QueryInterface ((IShellFolder2
*)This
, iid
, ppvObj
);
1342 /************************************************************************
1343 * ISF_NetConnect_ShellExecuteHookW_AddRef
1345 static ULONG WINAPI
ISF_NetConnect_ShellExecuteHookW_AddRef (IShellExecuteHookW
* iface
)
1347 IGenericSFImpl
* This
= impl_from_IShellExecuteHookW(iface
);
1349 return IShellFolder2_AddRef((IShellFolder2
*)This
);
1352 /************************************************************************
1353 * ISF_NetConnect_PersistFolder2_Release
1355 static ULONG WINAPI
ISF_NetConnect_ShellExecuteHookW_Release (IShellExecuteHookW
* iface
)
1357 IGenericSFImpl
* This
= impl_from_IShellExecuteHookW(iface
);
1359 return IShellFolder2_Release((IShellFolder2
*)This
);
1363 /************************************************************************
1364 * ISF_NetConnect_ShellExecuteHookW_Execute
1366 static HRESULT WINAPI
ISF_NetConnect_ShellExecuteHookW_Execute (IShellExecuteHookW
* iface
,
1367 LPSHELLEXECUTEINFOW pei
)
1370 NETCON_PROPERTIES
* pProperties
;
1371 IGenericSFImpl
* This
= impl_from_IShellExecuteHookW(iface
);
1373 val
= _ILGetValueStruct(ILFindLastID(pei
->lpIDList
));
1377 if (INetConnection_GetProperties((INetConnection
*)val
->pItem
, &pProperties
) != NOERROR
)
1380 if (pProperties
->Status
== NCS_CONNECTED
)
1382 NcFreeNetconProperties(pProperties
);
1383 return ShowNetConnectionStatus(This
->lpOleCmd
, val
->pItem
, pei
->hwnd
);
1386 NcFreeNetconProperties(pProperties
);
1392 static const IShellExecuteHookWVtbl vt_ShellExecuteHookW
=
1394 ISF_NetConnect_ShellExecuteHookW_QueryInterface
,
1395 ISF_NetConnect_ShellExecuteHookW_AddRef
,
1396 ISF_NetConnect_ShellExecuteHookW_Release
,
1397 ISF_NetConnect_ShellExecuteHookW_Execute
1401 static const IPersistIDListVtbl vt_PersistIDList
=
1403 ISF_NetConnect_PersistIDList_QueryInterface
,
1404 ISF_NetConnect_PersistIDList_AddRef
,
1405 ISF_NetConnect_PersistIDList_Release
,
1406 ISF_NetConnect_PersistIDList_GetClassID
,
1407 ISF_NetConnect_PersistIDList_SetIDList
,
1408 ISF_NetConnect_PersistIDList_GetIDList
,
1412 /************************************************************************
1413 * ISF_NetConnect_PersistFolder2_QueryInterface
1415 static HRESULT WINAPI
ISF_NetConnect_IQueryInfo_QueryInterface (IQueryInfo
* iface
,
1416 REFIID iid
, LPVOID
* ppvObj
)
1418 IContextMenuImpl
* This
= impl_from_IQueryInfo(iface
);
1420 if (IsEqualIID(iid
, &IID_IQueryInfo
))
1422 *ppvObj
= (IUnknown
*)&This
->lpVtblQueryInfo
;
1426 return E_NOINTERFACE
;
1429 /************************************************************************
1430 * ISF_NetConnect_PersistFolder2_AddRef
1432 static ULONG WINAPI
ISF_NetConnect_IQueryInfo_AddRef (IQueryInfo
* iface
)
1434 IContextMenuImpl
* This
= impl_from_IQueryInfo(iface
);
1436 return IContextMenu2_AddRef((IContextMenu2
*)This
);
1439 /************************************************************************
1440 * ISF_NetConnect_PersistFolder2_Release
1442 static ULONG WINAPI
ISF_NetConnect_IQueryInfo_Release (IQueryInfo
* iface
)
1444 IContextMenuImpl
* This
= impl_from_IQueryInfo(iface
);
1446 return IContextMenu_Release((IContextMenu
*)This
);
1449 /************************************************************************
1450 * ISF_NetConnect_PersistFolder2_GetClassID
1452 static HRESULT WINAPI
ISF_NetConnect_IQueryInfo_GetInfoFlags (
1453 IQueryInfo
* iface
, DWORD
*pdwFlags
)
1460 /************************************************************************
1461 * ISF_NetConnect_PersistFolder2_Initialize
1463 * NOTES: it makes no sense to change the pidl
1465 static HRESULT WINAPI
ISF_NetConnect_IQueryInfo_GetInfoTip (
1466 IQueryInfo
* iface
, DWORD dwFlags
, WCHAR
**ppwszTip
)
1468 // IGenericSFImpl * This = impl_from_IQueryInfo(iface);
1474 static const IQueryInfoVtbl vt_QueryInfo
=
1476 ISF_NetConnect_IQueryInfo_QueryInterface
,
1477 ISF_NetConnect_IQueryInfo_AddRef
,
1478 ISF_NetConnect_IQueryInfo_Release
,
1479 ISF_NetConnect_IQueryInfo_GetInfoTip
,
1480 ISF_NetConnect_IQueryInfo_GetInfoFlags
1483 /**************************************************************************
1484 * ISF_NetConnect_Constructor
1486 HRESULT WINAPI
ISF_NetConnect_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
1494 return CLASS_E_NOAGGREGATION
;
1496 sf
= (IGenericSFImpl
*) CoTaskMemAlloc(sizeof (IGenericSFImpl
));
1498 return E_OUTOFMEMORY
;
1501 sf
->lpVtbl
= &vt_ShellFolder2
;
1502 sf
->lpVtblPersistFolder2
= &vt_PersistFolder2
;
1503 sf
->lpVtblShellExecuteHookW
= &vt_ShellExecuteHookW
;
1505 hr
= CoCreateInstance(&CLSID_LanConnectStatusUI
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IOleCommandTarget
, (LPVOID
*)&sf
->lpOleCmd
);
1507 sf
->lpOleCmd
= NULL
;
1510 IOleCommandTarget_Exec(sf
->lpOleCmd
, &CGID_ShellServiceObject
, 2, OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
1513 sf
->pidlRoot
= _ILCreateNetConnect(); /* my qualified pidl */
1515 if (!SUCCEEDED (IShellFolder2_QueryInterface ((IShellFolder2
*)sf
, riid
, ppv
)))
1517 IShellFolder2_Release((IShellFolder2
*)sf
);
1518 return E_NOINTERFACE
;