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 IPersistIDListVtbl *lpVtblPersistIDList;
38 /* both paths are parsible from the desktop */
39 LPITEMIDLIST pidlRoot
; /* absolute pidl */
40 LPITEMIDLIST pidl
; /* enumerated pidl */
41 IOleCommandTarget
* lpOleCmd
;
42 } IGenericSFImpl
, *LPIGenericSFImpl
;
46 const IContextMenu3Vtbl
*lpVtblContextMenu
;
47 const IObjectWithSiteVtbl
*lpVtblObjectWithSite
;
48 const IQueryInfoVtbl
*lpVtblQueryInfo
;
49 const IExtractIconWVtbl
*lpVtblExtractIconW
;
53 IOleCommandTarget
* lpOleCmd
;
54 }IContextMenuImpl
, *LPIContextMenuImpl
;
56 static const shvheader NetConnectSFHeader
[] = {
57 {IDS_SHV_COLUMN_NAME
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 20},
58 {IDS_SHV_COLUMN_TYPE
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 8},
59 {IDS_SHV_COLUMN_STATE
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
60 {IDS_SHV_COLUMN_DEVNAME
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 12},
61 {IDS_SHV_COLUMN_PHONE
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
62 {IDS_SHV_COLUMN_OWNER
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 5}
65 #define NETCONNECTSHELLVIEWCOLUMNS 6
69 #define COLUMN_STATUS 2
70 #define COLUMN_DEVNAME 3
71 #define COLUMN_PHONE 4
72 #define COLUMN_OWNER 5
74 static const IContextMenu3Vtbl vt_ContextMenu3
;
75 static const IObjectWithSiteVtbl vt_ObjectWithSite
;
76 static const IQueryInfoVtbl vt_QueryInfo
;
77 static const IExtractIconWVtbl vt_ExtractIconW
;
79 static LPIContextMenuImpl __inline
impl_from_IExtractIcon(IExtractIconW
*iface
)
81 return (LPIContextMenuImpl
)((char *)iface
- FIELD_OFFSET(IContextMenuImpl
, lpVtblExtractIconW
));
85 static LPIContextMenuImpl __inline
impl_from_IObjectWithSite(IObjectWithSite
*iface
)
87 return (LPIContextMenuImpl
)((char *)iface
- FIELD_OFFSET(IContextMenuImpl
, lpVtblObjectWithSite
));
90 static LPIGenericSFImpl __inline
impl_from_IPersistFolder2(IPersistFolder2
*iface
)
92 return (LPIGenericSFImpl
)((char *)iface
- FIELD_OFFSET(IGenericSFImpl
, lpVtblPersistFolder2
));
95 static LPIContextMenuImpl __inline
impl_from_IQueryInfo(IQueryInfo
*iface
)
97 return (LPIContextMenuImpl
)((char *)iface
- FIELD_OFFSET(IContextMenuImpl
, lpVtblQueryInfo
));
101 /**************************************************************************
102 * ISF_NetConnect_fnQueryInterface
105 * supports not IPersist/IPersistFolder
107 static HRESULT WINAPI
ISF_NetConnect_fnQueryInterface (IShellFolder2
*iface
, REFIID riid
, LPVOID
*ppvObj
)
109 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
113 if (IsEqualIID (riid
, &IID_IUnknown
) ||
114 IsEqualIID (riid
, &IID_IShellFolder
) ||
115 IsEqualIID (riid
, &IID_IShellFolder2
))
119 else if (IsEqualIID (riid
, &IID_IPersistFolder
) ||
120 IsEqualIID (riid
, &IID_IPersistFolder2
))
122 *ppvObj
= (LPVOID
*)&This
->lpVtblPersistFolder2
;
125 else if (IsEqualIID(riid
, &IID_IPersistIDList
))
127 //*ppvObj = (LPVOID *)&This->lpVtblPersistIDList;
132 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
137 * IID_IPersistFreeThreadedObject
138 * IID_IBrowserFrameOptions
139 * IID_IShellIconOverlay
144 return E_NOINTERFACE
;
147 static ULONG WINAPI
ISF_NetConnect_fnAddRef (IShellFolder2
* iface
)
149 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
150 ULONG refCount
= InterlockedIncrement(&This
->ref
);
155 static ULONG WINAPI
ISF_NetConnect_fnRelease (IShellFolder2
* iface
)
157 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
158 ULONG refCount
= InterlockedDecrement(&This
->ref
);
163 SHFree (This
->pidlRoot
);
169 /**************************************************************************
170 * ISF_NetConnect_fnParseDisplayName
172 static HRESULT WINAPI
ISF_NetConnect_fnParseDisplayName (IShellFolder2
* iface
,
173 HWND hwndOwner
, LPBC pbcReserved
, LPOLESTR lpszDisplayName
,
174 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
176 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
178 HRESULT hr
= E_UNEXPECTED
;
182 *pchEaten
= 0; /* strange but like the original */
187 /**************************************************************************
188 * CreateNetConnectEnumListss()
190 static BOOL
CreateNetConnectEnumList(IEnumIDList
*list
, DWORD dwFlags
)
193 INetConnectionManager
* INetConMan
;
194 IEnumNetConnection
* IEnumCon
;
195 INetConnection
* INetCon
;
199 /* get an instance to of IConnectionManager */
200 hr
= INetConnectionManager_Constructor(NULL
, &IID_INetConnectionManager
, (LPVOID
*)&INetConMan
);
204 hr
= INetConnectionManager_EnumConnections(INetConMan
, NCME_DEFAULT
, &IEnumCon
);
207 INetConnectionManager_Release(INetConMan
);
213 hr
= IEnumNetConnection_Next(IEnumCon
, 1, &INetCon
, &Count
);
216 pidl
= ILCreateNetConnectItem(INetCon
);
219 AddToEnumList(list
, pidl
);
228 IEnumNetConnection_Release(IEnumCon
);
229 INetConnectionManager_Release(INetConMan
);
234 /**************************************************************************
235 * ISF_NetConnect_fnEnumObjects
237 static HRESULT WINAPI
ISF_NetConnect_fnEnumObjects (IShellFolder2
* iface
,
238 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
240 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
242 *ppEnumIDList
= IEnumIDList_Constructor();
244 CreateNetConnectEnumList(*ppEnumIDList
, dwFlags
);
247 return (*ppEnumIDList
) ? S_OK
: E_OUTOFMEMORY
;
250 /**************************************************************************
251 * ISF_NetConnect_fnBindToObject
253 static HRESULT WINAPI
ISF_NetConnect_fnBindToObject (IShellFolder2
* iface
,
254 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
256 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
261 /**************************************************************************
262 * ISF_NetConnect_fnBindToStorage
264 static HRESULT WINAPI
ISF_NetConnect_fnBindToStorage (IShellFolder2
* iface
,
265 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
267 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
274 /**************************************************************************
275 * ISF_NetConnect_fnCompareIDs
278 static HRESULT WINAPI
ISF_NetConnect_fnCompareIDs (IShellFolder2
* iface
,
279 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
281 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
288 /**************************************************************************
289 * ISF_NetConnect_fnCreateViewObject
291 static HRESULT WINAPI
ISF_NetConnect_fnCreateViewObject (IShellFolder2
* iface
,
292 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
294 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
295 IShellView
* pShellView
;
297 HRESULT hr
= E_NOINTERFACE
;
304 if (IsEqualIID (riid
, &IID_IShellView
))
306 ZeroMemory(&cvf
, sizeof(cvf
));
307 cvf
.cbSize
= sizeof(cvf
);
308 cvf
.pshf
= (IShellFolder
*)iface
;
310 hr
= SHCreateShellFolderViewEx(&cvf
, &pShellView
);
313 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
314 IShellView_Release (pShellView
);
321 /**************************************************************************
322 * ISF_NetConnect_fnGetAttributesOf
324 static HRESULT WINAPI
ISF_NetConnect_fnGetAttributesOf (IShellFolder2
* iface
,
325 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
327 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
329 static const DWORD dwNetConnectAttributes
= SFGAO_STORAGE
| SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
330 SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_HASSUBFOLDER
| SFGAO_CANRENAME
| SFGAO_CANDELETE
;
332 static const DWORD dwNetConnectItemAttributes
= SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
333 SFGAO_FILESYSANCESTOR
| SFGAO_CANRENAME
;
345 *rgfInOut
= dwNetConnectAttributes
;
347 *rgfInOut
= dwNetConnectItemAttributes
;
349 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
350 *rgfInOut
&= ~SFGAO_VALIDATE
;
355 /**************************************************************************
356 * ISF_NetConnect_fnGetUIObjectOf
359 * hwndOwner [in] Parent window for any output
360 * cidl [in] array size
361 * apidl [in] simple pidl array
362 * riid [in] Requested Interface
363 * prgfInOut [ ] reserved
364 * ppvObject [out] Resulting Interface
367 static HRESULT
IContextMenuImpl_Constructor(REFIID riid
, LPCITEMIDLIST apidl
, LPVOID
* ppvOut
, IOleCommandTarget
* lpOleCmd
)
369 IUnknown
*pObj
= NULL
;
370 IContextMenuImpl
* pMenu
= CoTaskMemAlloc(sizeof(IContextMenuImpl
));
372 return E_OUTOFMEMORY
;
374 ZeroMemory(pMenu
, sizeof(IContextMenuImpl
));
376 pMenu
->apidl
= apidl
;
377 pMenu
->lpVtblContextMenu
= &vt_ContextMenu3
;
378 pMenu
->lpVtblObjectWithSite
= &vt_ObjectWithSite
;
379 pMenu
->lpVtblExtractIconW
= &vt_ExtractIconW
;
380 pMenu
->lpVtblQueryInfo
= &vt_QueryInfo
;
381 pMenu
->pUnknown
= NULL
;
382 pMenu
->lpOleCmd
= lpOleCmd
;
385 if (IsEqualIID(riid
, &IID_IContextMenu
) || IsEqualIID(riid
, &IID_IContextMenu2
))// || IsEqualIID(riid, &IID_IContextMenu3))
386 pObj
= (IUnknown
*)(&pMenu
->lpVtblContextMenu
);
387 else if(IsEqualIID(riid
, &IID_IQueryInfo
))
388 pObj
= (IUnknown
*)(&pMenu
->lpVtblQueryInfo
);
389 else if(IsEqualIID(riid
, &IID_IExtractIconW
))
390 pObj
= (IUnknown
*)(&pMenu
->lpVtblExtractIconW
);
392 IUnknown_AddRef(pObj
);
399 static HRESULT WINAPI
ISF_NetConnect_fnGetUIObjectOf (IShellFolder2
* iface
,
400 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
, REFIID riid
,
401 UINT
* prgfInOut
, LPVOID
* ppvOut
)
403 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
405 IUnknown
*pObj
= NULL
;
406 HRESULT hr
= E_INVALIDARG
;
413 if ((IsEqualIID (riid
, &IID_IContextMenu
) || IsEqualIID (riid
, &IID_IContextMenu2
) || IsEqualIID(riid
, &IID_IContextMenu3
) ||
414 IsEqualIID(riid
, &IID_IQueryInfo
) || IsEqualIID(riid
, &IID_IExtractIconW
)) && (cidl
>= 1))
416 return IContextMenuImpl_Constructor(riid
, apidl
[0], ppvOut
, This
->lpOleCmd
);
425 /**************************************************************************
426 * ISF_NetConnect_fnGetDisplayNameOf
429 static HRESULT WINAPI
ISF_NetConnect_fnGetDisplayNameOf (IShellFolder2
* iface
,
430 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
434 NETCON_PROPERTIES
* pProperties
;
436 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
441 pszName
= CoTaskMemAlloc(MAX_PATH
* sizeof(WCHAR
));
443 return E_OUTOFMEMORY
;
445 if (_ILIsNetConnect (pidl
))
447 if (LoadStringW(netshell_hInstance
, IDS_NETWORKCONNECTION
, pszName
, MAX_PATH
))
449 pszName
[MAX_PATH
-1] = L
'\0';
455 val
= _ILGetValueStruct(pidl
);
458 if (INetConnection_GetProperties(val
->pItem
, &pProperties
) == NOERROR
)
460 if (pProperties
->pszwName
)
462 wcscpy(pszName
, pProperties
->pszwName
);
465 //NcFreeNetconProperties(pProperties);
473 strRet
->uType
= STRRET_WSTR
;
474 strRet
->u
.pOleStr
= pszName
;
478 CoTaskMemFree(pszName
);
484 /**************************************************************************
485 * ISF_NetConnect_fnSetNameOf
486 * Changes the name of a file object or subfolder, possibly changing its item
487 * identifier in the process.
490 * hwndOwner [in] Owner window for output
491 * pidl [in] simple pidl of item to change
492 * lpszName [in] the items new display name
493 * dwFlags [in] SHGNO formatting flags
494 * ppidlOut [out] simple pidl returned
496 static HRESULT WINAPI
ISF_NetConnect_fnSetNameOf (IShellFolder2
* iface
,
497 HWND hwndOwner
, LPCITEMIDLIST pidl
, /*simple pidl */
498 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
500 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
505 static HRESULT WINAPI
ISF_NetConnect_fnGetDefaultSearchGUID (
506 IShellFolder2
* iface
, GUID
* pguid
)
508 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
513 static HRESULT WINAPI
ISF_NetConnect_fnEnumSearches (IShellFolder2
* iface
,
514 IEnumExtraSearch
** ppenum
)
516 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
521 static HRESULT WINAPI
ISF_NetConnect_fnGetDefaultColumn (IShellFolder2
* iface
,
522 DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
524 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
534 static HRESULT WINAPI
ISF_NetConnect_fnGetDefaultColumnState (
535 IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
537 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
539 if (!pcsFlags
|| iColumn
>= NETCONNECTSHELLVIEWCOLUMNS
)
541 *pcsFlags
= NetConnectSFHeader
[iColumn
].pcsFlags
;
545 static HRESULT WINAPI
ISF_NetConnect_fnGetDetailsEx (IShellFolder2
* iface
,
546 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
548 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
553 static HRESULT WINAPI
ISF_NetConnect_fnGetDetailsOf (IShellFolder2
* iface
,
554 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
556 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
557 WCHAR buffer
[MAX_PATH
] = {0};
560 NETCON_PROPERTIES
* pProperties
;
562 if (iColumn
>= NETCONNECTSHELLVIEWCOLUMNS
)
565 psd
->fmt
= NetConnectSFHeader
[iColumn
].fmt
;
566 psd
->cxChar
= NetConnectSFHeader
[iColumn
].cxChar
;
569 psd
->str
.uType
= STRRET_WSTR
;
570 if (LoadStringW(netshell_hInstance
, NetConnectSFHeader
[iColumn
].colnameid
, buffer
, MAX_PATH
))
571 hr
= SHStrDupW(buffer
, &psd
->str
.u
.pOleStr
);
576 if (iColumn
== COLUMN_NAME
)
578 psd
->str
.uType
= STRRET_WSTR
;
579 return IShellFolder2_GetDisplayNameOf(iface
, pidl
, SHGDN_NORMAL
, &psd
->str
);
582 val
= _ILGetValueStruct(pidl
);
589 if (INetConnection_GetProperties((INetConnection
*)val
->pItem
, &pProperties
) != NOERROR
)
596 if (pProperties
->MediaType
== NCM_LAN
|| pProperties
->MediaType
== NCM_SHAREDACCESSHOST_RAS
)
598 if (LoadStringW(netshell_hInstance
, IDS_TYPE_ETHERNET
, buffer
, MAX_PATH
))
600 psd
->str
.uType
= STRRET_WSTR
;
601 hr
= SHStrDupW(buffer
, &psd
->str
.u
.pOleStr
);
607 if (pProperties
->Status
== NCS_HARDWARE_DISABLED
)
608 LoadStringW(netshell_hInstance
, IDS_STATUS_NON_OPERATIONAL
, buffer
, MAX_PATH
);
609 else if (pProperties
->Status
== NCS_DISCONNECTED
)
610 LoadStringW(netshell_hInstance
, IDS_STATUS_UNREACHABLE
, buffer
, MAX_PATH
);
611 else if (pProperties
->Status
== NCS_MEDIA_DISCONNECTED
)
612 LoadStringW(netshell_hInstance
, IDS_STATUS_DISCONNECTED
, buffer
, MAX_PATH
);
613 else if (pProperties
->Status
== NCS_CONNECTING
)
614 LoadStringW(netshell_hInstance
, IDS_STATUS_CONNECTING
, buffer
, MAX_PATH
);
615 else if (pProperties
->Status
== NCS_CONNECTED
)
616 LoadStringW(netshell_hInstance
, IDS_STATUS_CONNECTED
, buffer
, MAX_PATH
);
620 buffer
[MAX_PATH
-1] = L
'\0';
621 psd
->str
.uType
= STRRET_WSTR
;
622 hr
= SHStrDupW(buffer
, &psd
->str
.u
.pOleStr
);
626 if (pProperties
->pszwDeviceName
)
628 wcscpy(buffer
, pProperties
->pszwDeviceName
);
629 buffer
[MAX_PATH
-1] = L
'\0';
630 psd
->str
.uType
= STRRET_WSTR
;
631 hr
= SHStrDupW(buffer
, &psd
->str
.u
.pOleStr
);
636 psd
->str
.u
.cStr
[0] = '\0';
637 psd
->str
.uType
= STRRET_CSTR
;
641 NcFreeNetconProperties(pProperties
);
646 static HRESULT WINAPI
ISF_NetConnect_fnMapColumnToSCID (IShellFolder2
* iface
,
647 UINT column
, SHCOLUMNID
* pscid
)
649 //IGenericSFImpl *This = (IGenericSFImpl *)iface;
654 static const IShellFolder2Vtbl vt_ShellFolder2
= {
655 ISF_NetConnect_fnQueryInterface
,
656 ISF_NetConnect_fnAddRef
,
657 ISF_NetConnect_fnRelease
,
658 ISF_NetConnect_fnParseDisplayName
,
659 ISF_NetConnect_fnEnumObjects
,
660 ISF_NetConnect_fnBindToObject
,
661 ISF_NetConnect_fnBindToStorage
,
662 ISF_NetConnect_fnCompareIDs
,
663 ISF_NetConnect_fnCreateViewObject
,
664 ISF_NetConnect_fnGetAttributesOf
,
665 ISF_NetConnect_fnGetUIObjectOf
,
666 ISF_NetConnect_fnGetDisplayNameOf
,
667 ISF_NetConnect_fnSetNameOf
,
669 ISF_NetConnect_fnGetDefaultSearchGUID
,
670 ISF_NetConnect_fnEnumSearches
,
671 ISF_NetConnect_fnGetDefaultColumn
,
672 ISF_NetConnect_fnGetDefaultColumnState
,
673 ISF_NetConnect_fnGetDetailsEx
,
674 ISF_NetConnect_fnGetDetailsOf
,
675 ISF_NetConnect_fnMapColumnToSCID
678 //IInternetSecurityManager
680 /**************************************************************************
681 * IContextMenu2 Implementation
684 /************************************************************************
685 * ISF_NetConnect_IContextMenu_QueryInterface
687 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_QueryInterface(IContextMenu3
* iface
, REFIID iid
, LPVOID
* ppvObject
)
690 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
692 if (IsEqualIID(iid
, &IID_IContextMenu
) || IsEqualIID(iid
, &IID_IContextMenu2
) || IsEqualIID(iid
, &IID_IContextMenu3
))
694 *ppvObject
= (IUnknown
*) &This
->lpVtblContextMenu
;
695 InterlockedIncrement(&This
->ref
);
698 else if (IsEqualIID(iid
, &IID_IObjectWithSite
))
700 *ppvObject
= (IUnknown
*) &This
->lpVtblObjectWithSite
;
701 InterlockedIncrement(&This
->ref
);
704 else if (IsEqualIID(iid
, &IID_IQueryInfo
))
706 *ppvObject
= (IUnknown
*) &This
->lpVtblQueryInfo
;
707 InterlockedIncrement(&This
->ref
);
711 //StringFromCLSID(iid, &pStr);
712 //MessageBoxW(NULL, L"ISF_NetConnect_IContextMenu2_QueryInterface unhandled", pStr, MB_OK);
713 return E_NOINTERFACE
;
716 /************************************************************************
717 * ISF_NetConnect_IContextMenu_AddRef
719 static ULONG WINAPI
ISF_NetConnect_IContextMenu3_AddRef(IContextMenu3
* iface
)
722 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
724 refCount
= InterlockedIncrement(&This
->ref
);
729 /************************************************************************
730 * ISF_NetConnect_IContextMenu_Release
732 static ULONG WINAPI
ISF_NetConnect_IContextMenu3_Release(IContextMenu3
* iface
)
735 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
737 refCount
= InterlockedDecrement(&This
->ref
);
745 void WINAPI
_InsertMenuItemW (
757 ZeroMemory(&mii
, sizeof(mii
));
758 mii
.cbSize
= sizeof(mii
);
759 if (fType
== MFT_SEPARATOR
)
761 mii
.fMask
= MIIM_ID
| MIIM_TYPE
;
763 else if (fType
== MFT_STRING
)
765 mii
.fMask
= MIIM_ID
| MIIM_TYPE
| MIIM_STATE
;
766 if ((ULONG_PTR
)HIWORD((ULONG_PTR
)dwTypeData
) == 0)
768 if (LoadStringW(netshell_hInstance
, LOWORD((ULONG_PTR
)dwTypeData
), szText
, sizeof(szText
)/sizeof(WCHAR
)))
770 szText
[(sizeof(szText
)/sizeof(WCHAR
))-1] = 0;
771 mii
.dwTypeData
= szText
;
780 mii
.dwTypeData
= (LPWSTR
) dwTypeData
;
787 InsertMenuItemW( hmenu
, indexMenu
, fByPosition
, &mii
);
790 /**************************************************************************
791 * ISF_NetConnect_IContextMenu_QueryContextMenu()
793 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_QueryContextMenu(
794 IContextMenu3
*iface
,
801 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
803 NETCON_PROPERTIES
* pProperties
;
805 val
= _ILGetValueStruct(This
->apidl
);
809 if (INetConnection_GetProperties((INetConnection
*)val
->pItem
, &pProperties
) != NOERROR
)
813 if (pProperties
->Status
== NCS_HARDWARE_DISABLED
)
814 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_ACTIVATE
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_ACTIVATE
), MFS_DEFAULT
);
816 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_DEACTIVATE
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_DEACTIVATE
), MFS_ENABLED
);
818 if (pProperties
->Status
== NCS_HARDWARE_DISABLED
|| pProperties
->Status
== NCS_MEDIA_DISCONNECTED
|| pProperties
->Status
== NCS_DISCONNECTED
)
819 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_STATUS
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_STATUS
), MFS_GRAYED
);
820 else if (pProperties
->Status
== NCS_CONNECTED
)
821 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_STATUS
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_STATUS
), MFS_DEFAULT
);
823 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_STATUS
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_STATUS
), MFS_ENABLED
);
825 if (pProperties
->Status
== NCS_HARDWARE_DISABLED
|| pProperties
->Status
== NCS_MEDIA_DISCONNECTED
)
826 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_REPAIR
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_REPAIR
), MFS_GRAYED
);
828 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_REPAIR
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_REPAIR
), MFS_ENABLED
);
830 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, -1, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
831 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_CREATELINK
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_CREATELINK
), MFS_ENABLED
);
833 if (pProperties
->dwCharacter
& NCCF_ALLOW_REMOVAL
)
834 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_DELETE
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_DELETE
), MFS_ENABLED
);
836 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_DELETE
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_DELETE
), MFS_GRAYED
);
838 if (pProperties
->dwCharacter
& NCCF_ALLOW_RENAME
)
839 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_RENAME
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_RENAME
), MFS_ENABLED
);
841 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_RENAME
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_RENAME
), MFS_GRAYED
);
843 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, -1, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
844 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, IDS_NET_PROPERTIES
, MFT_STRING
, MAKEINTRESOURCEW(IDS_NET_PROPERTIES
), MFS_ENABLED
);
846 return MAKE_HRESULT(SEVERITY_SUCCESS
, 0, 9);
851 PropSheetExCallback(HPROPSHEETPAGE hPage
, LPARAM lParam
)
853 PROPSHEETHEADERW
*pinfo
= (PROPSHEETHEADERW
*)lParam
;
855 if (pinfo
->nPages
< MAX_PROPERTY_SHEET_PAGE
)
857 pinfo
->u3
.phpage
[pinfo
->nPages
++] = hPage
;
864 ShowNetConnectionStatus(
865 IContextMenuImpl
* This
,
866 INetConnection
* pNetConnect
,
869 NETCON_PROPERTIES
* pProperties
;
875 if (INetConnection_GetProperties(pNetConnect
, &pProperties
) != NOERROR
)
878 hr
= IOleCommandTarget_Exec(This
->lpOleCmd
, &pProperties
->guidId
, 2, OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
880 NcFreeNetconProperties(pProperties
);
885 ShowNetConnectionProperties(
886 INetConnection
* pNetConnect
,
891 PROPSHEETHEADERW pinfo
;
892 HPROPSHEETPAGE hppages
[MAX_PROPERTY_SHEET_PAGE
];
893 INetConnectionPropertyUi
* pNCP
;
894 NETCON_PROPERTIES
* pProperties
;
896 if (INetConnection_GetProperties(pNetConnect
, &pProperties
) != NOERROR
)
899 hr
= INetConnection_GetUiObjectClassId(pNetConnect
, &ClassID
);
902 NcFreeNetconProperties(pProperties
);
906 hr
= CoCreateInstance(&ClassID
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetConnectionPropertyUi
, (LPVOID
)&pNCP
);
909 NcFreeNetconProperties(pProperties
);
913 hr
= INetConnectionPropertyUi_SetConnection(pNCP
, pNetConnect
);
916 ZeroMemory(&pinfo
, sizeof(PROPSHEETHEADERW
));
917 ZeroMemory(hppages
, sizeof(hppages
));
918 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
919 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
| PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
920 pinfo
.u3
.phpage
= hppages
;
921 pinfo
.hwndParent
= hwnd
;
923 pinfo
.pszCaption
= pProperties
->pszwName
;
924 hr
= INetConnectionPropertyUi_AddPages(pNCP
, hwnd
, PropSheetExCallback
, (LPARAM
)&pinfo
);
927 if(PropertySheetW(&pinfo
) < 0)
931 INetConnectionPropertyUi_Release(pNCP
);
932 NcFreeNetconProperties(pProperties
);
937 /**************************************************************************
938 * ISF_NetConnect_IContextMenu_InvokeCommand()
940 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_InvokeCommand(
941 IContextMenu3
*iface
,
942 LPCMINVOKECOMMANDINFO lpcmi
)
944 IContextMenuImpl
* This
= (IContextMenuImpl
*)iface
;
947 val
= _ILGetValueStruct(This
->apidl
);
951 if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(IDS_NET_STATUS
) ||
952 lpcmi
->lpVerb
== MAKEINTRESOURCEA(IDS_NET_STATUS
-1)) //HACK for Windows XP
954 return ShowNetConnectionStatus(This
, val
->pItem
, lpcmi
->hwnd
);
956 else if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(IDS_NET_PROPERTIES
) ||
957 lpcmi
->lpVerb
== MAKEINTRESOURCEA(10099)) //HACK for Windows XP
959 /* FIXME perform version checks */
960 return ShowNetConnectionProperties(val
->pItem
, lpcmi
->hwnd
);
966 /**************************************************************************
967 * ISF_NetConnect_IContextMenu_GetCommandString()
970 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_GetCommandString(
971 IContextMenu3
*iface
,
983 /**************************************************************************
984 * ISF_NetConnect_IContextMenu_HandleMenuMsg()
986 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_HandleMenuMsg(
987 IContextMenu3
*iface
,
995 static HRESULT WINAPI
ISF_NetConnect_IContextMenu3_HandleMenuMsg2(
996 IContextMenu3
*iface
,
1006 static const IContextMenu3Vtbl vt_ContextMenu3
=
1008 ISF_NetConnect_IContextMenu3_QueryInterface
,
1009 ISF_NetConnect_IContextMenu3_AddRef
,
1010 ISF_NetConnect_IContextMenu3_Release
,
1011 ISF_NetConnect_IContextMenu3_QueryContextMenu
,
1012 ISF_NetConnect_IContextMenu3_InvokeCommand
,
1013 ISF_NetConnect_IContextMenu3_GetCommandString
,
1014 ISF_NetConnect_IContextMenu3_HandleMenuMsg
,
1015 ISF_NetConnect_IContextMenu3_HandleMenuMsg2
1018 static HRESULT WINAPI
ISF_NetConnect_IObjectWithSite_QueryInterface (IObjectWithSite
* iface
,
1019 REFIID iid
, LPVOID
* ppvObj
)
1021 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1023 if (IsEqualIID(iid
, &IID_IObjectWithSite
))
1025 *ppvObj
= (IUnknown
*)&This
->lpVtblObjectWithSite
;
1028 return E_NOINTERFACE
;
1031 /************************************************************************
1032 * ISF_NetConnect_IQueryInfo_AddRef
1034 static ULONG WINAPI
ISF_NetConnect_IObjectWithSite_AddRef (IObjectWithSite
* iface
)
1036 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1038 return IContextMenu2_AddRef((IContextMenu2
*)This
);
1041 /************************************************************************
1042 * ISF_NetConnect_IQueryInfo_Release
1044 static ULONG WINAPI
ISF_NetConnect_IObjectWithSite_Release (IObjectWithSite
* iface
)
1046 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1048 return IContextMenu_Release((IContextMenu
*)This
);
1051 /************************************************************************
1052 * ISF_NetConnect_PersistFolder2_Release
1054 static HRESULT WINAPI
ISF_NetConnect_IObjectWithSite_GetSite (IObjectWithSite
* iface
, REFIID riid
, PVOID
*ppvSite
)
1058 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1060 if (!This
->pUnknown
)
1066 hr
= IUnknown_QueryInterface(This
->pUnknown
, riid
, (LPVOID
*)&pUnknown
);
1069 IUnknown_AddRef(pUnknown
);
1070 *ppvSite
= pUnknown
;
1078 static HRESULT WINAPI
ISF_NetConnect_IObjectWithSite_SetSite (IObjectWithSite
* iface
, IUnknown
*pUnkSite
)
1080 IContextMenuImpl
* This
= impl_from_IObjectWithSite(iface
);
1086 IUnknown_Release(This
->pUnknown
);
1087 This
->pUnknown
= NULL
;
1092 IUnknown_AddRef(pUnkSite
);
1094 IUnknown_Release(This
->pUnknown
);
1095 This
->pUnknown
= pUnkSite
;
1102 static const IObjectWithSiteVtbl vt_ObjectWithSite
=
1104 ISF_NetConnect_IObjectWithSite_QueryInterface
,
1105 ISF_NetConnect_IObjectWithSite_AddRef
,
1106 ISF_NetConnect_IObjectWithSite_Release
,
1107 ISF_NetConnect_IObjectWithSite_SetSite
,
1108 ISF_NetConnect_IObjectWithSite_GetSite
1111 static HRESULT WINAPI
ISF_NetConnect_IExtractIconW_QueryInterface (IExtractIconW
* iface
,
1112 REFIID iid
, LPVOID
* ppvObj
)
1114 IContextMenuImpl
* This
= impl_from_IExtractIcon(iface
);
1116 if (IsEqualIID(iid
, &IID_IExtractIconW
))
1118 *ppvObj
= (IUnknown
*)&This
->lpVtblExtractIconW
;
1121 return E_NOINTERFACE
;
1124 /************************************************************************
1125 * ISF_NetConnect_IExtractIcon_AddRef
1127 static ULONG WINAPI
ISF_NetConnect_IExtractIconW_AddRef (IExtractIconW
* iface
)
1129 IContextMenuImpl
* This
= impl_from_IExtractIcon(iface
);
1131 return IContextMenu2_AddRef((IContextMenu2
*)This
);
1134 /************************************************************************
1135 * ISF_NetConnect_IExtractIcon_Release
1137 static ULONG WINAPI
ISF_NetConnect_IExtractIconW_Release (IExtractIconW
* iface
)
1139 IContextMenuImpl
* This
= impl_from_IExtractIcon(iface
);
1141 return IContextMenu_Release((IContextMenu
*)This
);
1144 /************************************************************************
1145 * ISF_NetConnect_IExtractIcon_GetIconLocation
1147 static HRESULT WINAPI
ISF_NetConnect_IExtractIconW_GetIconLocation(
1148 IExtractIconW
* iface
,
1156 NETCON_PROPERTIES
* pProperties
;
1157 IContextMenuImpl
* This
= impl_from_IExtractIcon(iface
);
1160 if (!GetModuleFileNameW(netshell_hInstance
, szIconFile
, cchMax
))
1163 val
= _ILGetValueStruct(This
->apidl
);
1167 if (INetConnection_GetProperties(val
->pItem
, &pProperties
) != NOERROR
)
1170 if (pProperties
->Status
== NCS_CONNECTED
|| pProperties
->Status
== NCS_CONNECTING
)
1171 *piIndex
= IDI_NET_IDLE
;
1173 *piIndex
= IDI_NET_OFF
;
1175 NcFreeNetconProperties(pProperties
);
1180 /************************************************************************
1181 * ISF_NetConnect_IExtractIcon_Extract
1183 static HRESULT WINAPI
ISF_NetConnect_IExtractIconW_Extract(
1184 IExtractIconW
* iface
,
1191 //IContextMenuImpl * This = impl_from_IExtractIcon(iface);
1192 if (nIconIndex
== IDI_NET_IDLE
)
1194 *phiconLarge
= LoadImage(netshell_hInstance
, MAKEINTRESOURCE(IDI_NET_IDLE
), IMAGE_ICON
, 32, 32, LR_DEFAULTCOLOR
);
1195 *phiconSmall
= LoadImage(netshell_hInstance
, MAKEINTRESOURCE(IDI_NET_IDLE
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
);
1198 else if (nIconIndex
== IDI_NET_OFF
)
1200 *phiconLarge
= LoadImage(netshell_hInstance
, MAKEINTRESOURCE(IDI_NET_OFF
), IMAGE_ICON
, 32, 32, LR_DEFAULTCOLOR
);
1201 *phiconSmall
= LoadImage(netshell_hInstance
, MAKEINTRESOURCE(IDI_NET_OFF
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
);
1208 static const IExtractIconWVtbl vt_ExtractIconW
=
1210 ISF_NetConnect_IExtractIconW_QueryInterface
,
1211 ISF_NetConnect_IExtractIconW_AddRef
,
1212 ISF_NetConnect_IExtractIconW_Release
,
1213 ISF_NetConnect_IExtractIconW_GetIconLocation
,
1214 ISF_NetConnect_IExtractIconW_Extract
1223 /************************************************************************
1224 * ISF_NetConnect_PersistFolder2_QueryInterface
1226 static HRESULT WINAPI
ISF_NetConnect_PersistFolder2_QueryInterface (IPersistFolder2
* iface
,
1227 REFIID iid
, LPVOID
* ppvObj
)
1229 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1231 return IShellFolder2_QueryInterface ((IShellFolder2
*)This
, iid
, ppvObj
);
1234 /************************************************************************
1235 * ISF_NetConnect_PersistFolder2_AddRef
1237 static ULONG WINAPI
ISF_NetConnect_PersistFolder2_AddRef (IPersistFolder2
* iface
)
1239 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1241 return IShellFolder2_AddRef((IShellFolder2
*)This
);
1244 /************************************************************************
1245 * ISF_NetConnect_PersistFolder2_Release
1247 static ULONG WINAPI
ISF_NetConnect_PersistFolder2_Release (IPersistFolder2
* iface
)
1249 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1251 return IShellFolder2_Release((IShellFolder2
*)This
);
1254 /************************************************************************
1255 * ISF_NetConnect_PersistFolder2_GetClassID
1257 static HRESULT WINAPI
ISF_NetConnect_PersistFolder2_GetClassID (
1258 IPersistFolder2
* iface
, CLSID
* lpClassId
)
1260 //IGenericSFImpl * This = impl_from_IPersistFolder2(iface);
1265 *lpClassId
= CLSID_NetworkConnections
;
1270 /************************************************************************
1271 * ISF_NetConnect_PersistFolder2_Initialize
1273 * NOTES: it makes no sense to change the pidl
1275 static HRESULT WINAPI
ISF_NetConnect_PersistFolder2_Initialize (
1276 IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
1278 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1280 SHFree(This
->pidlRoot
);
1281 This
->pidlRoot
= ILClone(pidl
);
1286 /**************************************************************************
1287 * ISF_NetConnect_PersistFolder2_GetCurFolder
1289 static HRESULT WINAPI
ISF_NetConnect_PersistFolder2_GetCurFolder (
1290 IPersistFolder2
* iface
, LPITEMIDLIST
* pidl
)
1292 IGenericSFImpl
* This
= impl_from_IPersistFolder2(iface
);
1298 *pidl
= ILClone (This
->pidlRoot
);
1303 static const IPersistFolder2Vtbl vt_PersistFolder2
=
1305 ISF_NetConnect_PersistFolder2_QueryInterface
,
1306 ISF_NetConnect_PersistFolder2_AddRef
,
1307 ISF_NetConnect_PersistFolder2_Release
,
1308 ISF_NetConnect_PersistFolder2_GetClassID
,
1309 ISF_NetConnect_PersistFolder2_Initialize
,
1310 ISF_NetConnect_PersistFolder2_GetCurFolder
1314 static const IPersistIDListVtbl vt_PersistIDList
=
1316 ISF_NetConnect_PersistIDList_QueryInterface
,
1317 ISF_NetConnect_PersistIDList_AddRef
,
1318 ISF_NetConnect_PersistIDList_Release
,
1319 ISF_NetConnect_PersistIDList_GetClassID
,
1320 ISF_NetConnect_PersistIDList_SetIDList
,
1321 ISF_NetConnect_PersistIDList_GetIDList
,
1325 /************************************************************************
1326 * ISF_NetConnect_PersistFolder2_QueryInterface
1328 static HRESULT WINAPI
ISF_NetConnect_IQueryInfo_QueryInterface (IQueryInfo
* iface
,
1329 REFIID iid
, LPVOID
* ppvObj
)
1331 IContextMenuImpl
* This
= impl_from_IQueryInfo(iface
);
1333 if (IsEqualIID(iid
, &IID_IQueryInfo
))
1335 *ppvObj
= (IUnknown
*)&This
->lpVtblQueryInfo
;
1339 return E_NOINTERFACE
;
1342 /************************************************************************
1343 * ISF_NetConnect_PersistFolder2_AddRef
1345 static ULONG WINAPI
ISF_NetConnect_IQueryInfo_AddRef (IQueryInfo
* iface
)
1347 IContextMenuImpl
* This
= impl_from_IQueryInfo(iface
);
1349 return IContextMenu2_AddRef((IContextMenu2
*)This
);
1352 /************************************************************************
1353 * ISF_NetConnect_PersistFolder2_Release
1355 static ULONG WINAPI
ISF_NetConnect_IQueryInfo_Release (IQueryInfo
* iface
)
1357 IContextMenuImpl
* This
= impl_from_IQueryInfo(iface
);
1359 return IContextMenu_Release((IContextMenu
*)This
);
1362 /************************************************************************
1363 * ISF_NetConnect_PersistFolder2_GetClassID
1365 static HRESULT WINAPI
ISF_NetConnect_IQueryInfo_GetInfoFlags (
1366 IQueryInfo
* iface
, DWORD
*pdwFlags
)
1373 /************************************************************************
1374 * ISF_NetConnect_PersistFolder2_Initialize
1376 * NOTES: it makes no sense to change the pidl
1378 static HRESULT WINAPI
ISF_NetConnect_IQueryInfo_GetInfoTip (
1379 IQueryInfo
* iface
, DWORD dwFlags
, WCHAR
**ppwszTip
)
1381 // IGenericSFImpl * This = impl_from_IQueryInfo(iface);
1387 static const IQueryInfoVtbl vt_QueryInfo
=
1389 ISF_NetConnect_IQueryInfo_QueryInterface
,
1390 ISF_NetConnect_IQueryInfo_AddRef
,
1391 ISF_NetConnect_IQueryInfo_Release
,
1392 ISF_NetConnect_IQueryInfo_GetInfoTip
,
1393 ISF_NetConnect_IQueryInfo_GetInfoFlags
1396 /**************************************************************************
1397 * ISF_NetConnect_Constructor
1399 HRESULT WINAPI
ISF_NetConnect_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
1407 return CLASS_E_NOAGGREGATION
;
1409 sf
= (IGenericSFImpl
*) CoTaskMemAlloc(sizeof (IGenericSFImpl
));
1411 return E_OUTOFMEMORY
;
1414 sf
->lpVtbl
= &vt_ShellFolder2
;
1415 sf
->lpVtblPersistFolder2
= &vt_PersistFolder2
;
1417 hr
= CoCreateInstance(&CLSID_LanConnectStatusUI
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IOleCommandTarget
, (LPVOID
*)&sf
->lpOleCmd
);
1419 sf
->lpOleCmd
= NULL
;
1422 IOleCommandTarget_Exec(sf
->lpOleCmd
, &CGID_ShellServiceObject
, 2, OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
1425 sf
->pidlRoot
= _ILCreateNetConnect(); /* my qualified pidl */
1427 if (!SUCCEEDED (IShellFolder2_QueryInterface ((IShellFolder2
*)sf
, riid
, ppv
)))
1429 IShellFolder2_Release((IShellFolder2
*)sf
);
1430 return E_NOINTERFACE
;