https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c73d8c64bbed43e93a2d7…
commit c73d8c64bbed43e93a2d757f341ef5c3296456e8
Author: Giannis Adamopoulos <gadamopoulos(a)reactos.org>
AuthorDate: Mon Nov 12 13:23:38 2018 +0200
Commit: Giannis Adamopoulos <gadamopoulos(a)reactos.org>
CommitDate: Sun Nov 18 14:01:54 2018 +0200
[NETSHELL] Use ATL
---
dll/shellext/netshell/CMakeLists.txt | 13 +-
dll/shellext/netshell/classfactory.cpp | 105 ---------
dll/shellext/netshell/connectmanager.cpp | 273 +++++------------------
dll/shellext/netshell/connectmanager.h | 75 +++++++
dll/shellext/netshell/enumlist.cpp | 124 ++++++++---
dll/shellext/netshell/enumlist.h | 52 -----
dll/shellext/netshell/lanconnectui.cpp | 163 +-------------
dll/shellext/netshell/lanconnectui.h | 69 ++++++
dll/shellext/netshell/lanstatusui.cpp | 124 +----------
dll/shellext/netshell/lanstatusui.h | 62 ++++++
dll/shellext/netshell/netshell.cpp | 72 ++++--
dll/shellext/netshell/netshell.rc | 2 +-
dll/shellext/netshell/precomp.h | 44 ++--
dll/shellext/netshell/shfldr_netconnect.cpp | 328 +---------------------------
dll/shellext/netshell/shfldr_netconnect.h | 137 ++++++++++++
15 files changed, 596 insertions(+), 1047 deletions(-)
diff --git a/dll/shellext/netshell/CMakeLists.txt b/dll/shellext/netshell/CMakeLists.txt
index 3a5f4a5f1f..cff3ce29e4 100644
--- a/dll/shellext/netshell/CMakeLists.txt
+++ b/dll/shellext/netshell/CMakeLists.txt
@@ -11,6 +11,11 @@ endif()
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
+add_definitions(
+ -D_ATL_NO_EXCEPTIONS)
+
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
+
add_definitions(-D_NETSHELL_)
spec2def(netshell.dll netshell.spec)
@@ -18,7 +23,6 @@ list(APPEND SOURCE
netshell.cpp
shfldr_netconnect.cpp
enumlist.cpp
- classfactory.cpp
connectmanager.cpp
lanconnectui.cpp
lanstatusui.cpp
@@ -34,8 +38,9 @@ add_library(netshell SHARED
${CMAKE_CURRENT_BINARY_DIR}/netshell_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/netshell.def)
-set_module_type(netshell win32dll)
-target_link_libraries(netshell uuid wine)
-add_importlibs(netshell shlwapi shell32 version iphlpapi ole32 gdi32 user32 advapi32
setupapi ws2_32 comctl32 msvcrt kernel32 ntdll)
+set_module_type(netshell win32dll UNICODE)
+target_link_libraries(netshell atlnew uuid wine)
+add_delay_importlibs(netshell ole32 oleaut32 shlwapi shell32)
+add_importlibs(netshell version iphlpapi gdi32 user32 advapi32 setupapi ws2_32 comctl32
msvcrt kernel32 ntdll)
add_pch(netshell precomp.h SOURCE)
add_cd_file(TARGET netshell DESTINATION reactos/system32 FOR all)
diff --git a/dll/shellext/netshell/classfactory.cpp
b/dll/shellext/netshell/classfactory.cpp
deleted file mode 100644
index 1e4d5fed34..0000000000
--- a/dll/shellext/netshell/classfactory.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "precomp.h"
-
-class CNetshellClassFactory final :
- public IClassFactory
-{
- public:
- CNetshellClassFactory(REFCLSID rclsid);
-
- /* IUnknown */
- virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
- virtual ULONG WINAPI AddRef();
- virtual ULONG WINAPI Release();
-
- /* IClassFactory */
- virtual HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID
*ppvObject);
- virtual HRESULT WINAPI LockServer(BOOL fLock);
-
- private:
- LONG m_ref;
- CLSID m_clsid;
-};
-
-CNetshellClassFactory::CNetshellClassFactory(REFCLSID rclsid) :
- m_ref(0),
- m_clsid(rclsid)
-{
-}
-
-HRESULT
-WINAPI
-CNetshellClassFactory::QueryInterface(
- REFIID riid,
- LPVOID *ppvObj)
-{
- *ppvObj = NULL;
- if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
- {
- *ppvObj = static_cast<IClassFactory*>(this);
- AddRef();
- return S_OK;
- }
- return E_NOINTERFACE;
-}
-
-ULONG
-WINAPI
-CNetshellClassFactory::AddRef()
-{
- ULONG refCount = InterlockedIncrement(&m_ref);
-
- return refCount;
-}
-
-ULONG
-WINAPI
-CNetshellClassFactory::Release()
-{
- ULONG refCount = InterlockedDecrement(&m_ref);
-
- if (!refCount)
- delete this;
-
- return refCount;
-}
-
-HRESULT
-WINAPI
-CNetshellClassFactory::CreateInstance(
- LPUNKNOWN pUnkOuter,
- REFIID riid,
- LPVOID *ppvObject)
-{
- *ppvObject = NULL;
-
- if (IsEqualCLSID(m_clsid, CLSID_ConnectionFolder))
- return ISF_NetConnect_Constructor(pUnkOuter, riid, ppvObject);
- else if (IsEqualCLSID(m_clsid, CLSID_ConnectionManager))
- return INetConnectionManager_Constructor(pUnkOuter, riid, ppvObject);
- else if (IsEqualCLSID(m_clsid, CLSID_LanConnectionUi))
- return LanConnectUI_Constructor(pUnkOuter, riid, ppvObject);
- else if (IsEqualCLSID(m_clsid, CLSID_ConnectionTray))
- return LanConnectStatusUI_Constructor(pUnkOuter, riid, ppvObject);
-
- return E_NOINTERFACE;
-}
-
-HRESULT
-WINAPI
-CNetshellClassFactory::LockServer(BOOL fLock)
-{
- return E_NOTIMPL;
-}
-
-HRESULT IClassFactory_fnConstructor(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
-{
- CNetshellClassFactory *pClsFactory = new CNetshellClassFactory(rclsid);
- if (!pClsFactory)
- return E_OUTOFMEMORY;
-
- pClsFactory->AddRef();
- HRESULT hr = pClsFactory->QueryInterface(riid, ppvOut);
- pClsFactory->Release();
-
- return hr;
-}
diff --git a/dll/shellext/netshell/connectmanager.cpp
b/dll/shellext/netshell/connectmanager.cpp
index f71d58f81a..88780be11d 100644
--- a/dll/shellext/netshell/connectmanager.cpp
+++ b/dll/shellext/netshell/connectmanager.cpp
@@ -7,146 +7,19 @@
#include "precomp.h"
-typedef struct tagINetConnectionItem
-{
- struct tagINetConnectionItem * Next;
- DWORD dwAdapterIndex;
- NETCON_PROPERTIES Props;
-} INetConnectionItem, *PINetConnectionItem;
-
-class CNetConnectionManager final :
- public INetConnectionManager,
- public IEnumNetConnection
-{
- public:
- CNetConnectionManager();
- BOOL EnumerateINetConnections();
-
- // IUnknown
- virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
- virtual ULONG WINAPI AddRef();
- virtual ULONG WINAPI Release();
-
- // INetConnectionManager
- virtual HRESULT WINAPI EnumConnections(NETCONMGR_ENUM_FLAGS Flags,
IEnumNetConnection **ppEnum);
-
- // IEnumNetConnection
- virtual HRESULT WINAPI Next(ULONG celt, INetConnection **rgelt, ULONG
*pceltFetched);
- virtual HRESULT WINAPI Skip(ULONG celt);
- virtual HRESULT WINAPI Reset();
- virtual HRESULT WINAPI Clone(IEnumNetConnection **ppenum);
-
- private:
- LONG m_ref;
- PINetConnectionItem m_pHead;
- PINetConnectionItem m_pCurrent;
-};
-
-class CNetConnection final :
- public INetConnection
-{
- public:
- CNetConnection(PINetConnectionItem pItem);
-
- // IUnknown
- virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
- virtual ULONG WINAPI AddRef();
- virtual ULONG WINAPI Release();
-
- // INetConnection
- HRESULT WINAPI Connect();
- HRESULT WINAPI Disconnect();
- HRESULT WINAPI Delete();
- HRESULT WINAPI Duplicate(LPCWSTR pszwDuplicateName, INetConnection **ppCon);
- HRESULT WINAPI GetProperties(NETCON_PROPERTIES **ppProps);
- HRESULT WINAPI GetUiObjectClassId(CLSID *pclsid);
- HRESULT WINAPI Rename(LPCWSTR pszwDuplicateName);
-
- private:
- ~CNetConnection();
-
- LONG m_ref;
- NETCON_PROPERTIES m_Props;
- DWORD m_dwAdapterIndex;
-};
-
VOID NormalizeOperStatus(MIB_IFROW *IfEntry, NETCON_PROPERTIES * Props);
-CNetConnectionManager::CNetConnectionManager() :
- m_ref(0),
- m_pHead(NULL),
- m_pCurrent(NULL)
-{
-}
-
-HRESULT
-WINAPI
-CNetConnectionManager::QueryInterface(
- REFIID iid,
- LPVOID *ppvObj)
-{
- *ppvObj = NULL;
-
- if (IsEqualIID(iid, IID_IUnknown) ||
- IsEqualIID(iid, IID_INetConnectionManager))
- {
- *ppvObj = static_cast<INetConnectionManager*>(this);
- AddRef();
- return S_OK;
- }
-
- return E_NOINTERFACE;
-}
-
-ULONG
-WINAPI
-CNetConnectionManager::AddRef()
-{
- ULONG refCount = InterlockedIncrement(&m_ref);
-
- return refCount;
-}
-
-ULONG
-WINAPI
-CNetConnectionManager::Release()
-{
- ULONG refCount = InterlockedDecrement(&m_ref);
-
- if (!refCount)
- delete this;
-
- return refCount;
-}
-
-HRESULT
-WINAPI
-CNetConnectionManager::EnumConnections(
- NETCONMGR_ENUM_FLAGS Flags,
- IEnumNetConnection **ppEnum)
-{
- TRACE("EnumConnections\n");
-
- if (!ppEnum)
- return E_POINTER;
-
- if (Flags != NCME_DEFAULT)
- return E_FAIL;
-
- *ppEnum = static_cast<IEnumNetConnection*>(this);
- AddRef();
- return S_OK;
-}
-
/***************************************************************
* INetConnection Interface
*/
-CNetConnection::CNetConnection(PINetConnectionItem pItem) :
- m_ref(0),
- m_Props(pItem->Props),
- m_dwAdapterIndex(pItem->dwAdapterIndex)
+HRESULT
+WINAPI
+CNetConnection::Initialize(PINetConnectionItem pItem)
{
+ m_Props = pItem->Props;
+ m_dwAdapterIndex = pItem->dwAdapterIndex;
+
if (pItem->Props.pszwName)
{
m_Props.pszwName =
static_cast<PWSTR>(CoTaskMemAlloc((wcslen(pItem->Props.pszwName)+1)*sizeof(WCHAR)));
@@ -160,6 +33,8 @@ CNetConnection::CNetConnection(PINetConnectionItem pItem) :
if (m_Props.pszwDeviceName)
wcscpy(m_Props.pszwDeviceName, pItem->Props.pszwDeviceName);
}
+
+ return S_OK;
}
CNetConnection::~CNetConnection()
@@ -168,46 +43,6 @@ CNetConnection::~CNetConnection()
CoTaskMemFree(m_Props.pszwDeviceName);
}
-HRESULT
-WINAPI
-CNetConnection::QueryInterface(
- REFIID iid,
- LPVOID * ppvObj)
-{
- *ppvObj = NULL;
-
- if (IsEqualIID(iid, IID_IUnknown) ||
- IsEqualIID(iid, IID_INetConnection))
- {
- *ppvObj = this;
- AddRef();
- return S_OK;
- }
-
- return E_NOINTERFACE;
-}
-
-ULONG
-WINAPI
-CNetConnection::AddRef()
-{
- ULONG refCount = InterlockedIncrement(&m_ref);
-
- return refCount;
-}
-
-ULONG
-WINAPI
-CNetConnection::Release()
-{
- ULONG refCount = InterlockedDecrement(&m_ref);
-
- if (!refCount)
- delete this;
-
- return refCount;
-}
-
HRESULT
WINAPI
CNetConnection::Connect()
@@ -390,21 +225,37 @@ CNetConnection::Rename(LPCWSTR pszwDuplicateName)
return hr;
}
-HRESULT WINAPI IConnection_Constructor(INetConnection **ppv, PINetConnectionItem pItem)
+HRESULT WINAPI CNetConnection_CreateInstance(PINetConnectionItem pItem, REFIID riid,
LPVOID * ppv)
{
- if (!ppv)
- return E_POINTER;
+ return ShellObjectCreatorInit<CNetConnection>(pItem, riid, ppv);
+}
- CNetConnection *pConnection = new CNetConnection(pItem);
- if (!pConnection)
- return E_OUTOFMEMORY;
- pConnection->AddRef();
- *ppv = pConnection;
- return S_OK;
+CNetConnectionManager::CNetConnectionManager() :
+ m_pHead(NULL),
+ m_pCurrent(NULL)
+{
}
+HRESULT
+WINAPI
+CNetConnectionManager::EnumConnections(
+ NETCONMGR_ENUM_FLAGS Flags,
+ IEnumNetConnection **ppEnum)
+{
+ TRACE("EnumConnections\n");
+
+ if (!ppEnum)
+ return E_POINTER;
+
+ if (Flags != NCME_DEFAULT)
+ return E_FAIL;
+
+ *ppEnum = static_cast<IEnumNetConnection*>(this);
+ AddRef();
+ return S_OK;
+}
/***************************************************************
* IEnumNetConnection Interface
@@ -428,7 +279,7 @@ CNetConnectionManager::Next(
if (!m_pCurrent)
return S_FALSE;
- hr = IConnection_Constructor(rgelt, m_pCurrent);
+ hr = CNetConnection_CreateInstance(m_pCurrent, IID_PPV_ARG(INetConnection, rgelt));
m_pCurrent = m_pCurrent->Next;
return hr;
@@ -517,7 +368,7 @@ NormalizeOperStatus(
}
}
-BOOL
+HRESULT
CNetConnectionManager::EnumerateINetConnections()
{
DWORD dwSize, dwResult, dwIndex, dwAdapterIndex, dwShowIcon, dwNotifyDisconnect;
@@ -536,17 +387,17 @@ CNetConnectionManager::EnumerateINetConnections()
/* get the IfTable */
dwSize = 0;
if (GetIfTable(NULL, &dwSize, TRUE) != ERROR_INSUFFICIENT_BUFFER)
- return FALSE;
+ return E_FAIL;
pIfTable = static_cast<PMIB_IFTABLE>(CoTaskMemAlloc(dwSize));
if (!pIfTable)
- return FALSE;
+ return E_OUTOFMEMORY;
dwResult = GetIfTable(pIfTable, &dwSize, TRUE);
if (dwResult != NO_ERROR)
{
CoTaskMemFree(pIfTable);
- return FALSE;
+ return HRESULT_FROM_WIN32(dwResult);
}
dwSize = 0;
@@ -554,21 +405,22 @@ CNetConnectionManager::EnumerateINetConnections()
if (dwResult!= ERROR_BUFFER_OVERFLOW)
{
CoTaskMemFree(pIfTable);
- return FALSE;
+ return HRESULT_FROM_WIN32(dwResult);
}
pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
if (!pAdapterInfo)
{
CoTaskMemFree(pIfTable);
- return FALSE;
+ return E_OUTOFMEMORY;
}
- if (GetAdaptersInfo(pAdapterInfo, &dwSize) != NO_ERROR)
+ dwResult = GetAdaptersInfo(pAdapterInfo, &dwSize);
+ if (dwResult != NO_ERROR)
{
CoTaskMemFree(pIfTable);
CoTaskMemFree(pAdapterInfo);
- return FALSE;
+ return HRESULT_FROM_WIN32(dwResult);
}
hInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT );
@@ -576,7 +428,7 @@ CNetConnectionManager::EnumerateINetConnections()
{
CoTaskMemFree(pIfTable);
CoTaskMemFree(pAdapterInfo);
- return FALSE;
+ return E_FAIL;
}
dwIndex = 0;
@@ -690,31 +542,22 @@ CNetConnectionManager::EnumerateINetConnections()
SetupDiDestroyDeviceInfoList(hInfo);
m_pCurrent = m_pHead;
- return TRUE;
+ return (m_pHead != NULL ? S_OK : S_FALSE);
}
-HRESULT WINAPI INetConnectionManager_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID
* ppv)
+HRESULT CNetConnectionManager::Initialize()
{
- TRACE("INetConnectionManager_Constructor\n");
-
- if (!ppv)
- return E_POINTER;
- if (pUnkOuter)
- return CLASS_E_NOAGGREGATION;
-
- CNetConnectionManager *pConnectionMgr = new CNetConnectionManager;
- if (!pConnectionMgr)
- return E_OUTOFMEMORY;
-
- pConnectionMgr->AddRef();
- HRESULT hr = pConnectionMgr->QueryInterface(riid, ppv);
-
- if (SUCCEEDED(hr))
- pConnectionMgr->EnumerateINetConnections();
-
- pConnectionMgr->Release();
-
- return hr;
+ HRESULT hr = EnumerateINetConnections();
+ if (FAILED_UNEXPECTEDLY(hr))
+ {
+ /* If something went wrong during the enumeration print an error don't
enumerate anything */
+ m_pCurrent = m_pHead = NULL;
+ return S_FALSE;
+ }
+ return S_OK;
}
-
+HRESULT WINAPI CNetConnectionManager_CreateInstance(REFIID riid, LPVOID * ppv)
+{
+ return ShellObjectCreatorInit<CNetConnectionManager>(riid, ppv);
+}
diff --git a/dll/shellext/netshell/connectmanager.h
b/dll/shellext/netshell/connectmanager.h
new file mode 100644
index 0000000000..a4a83296b4
--- /dev/null
+++ b/dll/shellext/netshell/connectmanager.h
@@ -0,0 +1,75 @@
+
+typedef struct tagINetConnectionItem
+{
+ struct tagINetConnectionItem * Next;
+ DWORD dwAdapterIndex;
+ NETCON_PROPERTIES Props;
+} INetConnectionItem, *PINetConnectionItem;
+
+class CNetConnectionManager:
+ public CComCoClass<CNetConnectionManager, &CLSID_ConnectionManager>,
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public INetConnectionManager,
+ public IEnumNetConnection
+{
+ public:
+ CNetConnectionManager();
+ HRESULT Initialize();
+ HRESULT EnumerateINetConnections();
+
+ // INetConnectionManager
+ virtual HRESULT WINAPI EnumConnections(NETCONMGR_ENUM_FLAGS Flags,
IEnumNetConnection **ppEnum);
+
+ // IEnumNetConnection
+ virtual HRESULT WINAPI Next(ULONG celt, INetConnection **rgelt, ULONG
*pceltFetched);
+ virtual HRESULT WINAPI Skip(ULONG celt);
+ virtual HRESULT WINAPI Reset();
+ virtual HRESULT WINAPI Clone(IEnumNetConnection **ppenum);
+
+ private:
+ PINetConnectionItem m_pHead;
+ PINetConnectionItem m_pCurrent;
+
+ public:
+ DECLARE_NO_REGISTRY()
+ DECLARE_NOT_AGGREGATABLE(CNetConnectionManager)
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(CNetConnectionManager)
+ COM_INTERFACE_ENTRY_IID(IID_INetConnectionManager, INetConnectionManager)
+ COM_INTERFACE_ENTRY_IID(IID_IEnumNetConnection, IEnumNetConnection)
+ END_COM_MAP()
+};
+
+class CNetConnection:
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public INetConnection
+{
+ private:
+ NETCON_PROPERTIES m_Props;
+ DWORD m_dwAdapterIndex;
+
+ public:
+ ~CNetConnection();
+ HRESULT WINAPI Initialize(PINetConnectionItem pItem);
+
+ // INetConnection
+ HRESULT WINAPI Connect();
+ HRESULT WINAPI Disconnect();
+ HRESULT WINAPI Delete();
+ HRESULT WINAPI Duplicate(LPCWSTR pszwDuplicateName, INetConnection **ppCon);
+ HRESULT WINAPI GetProperties(NETCON_PROPERTIES **ppProps);
+ HRESULT WINAPI GetUiObjectClassId(CLSID *pclsid);
+ HRESULT WINAPI Rename(LPCWSTR pszwDuplicateName);
+
+ DECLARE_NOT_AGGREGATABLE(CNetConnection)
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(CNetConnection)
+ COM_INTERFACE_ENTRY_IID(IID_INetConnection, INetConnection)
+ END_COM_MAP()
+};
+
+BOOL GetAdapterIndexFromNetCfgInstanceId(PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetCfg,
PDWORD pIndex);
+HRESULT WINAPI CNetConnectionManager_CreateInstance(REFIID riid, LPVOID * ppv);
+
diff --git a/dll/shellext/netshell/enumlist.cpp b/dll/shellext/netshell/enumlist.cpp
index 9dc629cccc..c4e5de37a7 100644
--- a/dll/shellext/netshell/enumlist.cpp
+++ b/dll/shellext/netshell/enumlist.cpp
@@ -7,6 +7,63 @@
#include "precomp.h"
+
+typedef struct tagGUIDStruct
+{
+ BYTE dummy; /* offset 01 is unknown */
+ GUID guid; /* offset 02 */
+} GUIDStruct;
+
+#define PT_GUID 0x1F
+
+typedef struct tagPIDLDATA
+{
+ BYTE type; /*00*/
+ union
+ {
+ struct tagGUIDStruct guid;
+ struct tagVALUEStruct value;
+ } u;
+} PIDLDATA, *LPPIDLDATA;
+
+typedef struct tagENUMLIST
+{
+ struct tagENUMLIST *pNext;
+ PITEMID_CHILD pidl;
+} ENUMLIST, *LPENUMLIST;
+
+class CEnumIDList:
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public IEnumIDList
+{
+ public:
+ CEnumIDList();
+ ~CEnumIDList();
+
+ HRESULT Initialize();
+
+ // IEnumIDList
+ virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, PITEMID_CHILD *rgelt, ULONG
*pceltFetched);
+ virtual HRESULT STDMETHODCALLTYPE Skip(ULONG celt);
+ virtual HRESULT STDMETHODCALLTYPE Reset();
+ virtual HRESULT STDMETHODCALLTYPE Clone(IEnumIDList **ppenum);
+
+ private:
+ BOOL AddToEnumList(PITEMID_CHILD pidl);
+
+ LPENUMLIST m_pFirst;
+ LPENUMLIST m_pLast;
+ LPENUMLIST m_pCurrent;
+
+ public:
+ DECLARE_NOT_AGGREGATABLE(CEnumIDList)
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(CEnumIDList)
+ COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList)
+ END_COM_MAP()
+};
+
/**************************************************************************
* AddToEnumList()
*/
@@ -44,7 +101,6 @@ CEnumIDList::AddToEnumList(PITEMID_CHILD pidl)
}
CEnumIDList::CEnumIDList() :
- m_ref(0),
m_pFirst(NULL),
m_pLast(NULL),
m_pCurrent(NULL)
@@ -65,41 +121,48 @@ CEnumIDList::~CEnumIDList()
}
HRESULT
-WINAPI
-CEnumIDList::QueryInterface(
- REFIID riid,
- LPVOID *ppvObj)
+CEnumIDList::Initialize()
{
- *ppvObj = NULL;
+ HRESULT hr;
+ INetConnectionManager *pNetConMan;
+ IEnumNetConnection *pEnumCon;
+ INetConnection *INetCon;
+ ULONG Count;
+ PITEMID_CHILD pidl;
- if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IEnumIDList))
+ /* get an instance to of IConnectionManager */
+ hr = CNetConnectionManager_CreateInstance(IID_INetConnectionManager,
(LPVOID*)&pNetConMan);
+ if (FAILED(hr))
+ return S_OK;
+
+ hr = pNetConMan->EnumConnections(NCME_DEFAULT, &pEnumCon);
+ if (FAILED(hr))
{
- *ppvObj = static_cast<IEnumIDList*>(this);
- AddRef();
+ pNetConMan->Release();
return S_OK;
}
- return E_NOINTERFACE;
-}
-
-ULONG
-WINAPI
-CEnumIDList::AddRef()
-{
- ULONG refCount = InterlockedIncrement(&m_ref);
-
- return refCount;
-}
-
-ULONG
-WINAPI CEnumIDList::Release()
-{
- ULONG refCount = InterlockedDecrement(&m_ref);
+ do
+ {
+ hr = pEnumCon->Next(1, &INetCon, &Count);
+ if (hr == S_OK)
+ {
+ pidl = ILCreateNetConnectItem(INetCon);
+ if (pidl)
+ {
+ AddToEnumList(pidl);
+ }
+ }
+ else
+ {
+ break;
+ }
+ } while (TRUE);
- if (!refCount)
- delete this;
+ pEnumCon->Release();
+ pNetConMan->Release();
- return refCount;
+ return S_OK;
}
HRESULT
@@ -264,3 +327,8 @@ const VALUEStruct * _ILGetValueStruct(LPCITEMIDLIST pidl)
return NULL;
}
+
+HRESULT CEnumIDList_CreateInstance(HWND hwndOwner, DWORD dwFlags, REFIID riid, LPVOID *
ppv)
+{
+ return ShellObjectCreatorInit<CEnumIDList>(riid, ppv);
+}
diff --git a/dll/shellext/netshell/enumlist.h b/dll/shellext/netshell/enumlist.h
deleted file mode 100644
index a693e1e674..0000000000
--- a/dll/shellext/netshell/enumlist.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#pragma once
-
-typedef struct tagGUIDStruct
-{
- BYTE dummy; /* offset 01 is unknown */
- GUID guid; /* offset 02 */
-} GUIDStruct;
-
-#define PT_GUID 0x1F
-
-typedef struct tagPIDLDATA
-{
- BYTE type; /*00*/
- union
- {
- struct tagGUIDStruct guid;
- struct tagVALUEStruct value;
- } u;
-} PIDLDATA, *LPPIDLDATA;
-
-typedef struct tagENUMLIST
-{
- struct tagENUMLIST *pNext;
- PITEMID_CHILD pidl;
-} ENUMLIST, *LPENUMLIST;
-
-class CEnumIDList final :
- public IEnumIDList
-{
- public:
- CEnumIDList();
- BOOL AddToEnumList(PITEMID_CHILD pidl);
-
- // IUnknown
- virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
- virtual ULONG WINAPI AddRef();
- virtual ULONG WINAPI Release();
-
- // IEnumIDList
- virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, PITEMID_CHILD *rgelt, ULONG
*pceltFetched);
- virtual HRESULT STDMETHODCALLTYPE Skip(ULONG celt);
- virtual HRESULT STDMETHODCALLTYPE Reset();
- virtual HRESULT STDMETHODCALLTYPE Clone(IEnumIDList **ppenum);
-
- private:
- ~CEnumIDList();
-
- LONG m_ref;
- LPENUMLIST m_pFirst;
- LPENUMLIST m_pLast;
- LPENUMLIST m_pCurrent;
-};
diff --git a/dll/shellext/netshell/lanconnectui.cpp
b/dll/shellext/netshell/lanconnectui.cpp
index 4722b914f5..60e25f0363 100644
--- a/dll/shellext/netshell/lanconnectui.cpp
+++ b/dll/shellext/netshell/lanconnectui.cpp
@@ -7,78 +7,11 @@
#include "precomp.h"
-#include <netcfgx.h>
-#include <netcfgn.h>
-#include <strsafe.h>
-
-/// CLASSID
-/// {7007ACC5-3202-11D1-AAD2-00805FC1270E}
-/// open network properties and wlan properties
-
-typedef enum
-{
- NET_TYPE_CLIENT = 1,
- NET_TYPE_SERVICE = 2,
- NET_TYPE_PROTOCOL = 3
-} NET_TYPE;
-
-typedef struct
-{
- NET_TYPE Type;
- DWORD dwCharacteristics;
- LPWSTR szHelp;
- INetCfgComponent *pNCfgComp;
- UINT NumPropDialogOpen;
-} NET_ITEM, *PNET_ITEM;
-
-class CNetConnectionPropertyUi final :
- public INetConnectionConnectUi,
- public INetConnectionPropertyUi2,
- public INetLanConnectionUiInfo
-{
- public:
- CNetConnectionPropertyUi();
-
- // IUnknown
- virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
- virtual ULONG WINAPI AddRef();
- virtual ULONG WINAPI Release();
-
- // INetConnectionPropertyUi2
- virtual HRESULT WINAPI AddPages(HWND hwndParent, LPFNADDPROPSHEETPAGE pfnAddPage,
LPARAM lParam);
- virtual HRESULT WINAPI GetIcon(DWORD dwSize, HICON *phIcon);
-
- // INetLanConnectionUiInfo
- virtual HRESULT WINAPI GetDeviceGuid(GUID *pGuid);
-
- // INetConnectionConnectUi
- virtual HRESULT WINAPI SetConnection(INetConnection* pCon);
- virtual HRESULT WINAPI Connect(HWND hwndParent, DWORD dwFlags);
- virtual HRESULT WINAPI Disconnect(HWND hwndParent, DWORD dwFlags);
-
- private:
- ~CNetConnectionPropertyUi();
-
- BOOL GetINetCfgComponent(INetCfg *pNCfg, INetCfgComponent ** pOut);
- VOID EnumComponents(HWND hDlgCtrl, INetCfg *pNCfg, const GUID *CompGuid, UINT
Type);
- VOID InitializeLANPropertiesUIDlg(HWND hwndDlg);
- VOID ShowNetworkComponentProperties(HWND hwndDlg);
- BOOL GetDeviceInstanceID(OUT LPOLESTR *DeviceInstanceID);
- static INT_PTR CALLBACK LANPropertiesUIDlg(HWND hwndDlg, UINT uMsg, WPARAM
wParam, LPARAM lParam);
-
- INetConnection * m_pCon;
- INetCfgLock *m_NCfgLock;
- INetCfg * m_pNCfg;
- NETCON_PROPERTIES * m_pProperties;
- LONG m_ref;
-};
-
CNetConnectionPropertyUi::CNetConnectionPropertyUi() :
m_pCon(NULL),
m_NCfgLock(NULL),
m_pNCfg(NULL),
- m_pProperties(NULL),
- m_ref(0)
+ m_pProperties(NULL)
{
}
@@ -99,26 +32,6 @@ CNetConnectionPropertyUi::~CNetConnectionPropertyUi()
}
}
-HPROPSHEETPAGE
-InitializePropertySheetPage(LPWSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR
szTitle)
-{
- PROPSHEETPAGEW ppage;
-
- memset(&ppage, 0x0, sizeof(PROPSHEETPAGEW));
- ppage.dwSize = sizeof(PROPSHEETPAGEW);
- ppage.dwFlags = PSP_DEFAULT;
- ppage.pszTemplate = resname;
- ppage.pfnDlgProc = dlgproc;
- ppage.lParam = lParam;
- ppage.hInstance = netshell_hInstance;
- if (szTitle)
- {
- ppage.dwFlags |= PSP_USETITLE;
- ppage.pszTitle = szTitle;
- }
- return CreatePropertySheetPageW(&ppage);
-}
-
VOID
AddItemToListView(HWND hDlgCtrl, PNET_ITEM pItem, LPWSTR szName, BOOL bChecked)
{
@@ -528,59 +441,6 @@ CNetConnectionPropertyUi::GetDeviceInstanceID(
return FALSE;
}
-HRESULT
-WINAPI
-CNetConnectionPropertyUi::QueryInterface(
- REFIID iid,
- LPVOID *ppvObj)
-{
- *ppvObj = NULL;
-
- if (IsEqualIID (iid, IID_IUnknown) ||
- IsEqualIID (iid, IID_INetConnectionPropertyUi) ||
- IsEqualIID (iid, IID_INetConnectionPropertyUi2))
- {
- *ppvObj = (INetConnectionPropertyUi2*)this;
- AddRef();
- return S_OK;
- }
- else if (IsEqualIID(iid, IID_INetLanConnectionUiInfo))
- {
- *ppvObj = (INetLanConnectionUiInfo*)this;
- AddRef();
- return S_OK;
- }
- else if (IsEqualIID(iid, IID_INetConnectionConnectUi))
- {
- *ppvObj = (INetConnectionConnectUi*)this;
- AddRef();
- return S_OK;
- }
-
- return E_NOINTERFACE;
-}
-
-ULONG
-WINAPI
-CNetConnectionPropertyUi::AddRef()
-{
- ULONG refCount = InterlockedIncrement(&m_ref);
-
- return refCount;
-}
-
-ULONG
-WINAPI
-CNetConnectionPropertyUi::Release()
-{
- ULONG refCount = InterlockedDecrement(&m_ref);
-
- if (!refCount)
- delete this;
-
- return refCount;
-}
-
HRESULT
WINAPI
CNetConnectionPropertyUi::AddPages(
@@ -679,24 +539,3 @@ CNetConnectionPropertyUi::Disconnect(
return S_OK;
}
-
-HRESULT WINAPI LanConnectUI_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
-{
- TRACE("LanConnectUI_Constructor\n");
-
- if (!ppv)
- return E_POINTER;
-
- if (pUnkOuter)
- return CLASS_E_NOAGGREGATION;
-
- CNetConnectionPropertyUi *pConPropUi = new CNetConnectionPropertyUi;
- if (!pConPropUi)
- return E_OUTOFMEMORY;
-
- pConPropUi->AddRef();
- HRESULT hr = pConPropUi->QueryInterface(riid, ppv);
- pConPropUi->Release();
-
- return hr;
-}
diff --git a/dll/shellext/netshell/lanconnectui.h b/dll/shellext/netshell/lanconnectui.h
new file mode 100644
index 0000000000..02c8a8051b
--- /dev/null
+++ b/dll/shellext/netshell/lanconnectui.h
@@ -0,0 +1,69 @@
+
+/// CLASSID
+/// {7007ACC5-3202-11D1-AAD2-00805FC1270E}
+/// open network properties and wlan properties
+
+typedef enum
+{
+ NET_TYPE_CLIENT = 1,
+ NET_TYPE_SERVICE = 2,
+ NET_TYPE_PROTOCOL = 3
+} NET_TYPE;
+
+typedef struct
+{
+ NET_TYPE Type;
+ DWORD dwCharacteristics;
+ LPWSTR szHelp;
+ INetCfgComponent *pNCfgComp;
+ UINT NumPropDialogOpen;
+} NET_ITEM, *PNET_ITEM;
+
+class CNetConnectionPropertyUi:
+ public CComCoClass<CNetConnectionPropertyUi, &CLSID_LanConnectionUi>,
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public INetConnectionConnectUi,
+ public INetConnectionPropertyUi2,
+ public INetLanConnectionUiInfo
+{
+ public:
+ CNetConnectionPropertyUi();
+ ~CNetConnectionPropertyUi();
+
+ // INetConnectionPropertyUi2
+ virtual HRESULT WINAPI AddPages(HWND hwndParent, LPFNADDPROPSHEETPAGE pfnAddPage,
LPARAM lParam);
+ virtual HRESULT WINAPI GetIcon(DWORD dwSize, HICON *phIcon);
+
+ // INetLanConnectionUiInfo
+ virtual HRESULT WINAPI GetDeviceGuid(GUID *pGuid);
+
+ // INetConnectionConnectUi
+ virtual HRESULT WINAPI SetConnection(INetConnection* pCon);
+ virtual HRESULT WINAPI Connect(HWND hwndParent, DWORD dwFlags);
+ virtual HRESULT WINAPI Disconnect(HWND hwndParent, DWORD dwFlags);
+
+ private:
+ BOOL GetINetCfgComponent(INetCfg *pNCfg, INetCfgComponent ** pOut);
+ VOID EnumComponents(HWND hDlgCtrl, INetCfg *pNCfg, const GUID *CompGuid, UINT
Type);
+ VOID InitializeLANPropertiesUIDlg(HWND hwndDlg);
+ VOID ShowNetworkComponentProperties(HWND hwndDlg);
+ BOOL GetDeviceInstanceID(OUT LPOLESTR *DeviceInstanceID);
+ static INT_PTR CALLBACK LANPropertiesUIDlg(HWND hwndDlg, UINT uMsg, WPARAM
wParam, LPARAM lParam);
+
+ INetConnection * m_pCon;
+ INetCfgLock *m_NCfgLock;
+ INetCfg * m_pNCfg;
+ NETCON_PROPERTIES * m_pProperties;
+
+ public:
+ DECLARE_NO_REGISTRY()
+ DECLARE_NOT_AGGREGATABLE(CNetConnectionPropertyUi)
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(CNetConnectionPropertyUi)
+ COM_INTERFACE_ENTRY_IID(IID_INetConnectionConnectUi,
INetConnectionConnectUi)
+ COM_INTERFACE_ENTRY_IID(IID_INetConnectionPropertyUi,
INetConnectionPropertyUi2)
+ COM_INTERFACE_ENTRY_IID(IID_INetConnectionPropertyUi2,
INetConnectionPropertyUi2)
+ COM_INTERFACE_ENTRY_IID(IID_INetLanConnectionUiInfo,
INetLanConnectionUiInfo)
+ END_COM_MAP()
+};
diff --git a/dll/shellext/netshell/lanstatusui.cpp
b/dll/shellext/netshell/lanstatusui.cpp
index 19e3beca92..2aa7cc0237 100644
--- a/dll/shellext/netshell/lanstatusui.cpp
+++ b/dll/shellext/netshell/lanstatusui.cpp
@@ -9,65 +9,8 @@
#include <winsock.h>
-/// CLSID
-/// HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{7007ACCF-3202-11D1-AAD2-00805FC1270E}
-// IID B722BCCB-4E68-101B-A2BC-00AA00404770
-
-#define WM_SHOWSTATUSDLG (WM_USER+10)
-
-typedef struct tagNotificationItem
-{
- struct tagNotificationItem *pNext;
- CLSID guidItem;
- UINT uID;
- HWND hwndDlg;
- INetConnection *pNet;
-} NOTIFICATION_ITEM;
-
-typedef struct
-{
- INetConnection *pNet;
- HWND hwndStatusDlg; /* LanStatusDlg window */
- HWND hwndDlg; /* status dialog window */
- DWORD dwAdapterIndex;
- UINT_PTR nIDEvent;
- UINT DHCPEnabled;
- DWORD dwInOctets;
- DWORD dwOutOctets;
- DWORD IpAddress;
- DWORD SubnetMask;
- DWORD Gateway;
- UINT uID;
- UINT Status;
-} LANSTATUSUI_CONTEXT;
-
-class CLanStatus final :
- public IOleCommandTarget
-{
- public:
- CLanStatus();
-
- // IUnknown
- virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
- virtual ULONG WINAPI AddRef();
- virtual ULONG WINAPI Release();
-
- // IOleCommandTarget
- virtual HRESULT WINAPI QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD
*prgCmds, OLECMDTEXT *pCmdText);
- virtual HRESULT WINAPI Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
-
- private:
- HRESULT InitializeNetTaskbarNotifications();
- HRESULT ShowStatusDialogByCLSID(const GUID *pguidCmdGroup);
-
- INetConnectionManager *m_lpNetMan;
- LONG m_ref;
- NOTIFICATION_ITEM *m_pHead;
-};
-
CLanStatus::CLanStatus() :
m_lpNetMan(NULL),
- m_ref(0),
m_pHead(NULL)
{
}
@@ -1002,10 +945,10 @@ CLanStatus::InitializeNetTaskbarNotifications()
//hr = CoCreateInstance(&CLSID_ConnectionManager, NULL, CLSCTX_INPROC_SERVER,
&IID_INetConnectionManager, (LPVOID*)&pNetConMan);
- hr = INetConnectionManager_Constructor(NULL, IID_INetConnectionManager,
(LPVOID*)&pNetConMan);
+ hr = CNetConnectionManager_CreateInstance(IID_INetConnectionManager,
(LPVOID*)&pNetConMan);
if (FAILED(hr))
{
- ERR("INetConnectionManager_Constructor failed\n");
+ ERR("CNetConnectionManager_CreateInstance failed\n");
return hr;
}
@@ -1124,46 +1067,6 @@ CLanStatus::ShowStatusDialogByCLSID(const GUID *pguidCmdGroup)
return E_FAIL;
}
-HRESULT
-WINAPI
-CLanStatus::QueryInterface(
- REFIID iid,
- LPVOID *ppvObj)
-{
- *ppvObj = NULL;
-
- if (IsEqualIID(iid, IID_IUnknown) ||
- IsEqualIID(iid, IID_IOleCommandTarget))
- {
- *ppvObj = this;
- AddRef();
- return S_OK;
- }
-
- return E_NOINTERFACE;
-}
-
-ULONG
-WINAPI
-CLanStatus::AddRef()
-{
- ULONG refCount = InterlockedIncrement(&m_ref);
-
- return refCount;
-}
-
-ULONG
-WINAPI
-CLanStatus::Release()
-{
- ULONG refCount = InterlockedDecrement(&m_ref);
-
- if (!refCount)
- delete this;
-
- return refCount;
-}
-
HRESULT
WINAPI
CLanStatus::QueryStatus(
@@ -1199,26 +1102,3 @@ CLanStatus::Exec(
}
return S_OK;
}
-
-HRESULT WINAPI LanConnectStatusUI_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID
*ppv)
-{
- TRACE("LanConnectStatusUI_Constructor\n");
-
- if (!ppv)
- return E_POINTER;
-
- if (pUnkOuter)
- return CLASS_E_NOAGGREGATION;
-
- CLanStatus *pLanStatus = new CLanStatus;
- if (!pLanStatus)
- return E_OUTOFMEMORY;
-
- pLanStatus->AddRef();
- static volatile CLanStatus *pCachedLanStatus = NULL;
- if (InterlockedCompareExchangePointer((void **)&pCachedLanStatus, pLanStatus,
NULL) != NULL)
- pLanStatus->Release();
-
- return ((CLanStatus*)pCachedLanStatus)->QueryInterface(riid, ppv);
-}
-
diff --git a/dll/shellext/netshell/lanstatusui.h b/dll/shellext/netshell/lanstatusui.h
new file mode 100644
index 0000000000..62f047b0cb
--- /dev/null
+++ b/dll/shellext/netshell/lanstatusui.h
@@ -0,0 +1,62 @@
+
+/// CLSID
+/// HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{7007ACCF-3202-11D1-AAD2-00805FC1270E}
+// IID B722BCCB-4E68-101B-A2BC-00AA00404770
+
+#define WM_SHOWSTATUSDLG (WM_USER+10)
+
+typedef struct tagNotificationItem
+{
+ struct tagNotificationItem *pNext;
+ CLSID guidItem;
+ UINT uID;
+ HWND hwndDlg;
+ INetConnection *pNet;
+} NOTIFICATION_ITEM;
+
+typedef struct
+{
+ INetConnection *pNet;
+ HWND hwndStatusDlg; /* LanStatusDlg window */
+ HWND hwndDlg; /* status dialog window */
+ DWORD dwAdapterIndex;
+ UINT_PTR nIDEvent;
+ UINT DHCPEnabled;
+ DWORD dwInOctets;
+ DWORD dwOutOctets;
+ DWORD IpAddress;
+ DWORD SubnetMask;
+ DWORD Gateway;
+ UINT uID;
+ UINT Status;
+} LANSTATUSUI_CONTEXT;
+
+class CLanStatus:
+ public CComCoClass<CLanStatus, &CLSID_ConnectionTray>,
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public IOleCommandTarget
+{
+ public:
+ CLanStatus();
+
+ // IOleCommandTarget
+ virtual HRESULT WINAPI QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD
*prgCmds, OLECMDTEXT *pCmdText);
+ virtual HRESULT WINAPI Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
+
+ private:
+ HRESULT InitializeNetTaskbarNotifications();
+ HRESULT ShowStatusDialogByCLSID(const GUID *pguidCmdGroup);
+
+ INetConnectionManager *m_lpNetMan;
+ NOTIFICATION_ITEM *m_pHead;
+
+ public:
+ DECLARE_NO_REGISTRY()
+ DECLARE_CENTRAL_INSTANCE_NOT_AGGREGATABLE(CLanStatus)
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(CLanStatus)
+ COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
+ END_COM_MAP()
+
+};
diff --git a/dll/shellext/netshell/netshell.cpp b/dll/shellext/netshell/netshell.cpp
index 0aaab32f6e..17ef8e747b 100644
--- a/dll/shellext/netshell/netshell.cpp
+++ b/dll/shellext/netshell/netshell.cpp
@@ -7,16 +7,46 @@
#include "precomp.h"
-#include <olectl.h>
+HMODULE g_hModule = NULL;
HINSTANCE netshell_hInstance;
-extern "C"
+class CNetshellModule : public CComModule
{
+public:
+};
+
+BEGIN_OBJECT_MAP(ObjectMap)
+ OBJECT_ENTRY(CLSID_ConnectionFolder, CNetworkConnections)
+ OBJECT_ENTRY(CLSID_ConnectionManager, CNetConnectionManager)
+ OBJECT_ENTRY(CLSID_LanConnectionUi, CNetConnectionPropertyUi)
+ OBJECT_ENTRY(CLSID_ConnectionTray, CLanStatus)
+END_OBJECT_MAP()
+
+CNetshellModule gModule;
-/* FIXME: rpcproxy.h */
-HRESULT __wine_register_resources(HMODULE module);
-HRESULT __wine_unregister_resources(HMODULE module);
+HPROPSHEETPAGE
+InitializePropertySheetPage(LPWSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR
szTitle)
+{
+ PROPSHEETPAGEW ppage;
+
+ memset(&ppage, 0x0, sizeof(PROPSHEETPAGEW));
+ ppage.dwSize = sizeof(PROPSHEETPAGEW);
+ ppage.dwFlags = PSP_DEFAULT;
+ ppage.pszTemplate = resname;
+ ppage.pfnDlgProc = dlgproc;
+ ppage.lParam = lParam;
+ ppage.hInstance = netshell_hInstance;
+ if (szTitle)
+ {
+ ppage.dwFlags |= PSP_USETITLE;
+ ppage.pszTitle = szTitle;
+ }
+ return CreatePropertySheetPageW(&ppage);
+}
+
+extern "C"
+{
BOOL
WINAPI
@@ -27,6 +57,7 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
case DLL_PROCESS_ATTACH:
netshell_hInstance = hinstDLL;
DisableThreadLibraryCalls(netshell_hInstance);
+ gModule.Init(ObjectMap, netshell_hInstance, NULL);
break;
default:
break;
@@ -45,13 +76,33 @@ DllCanUnloadNow(void)
STDAPI
DllRegisterServer(void)
{
- return __wine_register_resources(netshell_hInstance);
+ HRESULT hr;
+
+ hr = gModule.DllRegisterServer(FALSE);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ hr = gModule.UpdateRegistryFromResource(IDR_NETSHELL, TRUE, NULL);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ return S_OK;
}
STDAPI
DllUnregisterServer(void)
{
- return __wine_unregister_resources(netshell_hInstance);
+ HRESULT hr;
+
+ hr = gModule.DllUnregisterServer(FALSE);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ hr = gModule.UpdateRegistryFromResource(IDR_NETSHELL, FALSE, NULL);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ return S_OK;
}
STDAPI
@@ -60,12 +111,7 @@ DllGetClassObject(
REFIID riid,
LPVOID *ppv)
{
- if (!ppv)
- return E_INVALIDARG;
-
- *ppv = NULL;
-
- return IClassFactory_fnConstructor(rclsid, riid, ppv);
+ return gModule.DllGetClassObject(rclsid, riid, ppv);
}
VOID
diff --git a/dll/shellext/netshell/netshell.rc b/dll/shellext/netshell/netshell.rc
index 363273cd4e..b0c9625c7e 100644
--- a/dll/shellext/netshell/netshell.rc
+++ b/dll/shellext/netshell/netshell.rc
@@ -23,7 +23,7 @@ IDI_NET_TRANS ICON "res/nettrans.ico"
IDI_NET_TRANSREC ICON "res/nettrrec.ico"
IDI_NET_SETUP ICON "res/netsetup.ico"
-IDR_NETSHELL WINE_REGISTRY "res/netshell.rgs"
+IDR_NETSHELL REGISTRY "res/netshell.rgs"
#include <reactos/manifest_dll.rc>
diff --git a/dll/shellext/netshell/precomp.h b/dll/shellext/netshell/precomp.h
index 0d763a15da..a9553dc992 100644
--- a/dll/shellext/netshell/precomp.h
+++ b/dll/shellext/netshell/precomp.h
@@ -16,22 +16,28 @@
#include <shlwapi.h>
#include <shlobj.h>
#include <shellapi.h>
+#include <atlbase.h>
+#include <atlcom.h>
+#include <atlcoll.h>
+#include <atlstr.h>
#include <iphlpapi.h>
#include <setupapi.h>
#include <devguid.h>
#include <netcon.h>
#include <shlguid_undoc.h>
#include <prsht.h>
+#include <undocshell.h>
+#include <shellutils.h>
+
+#include <netcfgx.h>
+#include <netcfgn.h>
+#include <strsafe.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(shell);
#include "resource.h"
-#if defined(_MSC_VER) && _MSC_VER < 1700
-#define final sealed
-#endif
-
#define NCF_VIRTUAL 0x1
#define NCF_SOFTWARE_ENUMERATED 0x2
#define NCF_PHYSICAL 0x4
@@ -43,13 +49,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
#define NCF_FILTER 0x400
#define NCF_NDIS_PROTOCOL 0x4000
-typedef struct {
- int colnameid;
- int pcsFlags;
- int fmt;
- int cxChar;
-} shvheader;
-
typedef struct tagVALUEStruct
{
BYTE dummy;
@@ -59,32 +58,21 @@ typedef struct tagVALUEStruct
/* globals */
extern HINSTANCE netshell_hInstance;
-/* shfldr_netconnect.c */
-HRESULT ShowNetConnectionProperties(INetConnection * pNetConnect, HWND hwnd);
-HRESULT WINAPI ISF_NetConnect_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID *
ppv);
-
/* enumlist.c */
PITEMID_CHILD _ILCreateNetConnect(void);
PITEMID_CHILD ILCreateNetConnectItem(INetConnection *pItem);
BOOL _ILIsNetConnect(LPCITEMIDLIST pidl);
const VALUEStruct * _ILGetValueStruct(LPCITEMIDLIST pidl);
+HRESULT CEnumIDList_CreateInstance(HWND hwndOwner, DWORD dwFlags, REFIID riid, LPVOID *
ppv);
-/* classfactory.c */
-HRESULT IClassFactory_fnConstructor(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut);
-
-/* connectmanager.c */
-HRESULT WINAPI INetConnectionManager_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID
*ppv);
-BOOL GetAdapterIndexFromNetCfgInstanceId(PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetCfg,
PDWORD pIndex);
+#define NCCF_NOTIFY_DISCONNECTED 0x100000
-/* lanconnectui.c */
HPROPSHEETPAGE InitializePropertySheetPage(LPWSTR resname, DLGPROC dlgproc, LPARAM
lParam, LPWSTR szTitle);
-HRESULT WINAPI LanConnectUI_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv);
-/* lanstatusui.c */
-HRESULT WINAPI LanConnectStatusUI_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID
*ppv);
-
-#define NCCF_NOTIFY_DISCONNECTED 0x100000
+#include "connectmanager.h"
+#include "lanconnectui.h"
+#include "lanstatusui.h"
+#include "shfldr_netconnect.h"
-#include "enumlist.h"
#endif /* _PRECOMP_H__ */
diff --git a/dll/shellext/netshell/shfldr_netconnect.cpp
b/dll/shellext/netshell/shfldr_netconnect.cpp
index 91e12020d6..82d0cfa02c 100644
--- a/dll/shellext/netshell/shfldr_netconnect.cpp
+++ b/dll/shellext/netshell/shfldr_netconnect.cpp
@@ -33,112 +33,6 @@
* IShellFolder implementation
*/
-class CNetworkConnections final :
- public IPersistFolder2,
- public IShellExtInit,
- public IShellFolder2,
- public IOleCommandTarget,
- public IShellFolderViewCB,
- public IShellExecuteHookW
-{
- public:
- CNetworkConnections();
-
- /* IUnknown */
- virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
- virtual ULONG WINAPI AddRef();
- virtual ULONG WINAPI Release();
-
- // IPersistFolder2
- virtual HRESULT WINAPI GetClassID(CLSID *lpClassId);
- virtual HRESULT WINAPI Initialize(PCIDLIST_ABSOLUTE pidl);
- virtual HRESULT WINAPI GetCurFolder(PIDLIST_ABSOLUTE *pidl);
-
- // IShellFolder
- virtual HRESULT WINAPI ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR
lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes);
- virtual HRESULT WINAPI EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST
*ppEnumIDList);
- virtual HRESULT WINAPI BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved,
REFIID riid, LPVOID *ppvOut);
- virtual HRESULT WINAPI BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved,
REFIID riid, LPVOID *ppvOut);
- virtual HRESULT WINAPI CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1,
PCUIDLIST_RELATIVE pidl2);
- virtual HRESULT WINAPI CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID
*ppvOut);
- virtual HRESULT WINAPI GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl,
DWORD *rgfInOut);
- virtual HRESULT WINAPI GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut);
- virtual HRESULT WINAPI GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags,
LPSTRRET strRet);
- virtual HRESULT WINAPI SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR
lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut);
-
- // IShellFolder2
- virtual HRESULT WINAPI GetDefaultSearchGUID(GUID *pguid);
- virtual HRESULT WINAPI EnumSearches(IEnumExtraSearch **ppenum);
- virtual HRESULT WINAPI GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG
*pDisplay);
- virtual HRESULT WINAPI GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags);
- virtual HRESULT WINAPI GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID
*pscid, VARIANT *pv);
- virtual HRESULT WINAPI GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn,
SHELLDETAILS *psd);
- virtual HRESULT WINAPI MapColumnToSCID(UINT column, SHCOLUMNID *pscid);
-
- // IShellExtInit
- virtual HRESULT WINAPI Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject
*pdtobj, HKEY hkeyProgID);
-
- // IOleCommandTarget
- virtual HRESULT WINAPI Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
- virtual HRESULT WINAPI QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD
prgCmds[], OLECMDTEXT *pCmdText);
-
- // IShellFolderViewCB
- virtual HRESULT WINAPI MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam);
-
- // IShellExecuteHookW
- virtual HRESULT WINAPI Execute(LPSHELLEXECUTEINFOW pei);
-
- private:
- ~CNetworkConnections();
-
- LONG m_ref;
- /* both paths are parsible from the desktop */
- PIDLIST_ABSOLUTE m_pidlRoot;
- IOleCommandTarget *m_lpOleCmd;
-};
-
-class CNetConUiObject final :
- public IContextMenu3,
- public IObjectWithSite,
- public IQueryInfo,
- public IExtractIconW
-{
- public:
- CNetConUiObject(PCUITEMID_CHILD pidl, IOleCommandTarget *lpOleCmd);
-
- // IUnknown
- virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
- virtual ULONG WINAPI AddRef();
- virtual ULONG WINAPI Release();
-
- // IContextMenu3
- virtual HRESULT WINAPI QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT
idCmdFirst, UINT idCmdLast, UINT uFlags);
- virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpici);
- virtual HRESULT WINAPI GetCommandString(UINT_PTR idCmd, UINT uType, UINT
*pwReserved, LPSTR pszName, UINT cchMax);
- virtual HRESULT WINAPI HandleMenuMsg( UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual HRESULT WINAPI HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam,
LRESULT *plResult);
-
- // IObjectWithSite
- virtual HRESULT WINAPI SetSite(IUnknown *punk);
- virtual HRESULT WINAPI GetSite(REFIID iid, void **ppvSite);
-
- // IQueryInfo
- virtual HRESULT WINAPI GetInfoFlags(DWORD *pdwFlags);
- virtual HRESULT WINAPI GetInfoTip(DWORD dwFlags, WCHAR **ppwszTip);
-
- // IExtractIconW
- virtual HRESULT STDMETHODCALLTYPE GetIconLocation(UINT uFlags, LPWSTR szIconFile,
UINT cchMax, int *piIndex, UINT *pwFlags);
- virtual HRESULT STDMETHODCALLTYPE Extract(LPCWSTR pszFile, UINT nIconIndex, HICON
*phiconLarge, HICON *phiconSmall, UINT nIconSize);
-
- private:
- ~CNetConUiObject();
-
- LONG m_ref;
- PCUITEMID_CHILD m_pidl;
- IUnknown *m_pUnknown;
- IOleCommandTarget *m_lpOleCmd;
-};
-
static const shvheader NetConnectSFHeader[] = {
{IDS_SHV_COLUMN_NAME, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT,
20},
{IDS_SHV_COLUMN_TYPE, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT,
8},
@@ -160,7 +54,6 @@ static const shvheader NetConnectSFHeader[] = {
HRESULT ShowNetConnectionStatus(IOleCommandTarget * lpOleCmd, INetConnection *
pNetConnect, HWND hwnd);
CNetworkConnections::CNetworkConnections() :
- m_ref(0),
m_pidlRoot(_ILCreateNetConnect())
{
HRESULT hr;
@@ -179,71 +72,6 @@ CNetworkConnections::~CNetworkConnections()
SHFree(m_pidlRoot);
}
-/**************************************************************************
- * ISF_NetConnect_fnQueryInterface
- *
- * NOTE
- * supports not IPersist/IPersistFolder
- */
-HRESULT WINAPI CNetworkConnections::QueryInterface(REFIID riid, LPVOID *ppvObj)
-{
- *ppvObj = NULL;
-
- if (IsEqualIID(riid, IID_IUnknown) ||
- IsEqualIID (riid, IID_IPersist) ||
- IsEqualIID (riid, IID_IPersistFolder) ||
- IsEqualIID (riid, IID_IPersistFolder2))
- {
- *ppvObj = static_cast<IPersistFolder2*>(this);
- }
- else if (IsEqualIID(riid, IID_IShellFolder) ||
- IsEqualIID(riid, IID_IShellFolder2))
- {
- *ppvObj = static_cast<IShellFolder2*>(this);
- }
- else if (IsEqualIID(riid, IID_IShellExtInit))
- {
- *ppvObj = static_cast<IShellExtInit*>(this);
- }
- else if (IsEqualIID(riid, IID_IOleCommandTarget))
- {
- *ppvObj = static_cast<IOleCommandTarget*>(this);
- }
- else if (IsEqualIID(riid, IID_IShellFolderViewCB))
- {
- *ppvObj = static_cast<IShellFolderViewCB*>(this);
- }
- else if (IsEqualIID(riid, IID_IShellExecuteHookW))
- {
- *ppvObj = static_cast<IShellExecuteHookW*>(this);
- }
-
- if (*ppvObj)
- {
- AddRef();
- return S_OK;
- }
-
- return E_NOINTERFACE;
-}
-
-ULONG WINAPI CNetworkConnections::AddRef()
-{
- ULONG refCount = InterlockedIncrement(&m_ref);
-
- return refCount;
-}
-
-ULONG WINAPI CNetworkConnections::Release()
-{
- ULONG refCount = InterlockedDecrement(&m_ref);
-
- if (!refCount)
- delete this;
-
- return refCount;
-}
-
/**************************************************************************
* ISF_NetConnect_fnParseDisplayName
*/
@@ -260,67 +88,13 @@ HRESULT WINAPI CNetworkConnections::ParseDisplayName (
return hr;
}
-/**************************************************************************
- * CreateNetConnectEnumList()
- */
-static BOOL CreateNetConnectEnumList(CEnumIDList *list, DWORD dwFlags)
-{
- HRESULT hr;
- INetConnectionManager *pNetConMan;
- IEnumNetConnection *pEnumCon;
- INetConnection *INetCon;
- ULONG Count;
- PITEMID_CHILD pidl;
-
- /* get an instance to of IConnectionManager */
- hr = INetConnectionManager_Constructor(NULL, IID_INetConnectionManager,
(LPVOID*)&pNetConMan);
- if (FAILED(hr))
- return FALSE;
-
- hr = pNetConMan->EnumConnections(NCME_DEFAULT, &pEnumCon);
- if (FAILED(hr))
- {
- pNetConMan->Release();
- return FALSE;
- }
-
- do
- {
- hr = pEnumCon->Next(1, &INetCon, &Count);
- if (hr == S_OK)
- {
- pidl = ILCreateNetConnectItem(INetCon);
- if (pidl)
- {
- list->AddToEnumList(pidl);
- }
- }
- else
- {
- break;
- }
- } while (TRUE);
-
- pEnumCon->Release();
- pNetConMan->Release();
-
- return TRUE;
-}
-
/**************************************************************************
* ISF_NetConnect_fnEnumObjects
*/
HRESULT WINAPI CNetworkConnections::EnumObjects(
HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
{
- CEnumIDList *pList = new CEnumIDList;
- *ppEnumIDList = static_cast<LPENUMIDLIST>(pList);
- if (!pList)
- return E_OUTOFMEMORY;
-
- pList->AddRef();
- CreateNetConnectEnumList(pList, dwFlags);
- return S_OK;
+ return CEnumIDList_CreateInstance(hwndOwner, dwFlags, IID_PPV_ARG(IEnumIDList,
ppEnumIDList));
}
/**************************************************************************
@@ -454,18 +228,6 @@ HRESULT WINAPI CNetworkConnections::GetAttributesOf(
*
*/
-HRESULT IContextMenuImpl_Constructor(REFIID riid, PCUITEMID_CHILD pidl, LPVOID * ppvOut,
IOleCommandTarget * lpOleCmd)
-{
- CNetConUiObject *pMenu = new CNetConUiObject(pidl, lpOleCmd);
- if (!pMenu)
- return E_OUTOFMEMORY;
-
- pMenu->AddRef();
- HRESULT hr = pMenu->QueryInterface(riid, ppvOut);
- pMenu->Release();
- return hr;
-}
-
HRESULT WINAPI CNetworkConnections::GetUIObjectOf(
HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid,
UINT * prgfInOut, LPVOID * ppvOut)
@@ -481,7 +243,7 @@ HRESULT WINAPI CNetworkConnections::GetUIObjectOf(
if ((IsEqualIID(riid, IID_IContextMenu) || IsEqualIID (riid, IID_IContextMenu2) ||
IsEqualIID(riid, IID_IContextMenu3) ||
IsEqualIID(riid, IID_IQueryInfo) || IsEqualIID(riid, IID_IExtractIconW))
&& cidl >= 1)
{
- return IContextMenuImpl_Constructor(riid, apidl[0], ppvOut, m_lpOleCmd);
+ return ShellObjectCreatorInit<CNetConUiObject>(apidl[0], m_lpOleCmd, riid,
ppvOut);
}
else
hr = E_NOINTERFACE;
@@ -725,14 +487,11 @@ HRESULT WINAPI CNetworkConnections::MapColumnToSCID(UINT column,
SHCOLUMNID *psc
* IContextMenu2 Implementation
*/
-CNetConUiObject::CNetConUiObject(PCUITEMID_CHILD pidl, IOleCommandTarget *lpOleCmd)
- : m_ref(0),
- m_pidl(pidl),
+CNetConUiObject::CNetConUiObject()
+ : m_pidl(NULL),
m_pUnknown(NULL),
- m_lpOleCmd(lpOleCmd)
+ m_lpOleCmd(NULL)
{
- if (m_lpOleCmd)
- m_lpOleCmd->AddRef();
}
CNetConUiObject::~CNetConUiObject()
@@ -741,55 +500,13 @@ CNetConUiObject::~CNetConUiObject()
m_lpOleCmd->Release();
}
-/************************************************************************
- * ISF_NetConnect_IContextMenu_QueryInterface
- */
-HRESULT WINAPI CNetConUiObject::QueryInterface(REFIID iid, LPVOID *ppvObject)
-{
- *ppvObject = NULL;
-
- if (IsEqualIID(iid, IID_IContextMenu) || IsEqualIID(iid, IID_IContextMenu2) ||
IsEqualIID(iid, IID_IContextMenu3))
- *ppvObject = static_cast<IContextMenu3*>(this);
- else if (IsEqualIID(iid, IID_IObjectWithSite))
- *ppvObject = static_cast<IObjectWithSite*>(this);
- else if (IsEqualIID(iid, IID_IQueryInfo))
- *ppvObject = static_cast<IQueryInfo*>(this);
- else if (IsEqualIID(iid, IID_IExtractIconW))
- *ppvObject = static_cast<IExtractIconW*>(this);
-
- if (*ppvObject)
- {
- AddRef();
- return S_OK;
- }
-
- return E_NOINTERFACE;
-}
-
-/************************************************************************
- * ISF_NetConnect_IContextMenu_AddRef
- */
-ULONG WINAPI CNetConUiObject::AddRef()
-{
- ULONG refCount;
-
- refCount = InterlockedIncrement(&m_ref);
-
- return refCount;
-}
-
-/************************************************************************
- * ISF_NetConnect_IContextMenu_Release
- */
-ULONG WINAPI CNetConUiObject::Release()
+HRESULT WINAPI CNetConUiObject::Initialize(PCUITEMID_CHILD pidl, IOleCommandTarget
*lpOleCmd)
{
- ULONG refCount;
-
- refCount = InterlockedDecrement(&m_ref);
- if (!refCount)
- delete this;
-
- return refCount;
+ m_pidl = pidl;
+ m_lpOleCmd = lpOleCmd;
+ if (m_lpOleCmd)
+ m_lpOleCmd->AddRef();
+ return S_OK;
}
void WINAPI _InsertMenuItemW (
@@ -1294,26 +1011,3 @@ HRESULT WINAPI CNetConUiObject::GetInfoTip(DWORD dwFlags, WCHAR
**ppwszTip)
*ppwszTip = NULL;
return S_OK;
}
-
-/**************************************************************************
-* ISF_NetConnect_Constructor
-*/
-HRESULT WINAPI ISF_NetConnect_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
-{
- TRACE("ISF_NetConnect_Constructor\n");
-
- if (!ppv)
- return E_POINTER;
- if (pUnkOuter)
- return CLASS_E_NOAGGREGATION;
-
- CNetworkConnections *pnc = new CNetworkConnections;
- if (!pnc)
- return E_OUTOFMEMORY;
-
- pnc->AddRef();
- HRESULT hr = pnc->QueryInterface(riid, ppv);
- pnc->Release();
-
- return hr;
-}
diff --git a/dll/shellext/netshell/shfldr_netconnect.h
b/dll/shellext/netshell/shfldr_netconnect.h
new file mode 100644
index 0000000000..2c541ad3bd
--- /dev/null
+++ b/dll/shellext/netshell/shfldr_netconnect.h
@@ -0,0 +1,137 @@
+
+
+typedef struct {
+ int colnameid;
+ int pcsFlags;
+ int fmt;
+ int cxChar;
+} shvheader;
+
+class CNetworkConnections:
+ public CComCoClass<CNetworkConnections, &CLSID_ConnectionFolder>,
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public IPersistFolder2,
+ public IShellExtInit,
+ public IShellFolder2,
+ public IOleCommandTarget,
+ public IShellFolderViewCB,
+ public IShellExecuteHookW
+{
+ public:
+ CNetworkConnections();
+ ~CNetworkConnections();
+
+ // IPersistFolder2
+ virtual HRESULT WINAPI GetClassID(CLSID *lpClassId);
+ virtual HRESULT WINAPI Initialize(PCIDLIST_ABSOLUTE pidl);
+ virtual HRESULT WINAPI GetCurFolder(PIDLIST_ABSOLUTE *pidl);
+
+ // IShellFolder
+ virtual HRESULT WINAPI ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR
lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes);
+ virtual HRESULT WINAPI EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST
*ppEnumIDList);
+ virtual HRESULT WINAPI BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved,
REFIID riid, LPVOID *ppvOut);
+ virtual HRESULT WINAPI BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved,
REFIID riid, LPVOID *ppvOut);
+ virtual HRESULT WINAPI CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1,
PCUIDLIST_RELATIVE pidl2);
+ virtual HRESULT WINAPI CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID
*ppvOut);
+ virtual HRESULT WINAPI GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl,
DWORD *rgfInOut);
+ virtual HRESULT WINAPI GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut);
+ virtual HRESULT WINAPI GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags,
LPSTRRET strRet);
+ virtual HRESULT WINAPI SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR
lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut);
+
+ // IShellFolder2
+ virtual HRESULT WINAPI GetDefaultSearchGUID(GUID *pguid);
+ virtual HRESULT WINAPI EnumSearches(IEnumExtraSearch **ppenum);
+ virtual HRESULT WINAPI GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG
*pDisplay);
+ virtual HRESULT WINAPI GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags);
+ virtual HRESULT WINAPI GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID
*pscid, VARIANT *pv);
+ virtual HRESULT WINAPI GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn,
SHELLDETAILS *psd);
+ virtual HRESULT WINAPI MapColumnToSCID(UINT column, SHCOLUMNID *pscid);
+
+ // IShellExtInit
+ virtual HRESULT WINAPI Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject
*pdtobj, HKEY hkeyProgID);
+
+ // IOleCommandTarget
+ virtual HRESULT WINAPI Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
+ virtual HRESULT WINAPI QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD
prgCmds[], OLECMDTEXT *pCmdText);
+
+ // IShellFolderViewCB
+ virtual HRESULT WINAPI MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+ // IShellExecuteHookW
+ virtual HRESULT WINAPI Execute(LPSHELLEXECUTEINFOW pei);
+
+ private:
+
+ /* both paths are parsible from the desktop */
+ PIDLIST_ABSOLUTE m_pidlRoot;
+ IOleCommandTarget *m_lpOleCmd;
+
+ public:
+
+ BEGIN_COM_MAP(CNetworkConnections)
+ COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersistFolder2)
+ COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder2)
+ COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2)
+ COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder2)
+ COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2)
+ COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit)
+ COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
+ COM_INTERFACE_ENTRY_IID(IID_IShellFolderViewCB, IShellFolderViewCB)
+ COM_INTERFACE_ENTRY_IID(IID_IShellExecuteHookW, IShellExecuteHookW)
+ END_COM_MAP()
+
+ DECLARE_NO_REGISTRY()
+ DECLARE_NOT_AGGREGATABLE(CNetworkConnections)
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+};
+
+class CNetConUiObject:
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public IContextMenu3,
+ public IObjectWithSite,
+ public IQueryInfo,
+ public IExtractIconW
+{
+ private:
+ PCUITEMID_CHILD m_pidl;
+ IUnknown *m_pUnknown;
+ IOleCommandTarget *m_lpOleCmd;
+
+ public:
+ CNetConUiObject();
+ ~CNetConUiObject();
+ HRESULT WINAPI Initialize(PCUITEMID_CHILD pidl, IOleCommandTarget *lpOleCmd);
+
+ // IContextMenu3
+ virtual HRESULT WINAPI QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT
idCmdFirst, UINT idCmdLast, UINT uFlags);
+ virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpici);
+ virtual HRESULT WINAPI GetCommandString(UINT_PTR idCmd, UINT uType, UINT
*pwReserved, LPSTR pszName, UINT cchMax);
+ virtual HRESULT WINAPI HandleMenuMsg( UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual HRESULT WINAPI HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam,
LRESULT *plResult);
+
+ // IObjectWithSite
+ virtual HRESULT WINAPI SetSite(IUnknown *punk);
+ virtual HRESULT WINAPI GetSite(REFIID iid, void **ppvSite);
+
+ // IQueryInfo
+ virtual HRESULT WINAPI GetInfoFlags(DWORD *pdwFlags);
+ virtual HRESULT WINAPI GetInfoTip(DWORD dwFlags, WCHAR **ppwszTip);
+
+ // IExtractIconW
+ virtual HRESULT STDMETHODCALLTYPE GetIconLocation(UINT uFlags, LPWSTR szIconFile,
UINT cchMax, int *piIndex, UINT *pwFlags);
+ virtual HRESULT STDMETHODCALLTYPE Extract(LPCWSTR pszFile, UINT nIconIndex, HICON
*phiconLarge, HICON *phiconSmall, UINT nIconSize);
+
+ BEGIN_COM_MAP(CNetConUiObject)
+ COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu3)
+ COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu3)
+ COM_INTERFACE_ENTRY_IID(IID_IContextMenu3, IContextMenu3)
+ COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
+ COM_INTERFACE_ENTRY_IID(IID_IQueryInfo, IQueryInfo)
+ COM_INTERFACE_ENTRY_IID(IID_IExtractIconW, IExtractIconW)
+ END_COM_MAP()
+
+ DECLARE_NOT_AGGREGATABLE(CNetConUiObject)
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+};
+
+HRESULT ShowNetConnectionProperties(INetConnection * pNetConnect, HWND hwnd);