Author: tfaber
Date: Sun Apr 19 20:18:25 2015
New Revision: 67307

URL: http://svn.reactos.org/svn/reactos?rev=67307&view=rev
Log:
[NETSHELL]
Fix artifacts from incomplete C++ conversion:
- Add m_ prefix to member variables to avoid shadowing locals
- Use initializer lists in constructors
- Use destructors instead of putting code in Release
- Avoid C-style casts (not exhaustive)

Modified:
    trunk/reactos/dll/shellext/netshell/CMakeLists.txt
    trunk/reactos/dll/shellext/netshell/classfactory.cpp
    trunk/reactos/dll/shellext/netshell/connectmanager.cpp
    trunk/reactos/dll/shellext/netshell/enumlist.cpp
    trunk/reactos/dll/shellext/netshell/enumlist.h
    trunk/reactos/dll/shellext/netshell/lanconnectui.cpp
    trunk/reactos/dll/shellext/netshell/lanstatusui.cpp
    trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp

Modified: trunk/reactos/dll/shellext/netshell/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/CMakeLists.txt?rev=67307&r1=67306&r2=67307&view=diff
==============================================================================
--- trunk/reactos/dll/shellext/netshell/CMakeLists.txt  [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/netshell/CMakeLists.txt  [iso-8859-1] Sun Apr 19 
20:18:25 2015
@@ -5,7 +5,7 @@
 
 if(NOT MSVC)
     # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
+    add_compile_flags_language("-std=c++11 -Wshadow" "CXX")
 endif()
 
 remove_definitions(-D_WIN32_WINNT=0x502)

Modified: trunk/reactos/dll/shellext/netshell/classfactory.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/classfactory.cpp?rev=67307&r1=67306&r2=67307&view=diff
==============================================================================
--- trunk/reactos/dll/shellext/netshell/classfactory.cpp        [iso-8859-1] 
(original)
+++ trunk/reactos/dll/shellext/netshell/classfactory.cpp        [iso-8859-1] 
Sun Apr 19 20:18:25 2015
@@ -16,14 +16,14 @@
         virtual HRESULT WINAPI LockServer(BOOL fLock);
     
     private:
-        LONG ref;
-        CLSID clsid;
+        LONG m_ref;
+        CLSID m_clsid;
 };
 
-CNetshellClassFactory::CNetshellClassFactory(REFCLSID rclsid)
+CNetshellClassFactory::CNetshellClassFactory(REFCLSID rclsid) :
+    m_ref(0),
+    m_clsid(rclsid)
 {
-    ref = 0;
-    clsid = rclsid;
 }
 
 HRESULT
@@ -33,10 +33,10 @@
     LPVOID *ppvObj)
 {
     *ppvObj = NULL;
-    if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
+    if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
     {
-        *ppvObj = (IClassFactory*)this;
-        InterlockedIncrement(&ref);
+        *ppvObj = static_cast<IClassFactory*>(this);
+        AddRef();
         return S_OK;
     }
     return E_NOINTERFACE;
@@ -46,7 +46,7 @@
 WINAPI
 CNetshellClassFactory::AddRef()
 {
-    ULONG refCount = InterlockedIncrement(&ref);
+    ULONG refCount = InterlockedIncrement(&m_ref);
 
     return refCount;
 }
@@ -55,13 +55,11 @@
 WINAPI
 CNetshellClassFactory::Release()
 {
-    ULONG refCount = InterlockedDecrement(&ref);
+    ULONG refCount = InterlockedDecrement(&m_ref);
 
     if (!refCount)
-    {
         CoTaskMemFree(this);
-        return 0;
-    }
+
     return refCount;
 }
 
@@ -74,13 +72,13 @@
 {
     *ppvObject = NULL;
 
-    if (IsEqualCLSID(clsid, CLSID_NetworkConnections))
+    if (IsEqualCLSID(m_clsid, CLSID_NetworkConnections))
         return ISF_NetConnect_Constructor(pUnkOuter, riid, ppvObject);
-    else if (IsEqualCLSID(clsid, CLSID_ConnectionManager))
+    else if (IsEqualCLSID(m_clsid, CLSID_ConnectionManager))
         return INetConnectionManager_Constructor(pUnkOuter, riid, ppvObject);
-    else if (IsEqualCLSID(clsid, CLSID_LANConnectUI))
+    else if (IsEqualCLSID(m_clsid, CLSID_LANConnectUI))
         return LanConnectUI_Constructor(pUnkOuter, riid, ppvObject);
-    else if (IsEqualCLSID(clsid, CLSID_LanConnectStatusUI))
+    else if (IsEqualCLSID(m_clsid, CLSID_LanConnectStatusUI))
         return LanConnectStatusUI_Constructor(pUnkOuter, riid, ppvObject);
 
     return E_NOINTERFACE;

Modified: trunk/reactos/dll/shellext/netshell/connectmanager.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/connectmanager.cpp?rev=67307&r1=67306&r2=67307&view=diff
==============================================================================
--- trunk/reactos/dll/shellext/netshell/connectmanager.cpp      [iso-8859-1] 
(original)
+++ trunk/reactos/dll/shellext/netshell/connectmanager.cpp      [iso-8859-1] 
Sun Apr 19 20:18:25 2015
@@ -30,9 +30,9 @@
         virtual HRESULT WINAPI Clone(IEnumNetConnection **ppenum);
 
     private:
-        LONG ref;
-        PINetConnectionItem pHead;
-        PINetConnectionItem pCurrent;
+        LONG m_ref;
+        PINetConnectionItem m_pHead;
+        PINetConnectionItem m_pCurrent;
 };
 
 class CNetConnection final :
@@ -40,6 +40,7 @@
 {
     public:
         CNetConnection(PINetConnectionItem pItem);
+        ~CNetConnection();
 
         // IUnknown
         virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
@@ -56,18 +57,18 @@
         HRESULT WINAPI Rename(LPCWSTR pszwDuplicateName);
 
     private:
-        LONG ref;
-        NETCON_PROPERTIES Props;
-        DWORD dwAdapterIndex;
+        LONG m_ref;
+        NETCON_PROPERTIES m_Props;
+        DWORD m_dwAdapterIndex;
 };
 
 VOID NormalizeOperStatus(MIB_IFROW *IfEntry, NETCON_PROPERTIES * Props);
 
-CNetConnectionManager::CNetConnectionManager()
-{
-    ref = 0;
-    pHead = NULL;
-    pCurrent = NULL;
+CNetConnectionManager::CNetConnectionManager() :
+    m_ref(0),
+    m_pHead(NULL),
+    m_pCurrent(NULL)
+{
 }
 
 HRESULT
@@ -81,7 +82,7 @@
     if (IsEqualIID(iid, IID_IUnknown) ||
         IsEqualIID(iid, IID_INetConnectionManager))
     {
-        *ppvObj = (INetConnectionManager*)this;
+        *ppvObj = static_cast<INetConnectionManager*>(this);
         AddRef();
         return S_OK;
     }
@@ -93,7 +94,7 @@
 WINAPI
 CNetConnectionManager::AddRef()
 {
-    ULONG refCount = InterlockedIncrement(&ref);
+    ULONG refCount = InterlockedIncrement(&m_ref);
 
     return refCount;
 }
@@ -102,7 +103,7 @@
 WINAPI
 CNetConnectionManager::Release()
 {
-    ULONG refCount = InterlockedDecrement(&ref);
+    ULONG refCount = InterlockedDecrement(&m_ref);
 
     if (!refCount)
         delete this;
@@ -124,7 +125,7 @@
     if (Flags != NCME_DEFAULT)
         return E_FAIL;
 
-    *ppEnum = (IEnumNetConnection*)this;
+    *ppEnum = static_cast<IEnumNetConnection*>(this);
     AddRef();
     return S_OK;
 }
@@ -133,25 +134,30 @@
  * INetConnection Interface
  */
 
-CNetConnection::CNetConnection(PINetConnectionItem pItem)
-{
-    ref = 0;
-    dwAdapterIndex = pItem->dwAdapterIndex;
-    CopyMemory(&Props, &pItem->Props, sizeof(NETCON_PROPERTIES));
-
+CNetConnection::CNetConnection(PINetConnectionItem pItem) :
+    m_ref(0),
+    m_Props(pItem->Props),
+    m_dwAdapterIndex(pItem->dwAdapterIndex)
+{
     if (pItem->Props.pszwName)
     {
-        Props.pszwName = 
(LPWSTR)CoTaskMemAlloc((wcslen(pItem->Props.pszwName)+1)*sizeof(WCHAR));
-        if (Props.pszwName)
-            wcscpy(Props.pszwName, pItem->Props.pszwName);
+        m_Props.pszwName = 
static_cast<PWSTR>(CoTaskMemAlloc((wcslen(pItem->Props.pszwName)+1)*sizeof(WCHAR)));
+        if (m_Props.pszwName)
+            wcscpy(m_Props.pszwName, pItem->Props.pszwName);
     }
 
     if (pItem->Props.pszwDeviceName)
     {
-        Props.pszwDeviceName = 
(LPWSTR)CoTaskMemAlloc((wcslen(pItem->Props.pszwDeviceName)+1)*sizeof(WCHAR));
-        if (Props.pszwDeviceName)
-            wcscpy(Props.pszwDeviceName, pItem->Props.pszwDeviceName);
-    }
+        m_Props.pszwDeviceName = 
static_cast<PWSTR>(CoTaskMemAlloc((wcslen(pItem->Props.pszwDeviceName)+1)*sizeof(WCHAR)));
+        if (m_Props.pszwDeviceName)
+            wcscpy(m_Props.pszwDeviceName, pItem->Props.pszwDeviceName);
+    }
+}
+
+CNetConnection::~CNetConnection()
+{
+    CoTaskMemFree(m_Props.pszwName);
+    CoTaskMemFree(m_Props.pszwDeviceName);
 }
 
 HRESULT
@@ -177,7 +183,7 @@
 WINAPI
 CNetConnection::AddRef()
 {
-    ULONG refCount = InterlockedIncrement(&ref);
+    ULONG refCount = InterlockedIncrement(&m_ref);
 
     return refCount;
 }
@@ -186,14 +192,10 @@
 WINAPI
 CNetConnection::Release()
 {
-    ULONG refCount = InterlockedDecrement(&ref);
+    ULONG refCount = InterlockedDecrement(&m_ref);
 
     if (!refCount)
-    {
-        CoTaskMemFree(Props.pszwName);
-        CoTaskMemFree(Props.pszwDeviceName);
         delete this;
-    }
 
     return refCount;
 }
@@ -243,32 +245,32 @@
     if (!ppProps)
         return E_POINTER;
 
-    pProperties = 
(NETCON_PROPERTIES*)CoTaskMemAlloc(sizeof(NETCON_PROPERTIES));
+    pProperties = 
static_cast<NETCON_PROPERTIES*>(CoTaskMemAlloc(sizeof(NETCON_PROPERTIES)));
     if (!pProperties)
         return E_OUTOFMEMORY;
 
-    CopyMemory(pProperties, &Props, sizeof(NETCON_PROPERTIES));
+    CopyMemory(pProperties, &m_Props, sizeof(NETCON_PROPERTIES));
     pProperties->pszwName = NULL;
 
-    if (Props.pszwDeviceName)
-    {
-        pProperties->pszwDeviceName = 
(LPWSTR)CoTaskMemAlloc((wcslen(Props.pszwDeviceName)+1)*sizeof(WCHAR));
+    if (m_Props.pszwDeviceName)
+    {
+        pProperties->pszwDeviceName = 
static_cast<LPWSTR>(CoTaskMemAlloc((wcslen(m_Props.pszwDeviceName)+1)*sizeof(WCHAR)));
         if (pProperties->pszwDeviceName)
-            wcscpy(pProperties->pszwDeviceName, Props.pszwDeviceName);
+            wcscpy(pProperties->pszwDeviceName, m_Props.pszwDeviceName);
     }
 
     *ppProps = pProperties;
 
     /* get updated adapter characteristics */
     ZeroMemory(&IfEntry, sizeof(IfEntry));
-    IfEntry.dwIndex = dwAdapterIndex;
-    if(GetIfEntry(&IfEntry) != NO_ERROR)
+    IfEntry.dwIndex = m_dwAdapterIndex;
+    if (GetIfEntry(&IfEntry) != NO_ERROR)
         return NOERROR;
 
     NormalizeOperStatus(&IfEntry, pProperties);
 
 
-    hr = StringFromCLSID((CLSID)Props.guidId, &pStr);
+    hr = StringFromCLSID((CLSID)m_Props.guidId, &pStr);
     if (SUCCEEDED(hr))
     {
         wcscpy(szName, 
L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\");
@@ -290,18 +292,18 @@
             {
                 /* use updated name */
                 dwSize = wcslen(szName) + 1;
-                pProperties->pszwName = (LPWSTR)CoTaskMemAlloc(dwSize * 
sizeof(WCHAR));
+                pProperties->pszwName = 
static_cast<PWSTR>(CoTaskMemAlloc(dwSize * sizeof(WCHAR)));
                 if (pProperties->pszwName)
                     CopyMemory(pProperties->pszwName, szName, dwSize * 
sizeof(WCHAR));
             }
             else
             {
                 /* use cached name */
-                if (Props.pszwName)
+                if (m_Props.pszwName)
                 {
-                    pProperties->pszwName = 
(LPWSTR)CoTaskMemAlloc((wcslen(Props.pszwName)+1)*sizeof(WCHAR));
+                    pProperties->pszwName = 
static_cast<PWSTR>(CoTaskMemAlloc((wcslen(m_Props.pszwName)+1)*sizeof(WCHAR)));
                     if (pProperties->pszwName)
-                        wcscpy(pProperties->pszwName, Props.pszwName);
+                        wcscpy(pProperties->pszwName, m_Props.pszwName);
                 }
             }
             RegCloseKey(hKey);
@@ -316,7 +318,7 @@
 WINAPI
 CNetConnection::GetUiObjectClassId(CLSID *pclsid)
 {
-    if (Props.MediaType == NCM_LAN)
+    if (m_Props.MediaType == NCM_LAN)
     {
         CopyMemory(pclsid, &CLSID_LANConnectUI, sizeof(CLSID));
         return S_OK;
@@ -338,20 +340,20 @@
     if (pszwDuplicateName == NULL || wcslen(pszwDuplicateName) == 0)
         return S_OK;
 
-    if (Props.pszwName)
-    {
-        CoTaskMemFree(Props.pszwName);
-        Props.pszwName = NULL;
+    if (m_Props.pszwName)
+    {
+        CoTaskMemFree(m_Props.pszwName);
+        m_Props.pszwName = NULL;
     }
 
     dwSize = (wcslen(pszwDuplicateName) + 1) * sizeof(WCHAR);
-    Props.pszwName = (LPWSTR)CoTaskMemAlloc(dwSize);
-    if (Props.pszwName == NULL)
+    m_Props.pszwName = static_cast<PWSTR>(CoTaskMemAlloc(dwSize));
+    if (m_Props.pszwName == NULL)
         return E_OUTOFMEMORY;
 
-    wcscpy(Props.pszwName, pszwDuplicateName);
-
-    hr = StringFromCLSID((CLSID)Props.guidId, &pStr);
+    wcscpy(m_Props.pszwName, pszwDuplicateName);
+
+    hr = StringFromCLSID((CLSID)m_Props.guidId, &pStr);
     if (SUCCEEDED(hr))
     {
         wcscpy(szName, 
L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\");
@@ -360,7 +362,7 @@
 
         if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szName, 0, KEY_WRITE, &hKey) == 
ERROR_SUCCESS)
         {
-            RegSetValueExW(hKey, L"Name", NULL, REG_SZ, 
(LPBYTE)Props.pszwName, dwSize);
+            RegSetValueExW(hKey, L"Name", NULL, REG_SZ, 
(LPBYTE)m_Props.pszwName, dwSize);
             RegCloseKey(hKey);
         }
 
@@ -380,7 +382,7 @@
         return E_OUTOFMEMORY;
 
     pConnection->AddRef();
-    *ppv = (INetConnection *)pConnection;
+    *ppv = pConnection;
 
     return S_OK;
 }
@@ -405,11 +407,11 @@
     if (celt != 1)
         return E_FAIL;
 
-    if (!pCurrent)
+    if (!m_pCurrent)
         return S_FALSE;
 
-    hr = IConnection_Constructor(rgelt, pCurrent);
-    pCurrent = pCurrent->Next;
+    hr = IConnection_Constructor(rgelt, m_pCurrent);
+    m_pCurrent = m_pCurrent->Next;
 
     return hr;
 }
@@ -418,8 +420,8 @@
 WINAPI
 CNetConnectionManager::Skip(ULONG celt)
 {
-    while(pCurrent && celt-- > 0)
-        pCurrent = pCurrent->Next;
+    while (m_pCurrent && celt-- > 0)
+        m_pCurrent = m_pCurrent->Next;
 
     if (celt)
        return S_FALSE;
@@ -432,7 +434,7 @@
 WINAPI
 CNetConnectionManager::Reset()
 {
-    pCurrent = pHead;
+    m_pCurrent = m_pHead;
     return S_OK;
 }
 
@@ -450,7 +452,7 @@
     IP_ADAPTER_INFO * pCurrentAdapter;
 
     pCurrentAdapter = pAdapterInfo;
-    while(pCurrentAdapter)
+    while (pCurrentAdapter)
     {
         szBuffer[0] = L'\0';
         if (MultiByteToWideChar(CP_ACP, 0, pCurrentAdapter->AdapterName, -1, 
szBuffer, sizeof(szBuffer)/sizeof(szBuffer[0])))
@@ -472,7 +474,7 @@
     MIB_IFROW *IfEntry,
     NETCON_PROPERTIES    * Props)
 {
-    switch(IfEntry->dwOperStatus)
+    switch (IfEntry->dwOperStatus)
     {
         case MIB_IF_OPER_STATUS_NON_OPERATIONAL:
             Props->Status = NCS_HARDWARE_DISABLED;
@@ -518,7 +520,7 @@
     if (GetIfTable(NULL, &dwSize, TRUE) != ERROR_INSUFFICIENT_BUFFER)
         return FALSE;
 
-    pIfTable = (PMIB_IFTABLE)CoTaskMemAlloc(dwSize);
+    pIfTable = static_cast<PMIB_IFTABLE>(CoTaskMemAlloc(dwSize));
     if (!pIfTable)
         return FALSE;
 
@@ -537,7 +539,7 @@
         return FALSE;
     }
 
-    pAdapterInfo = (PIP_ADAPTER_INFO)CoTaskMemAlloc(dwSize);
+    pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
     if (!pAdapterInfo)
     {
         CoTaskMemFree(pIfTable);
@@ -593,11 +595,11 @@
         /* get detailed adapter info */
         ZeroMemory(&IfEntry, sizeof(IfEntry));
         IfEntry.dwIndex = dwAdapterIndex;
-        if(GetIfEntry(&IfEntry) != NO_ERROR)
+        if (GetIfEntry(&IfEntry) != NO_ERROR)
             break;
 
         /* allocate new INetConnectionItem */
-        PINetConnectionItem pNew = 
(PINetConnectionItem)CoTaskMemAlloc(sizeof(INetConnectionItem));
+        PINetConnectionItem pNew = 
static_cast<PINetConnectionItem>(CoTaskMemAlloc(sizeof(INetConnectionItem)));
         if (!pNew)
             break;
 
@@ -607,7 +609,7 @@
         CLSIDFromString(szNetCfg, &pNew->Props.guidId);
         NormalizeOperStatus(&IfEntry, &pNew->Props);
 
-        switch(IfEntry.dwType)
+        switch (IfEntry.dwType)
         {
             case IF_TYPE_ETHERNET_CSMACD:
                 pNew->Props.MediaType = NCM_LAN;
@@ -628,7 +630,7 @@
             dwSize = sizeof(szAdapterNetCfg);
             if (RegQueryValueExW(hSubKey, L"Name", NULL, NULL, 
(LPBYTE)szAdapterNetCfg, &dwSize) == ERROR_SUCCESS)
             {
-                pNew->Props.pszwName = 
(LPWSTR)CoTaskMemAlloc((wcslen(szAdapterNetCfg)+1) * sizeof(WCHAR));
+                pNew->Props.pszwName = 
static_cast<PWSTR>(CoTaskMemAlloc((wcslen(szAdapterNetCfg)+1) * sizeof(WCHAR)));
                 if (pNew->Props.pszwName)
                     wcscpy(pNew->Props.pszwName, szAdapterNetCfg);
             }
@@ -646,7 +648,7 @@
         SetupDiGetDeviceRegistryPropertyW(hInfo, &DevInfo, SPDRP_DEVICEDESC, 
NULL, NULL, 0, &dwSize);
         if (dwSize != 0)
         {
-            pNew->Props.pszwDeviceName = (LPWSTR)CoTaskMemAlloc(dwSize);
+            pNew->Props.pszwDeviceName = 
static_cast<PWSTR>(CoTaskMemAlloc(dwSize));
             if (pNew->Props.pszwDeviceName)
                 SetupDiGetDeviceRegistryPropertyW(hInfo, &DevInfo, 
SPDRP_DEVICEDESC, NULL, (PBYTE)pNew->Props.pszwDeviceName, dwSize, &dwSize);
         }
@@ -654,16 +656,16 @@
         if (pCurrent)
             pCurrent->Next = pNew;
         else
-            pHead = pNew;
+            m_pHead = pNew;
 
         pCurrent = pNew;
-    }while(TRUE);
+    } while (TRUE);
 
     CoTaskMemFree(pIfTable);
     CoTaskMemFree(pAdapterInfo);
     SetupDiDestroyDeviceInfoList(hInfo);
 
-    this->pCurrent = pHead;
+    m_pCurrent = m_pHead;
     return TRUE;
 }
 

Modified: trunk/reactos/dll/shellext/netshell/enumlist.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/enumlist.cpp?rev=67307&r1=67306&r2=67307&view=diff
==============================================================================
--- trunk/reactos/dll/shellext/netshell/enumlist.cpp    [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/netshell/enumlist.cpp    [iso-8859-1] Sun Apr 19 
20:18:25 2015
@@ -3,7 +3,7 @@
 /**************************************************************************
  *  AddToEnumList()
  */
-BOOL 
+BOOL
 CEnumIDList::AddToEnumList(LPITEMIDLIST pidl)
 {
     LPENUMLIST pNew;
@@ -11,37 +11,50 @@
     if (!pidl)
         return FALSE;
 
-    pNew = (LPENUMLIST)SHAlloc(sizeof(ENUMLIST));
-    if(pNew)
+    pNew = static_cast<LPENUMLIST>(SHAlloc(sizeof(ENUMLIST)));
+    if (pNew)
     {
         pNew->pNext = NULL;
         pNew->pidl = pidl;
 
-        if(!mpFirst)
+        if (!m_pFirst)
         {
-            mpFirst = pNew;
-            mpCurrent = pNew;
+            m_pFirst = pNew;
+            m_pCurrent = pNew;
         }
 
-        if(mpLast)
+        if (m_pLast)
         {
             /*add the new item to the end of the list */
-            mpLast->pNext = pNew;
+            m_pLast->pNext = pNew;
         }
 
         /*update the last item pointer */
-        mpLast = pNew;
+        m_pLast = pNew;
         return TRUE;
     }
     return FALSE;
 }
 
-CEnumIDList::CEnumIDList()
-{
-    ref = 0;
-    mpCurrent = NULL;
-    mpLast = NULL;
-    mpFirst = NULL;
+CEnumIDList::CEnumIDList() :
+    m_ref(0),
+    m_pFirst(NULL),
+    m_pLast(NULL),
+    m_pCurrent(NULL)
+{
+}
+
+CEnumIDList::~CEnumIDList()
+{
+    LPENUMLIST pDelete;
+
+    while (m_pFirst)
+    {
+        pDelete = m_pFirst;
+        m_pFirst = pDelete->pNext;
+        SHFree(pDelete->pidl);
+        SHFree(pDelete);
+    }
 }
 
 HRESULT
@@ -54,7 +67,7 @@
 
     if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IEnumIDList))
     {
-        *ppvObj = (IEnumIDList*)this;
+        *ppvObj = static_cast<IEnumIDList*>(this);
         AddRef();
         return S_OK;
     }
@@ -66,7 +79,7 @@
 WINAPI
 CEnumIDList::AddRef()
 {
-    ULONG refCount = InterlockedIncrement(&ref);
+    ULONG refCount = InterlockedIncrement(&m_ref);
 
     return refCount;
 }
@@ -74,20 +87,11 @@
 ULONG
 WINAPI CEnumIDList::Release()
 {
-    LPENUMLIST pDelete;
-    ULONG refCount = InterlockedDecrement(&ref);
-
-    if (!refCount) 
-    {
-        while (mpFirst)
-        {
-            pDelete = mpFirst;
-            mpFirst = pDelete->pNext;
-            SHFree(pDelete->pidl);
-            SHFree(pDelete);
-        }
+    ULONG refCount = InterlockedDecrement(&m_ref);
+
+    if (!refCount)
         delete this;
-    }
+
     return refCount;
 }
 
@@ -102,7 +106,7 @@
     HRESULT hr = S_OK;
     LPITEMIDLIST temp;
 
-    if(pceltFetched)
+    if (pceltFetched)
         *pceltFetched = 0;
 
     *rgelt=0;
@@ -112,19 +116,19 @@
         return E_INVALIDARG;
     }
 
-    if (celt > 0 && !mpCurrent)
+    if (celt > 0 && !m_pCurrent)
     {
         return S_FALSE;
     }
 
     for (i = 0; i < celt; i++)
     {
-        if (!mpCurrent)
+        if (!m_pCurrent)
             break;
 
-        temp = ILClone(mpCurrent->pidl);
+        temp = ILClone(m_pCurrent->pidl);
         rgelt[i] = temp;
-        mpCurrent = mpCurrent->pNext;
+        m_pCurrent = m_pCurrent->pNext;
     }
 
     if (pceltFetched)
@@ -142,12 +146,12 @@
 
     for (dwIndex = 0; dwIndex < celt; dwIndex++)
     {
-        if (!mpCurrent)
+        if (!m_pCurrent)
         {
             hr = S_FALSE;
             break;
         }
-        mpCurrent = mpCurrent->pNext;
+        m_pCurrent = m_pCurrent->pNext;
     }
 
     return hr;
@@ -157,7 +161,7 @@
 WINAPI
 CEnumIDList::Reset()
 {
-    mpCurrent = mpFirst;
+    m_pCurrent = m_pFirst;
     return S_OK;
 }
 
@@ -173,7 +177,7 @@
 
 LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
 {
-    if(pidl && pidl->mkid.cb != 0x00)
+    if (pidl && pidl->mkid.cb != 0x00)
         return (LPPIDLDATA) &(pidl->mkid.abID);
     return NULL;
 }
@@ -183,7 +187,7 @@
     LPITEMIDLIST pidlOut = NULL;
 
     pidlOut = (LPITEMIDLIST)SHAlloc(size + 5);
-    if(pidlOut)
+    if (pidlOut)
     {
         LPPIDLDATA pData;
 
@@ -243,7 +247,7 @@
 
     pidl = _ILAlloc(0x99, sizeof(PIDLDATA));
     pdata = _ILGetDataPointer(pidl);
-    pdata->u.value.pItem = (INetConnection*)pItem;
+    pdata->u.value.pItem = pItem;
 
     return pidl;
 }

Modified: trunk/reactos/dll/shellext/netshell/enumlist.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/enumlist.h?rev=67307&r1=67306&r2=67307&view=diff
==============================================================================
--- trunk/reactos/dll/shellext/netshell/enumlist.h      [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/netshell/enumlist.h      [iso-8859-1] Sun Apr 19 
20:18:25 2015
@@ -43,8 +43,10 @@
         virtual HRESULT STDMETHODCALLTYPE Clone(IEnumIDList **ppenum);
 
     private:
-        LONG        ref;
-        LPENUMLIST  mpFirst;
-        LPENUMLIST  mpLast;
-        LPENUMLIST  mpCurrent;
+        ~CEnumIDList();
+
+        LONG        m_ref;
+        LPENUMLIST  m_pFirst;
+        LPENUMLIST  m_pLast;
+        LPENUMLIST  m_pCurrent;
 };

Modified: trunk/reactos/dll/shellext/netshell/lanconnectui.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/lanconnectui.cpp?rev=67307&r1=67306&r2=67307&view=diff
==============================================================================
--- trunk/reactos/dll/shellext/netshell/lanconnectui.cpp        [iso-8859-1] 
(original)
+++ trunk/reactos/dll/shellext/netshell/lanconnectui.cpp        [iso-8859-1] 
Sun Apr 19 20:18:25 2015
@@ -31,6 +31,7 @@
 {
     public:
         CNetConnectionPropertyUi();
+        ~CNetConnectionPropertyUi();
 
         // IUnknown
         virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
@@ -57,20 +58,37 @@
         BOOL GetDeviceInstanceID(OUT LPOLESTR *DeviceInstanceID); 
         static INT_PTR CALLBACK LANPropertiesUIDlg(HWND hwndDlg, UINT uMsg, 
WPARAM wParam, LPARAM lParam);
 
-        INetConnection * pCon;
-        INetCfgLock *NCfgLock;
-        INetCfg * pNCfg;
-        NETCON_PROPERTIES * pProperties;
-        LONG ref;
+        INetConnection * m_pCon;
+        INetCfgLock *m_NCfgLock;
+        INetCfg * m_pNCfg;
+        NETCON_PROPERTIES * m_pProperties;
+        LONG m_ref;
 };
 
-CNetConnectionPropertyUi::CNetConnectionPropertyUi()
-{
-    ref = 0;
-    pCon = NULL;
-    pNCfg = NULL;
-    NCfgLock = NULL;
-    pProperties = NULL;
+CNetConnectionPropertyUi::CNetConnectionPropertyUi() :
+    m_pCon(NULL),
+    m_NCfgLock(NULL),
+    m_pNCfg(NULL),
+    m_pProperties(NULL),
+    m_ref(0)
+{
+}
+
+CNetConnectionPropertyUi::~CNetConnectionPropertyUi()
+{
+    if (m_pNCfg)
+    {
+        m_pNCfg->Uninitialize();
+        m_pNCfg->Release();
+    }
+    if (m_NCfgLock)
+    {
+        m_NCfgLock->Release();
+    }
+    if (m_pProperties)
+    {
+        NcFreeNetconProperties(m_pProperties);
+    }
 }
 
 HPROPSHEETPAGE
@@ -127,7 +145,7 @@
         hr = pNCg->GetDisplayName(&pName);
         if (SUCCEEDED(hr))
         {
-            if (!_wcsicmp(pName, pProperties->pszwDeviceName))
+            if (!_wcsicmp(pName, m_pProperties->pszwDeviceName))
             {
                 *pOut = pNCg;
                 pEnumCfg->Release();
@@ -160,7 +178,7 @@
         pNCfg->Release();
         return;
     }
-    while(pENetCfg->Next(1, &pNCfgComp, &Num) == S_OK)
+    while (pENetCfg->Next(1, &pNCfgComp, &Num) == S_OK)
     {
         hr = pNCfgComp->GetCharacteristics(&dwCharacteristics);
         if (SUCCEEDED(hr) && (dwCharacteristics & NCF_HIDDEN))
@@ -188,7 +206,7 @@
             }
         }
 
-        pItem = (NET_ITEM*)CoTaskMemAlloc(sizeof(NET_ITEM));
+        pItem = static_cast<NET_ITEM*>(CoTaskMemAlloc(sizeof(NET_ITEM)));
         if (!pItem)
             continue;
 
@@ -217,13 +235,13 @@
     LPWSTR pDisplayName;
     LVITEMW li;
 
-    SendDlgItemMessageW(hwndDlg, IDC_NETCARDNAME, WM_SETTEXT, 0, 
(LPARAM)pProperties->pszwDeviceName);
-    if (pProperties->dwCharacter & NCCF_SHOW_ICON)
+    SendDlgItemMessageW(hwndDlg, IDC_NETCARDNAME, WM_SETTEXT, 0, 
(LPARAM)m_pProperties->pszwDeviceName);
+    if (m_pProperties->dwCharacter & NCCF_SHOW_ICON)
     {
         /* check show item on taskbar*/
         SendDlgItemMessageW(hwndDlg, IDC_SHOWTASKBAR, BM_SETCHECK, 
BST_CHECKED, 0);
     }
-    if (pProperties->dwCharacter & NCCF_NOTIFY_DISCONNECTED)
+    if (m_pProperties->dwCharacter & NCCF_NOTIFY_DISCONNECTED)
     {
         /* check notify item */
         SendDlgItemMessageW(hwndDlg, IDC_NOTIFYNOCONNECTION, BM_SETCHECK, 
BST_CHECKED, 0);
@@ -255,7 +273,7 @@
         return;
     }
 
-    NCfgLock = pNCfgLock;
+    m_NCfgLock = pNCfgLock;
     hr = pNCfg->Initialize(NULL);
     if (FAILED(hr))
     {
@@ -266,7 +284,7 @@
     EnumComponents(hDlgCtrl, pNCfg, &GUID_DEVCLASS_NETCLIENT, NET_TYPE_CLIENT);
     EnumComponents(hDlgCtrl, pNCfg, &GUID_DEVCLASS_NETSERVICE, 
NET_TYPE_SERVICE);
     EnumComponents(hDlgCtrl, pNCfg, &GUID_DEVCLASS_NETTRANS, 
NET_TYPE_PROTOCOL);
-    this->pNCfg = pNCfg;
+    m_pNCfg = pNCfg;
 
     ZeroMemory(&li, sizeof(li));
     li.mask = LVIF_STATE;
@@ -337,7 +355,7 @@
     LPOLESTR pStr;
     HKEY hKey;
 
-    switch(uMsg)
+    switch (uMsg)
     {
         case WM_INITDIALOG:
             page = (PROPSHEETPAGE*)lParam;
@@ -351,9 +369,9 @@
             if (lppsn->hdr.code == PSN_APPLY)
             {
                 This = (CNetConnectionPropertyUi*)GetWindowLongPtr(hwndDlg, 
DWLP_USER);
-                if (This->pNCfg)
+                if (This->m_pNCfg)
                 {
-                    hr = This->pNCfg->Apply();
+                    hr = This->m_pNCfg->Apply();
                     if (FAILED(hr))
                         return PSNRET_INVALID;
                 }
@@ -364,7 +382,7 @@
                     dwShowIcon = 0;
 
 
-                if (StringFromCLSID((CLSID)This->pProperties->guidId, &pStr) 
== ERROR_SUCCESS)
+                if (StringFromCLSID((CLSID)This->m_pProperties->guidId, &pStr) 
== ERROR_SUCCESS)
                 {
                     swprintf(szKey, 
L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection",
 pStr);
                     CoTaskMemFree(pStr);
@@ -381,9 +399,9 @@
             else if (lppsn->hdr.code == PSN_CANCEL)
             {
                 This = (CNetConnectionPropertyUi*)GetWindowLongPtr(hwndDlg, 
DWLP_USER);
-                if (This->pNCfg)
+                if (This->m_pNCfg)
                 {
-                    hr = This->pNCfg->Cancel();
+                    hr = This->m_pNCfg->Cancel();
                     if (SUCCEEDED(hr))
                         return PSNRET_NOERROR;
                     else
@@ -465,7 +483,7 @@
     WCHAR szKeyName[2*MAX_PATH];
     WCHAR szInstanceID[2*MAX_PATH];
 
-    if (StringFromCLSID(pProperties->guidId, &pStr) != ERROR_SUCCESS)
+    if (StringFromCLSID(m_pProperties->guidId, &pStr) != ERROR_SUCCESS)
     {
         // failed to convert guid to string
         return FALSE;
@@ -484,7 +502,7 @@
     if (RegGetValueW(hKey, NULL, L"PnpInstanceId", RRF_RT_REG_SZ, NULL, 
(PVOID)szInstanceID, &dwInstanceID) == ERROR_SUCCESS)
     {
         szInstanceID[MAX_PATH-1] = L'\0';
-        pResult = (LPOLESTR)CoTaskMemAlloc((wcslen(szInstanceID) + 1) * 
sizeof(WCHAR));
+        pResult = static_cast<LPOLESTR>(CoTaskMemAlloc((wcslen(szInstanceID) + 
1) * sizeof(WCHAR)));
         if (pResult != 0)
         {
             wcscpy(pResult, szInstanceID);
@@ -537,7 +555,7 @@
 WINAPI
 CNetConnectionPropertyUi::AddRef()
 {
-    ULONG refCount = InterlockedIncrement(&ref);
+    ULONG refCount = InterlockedIncrement(&m_ref);
 
     return refCount;
 }
@@ -546,25 +564,10 @@
 WINAPI
 CNetConnectionPropertyUi::Release()
 {
-    ULONG refCount = InterlockedDecrement(&ref);
+    ULONG refCount = InterlockedDecrement(&m_ref);
 
     if (!refCount)
-    {
-        if (pNCfg)
-        {
-            pNCfg->Uninitialize();
-            pNCfg->Release();
-        }
-        if (NCfgLock)
-        {
-            NCfgLock->Release();
-        }
-        if (pProperties)
-        {
-            NcFreeNetconProperties(pProperties);
-        }
         delete this;
-    }
 
     return refCount;
 }
@@ -583,14 +586,14 @@
 
     initEx.dwSize = sizeof(initEx);
     initEx.dwICC = ICC_LISTVIEW_CLASSES;
-    if(!InitCommonControlsEx(&initEx))
+    if (!InitCommonControlsEx(&initEx))
         return E_FAIL;
 
-    hr = pCon->GetProperties(&pProperties);
+    hr = m_pCon->GetProperties(&m_pProperties);
     if (FAILED(hr))
         return hr;
 
-    hProp = InitializePropertySheetPage(MAKEINTRESOURCEW(IDD_NETPROPERTIES), 
LANPropertiesUIDlg, (LPARAM)this, pProperties->pszwName);
+    hProp = InitializePropertySheetPage(MAKEINTRESOURCEW(IDD_NETPROPERTIES), 
LANPropertiesUIDlg, (LPARAM)this, m_pProperties->pszwName);
     if (hProp)
     {
         ret = (*pfnAddPage)(hProp, lParam);
@@ -619,7 +622,7 @@
 WINAPI
 CNetConnectionPropertyUi::GetDeviceGuid(GUID *pGuid)
 {
-    CopyMemory(pGuid, &pProperties->guidId, sizeof(GUID));
+    CopyMemory(pGuid, &m_pProperties->guidId, sizeof(GUID));
     return S_OK;
 }
 
@@ -627,13 +630,13 @@
 WINAPI
 CNetConnectionPropertyUi::SetConnection(INetConnection* pCon)
 {
-    if (this->pCon)
-        this->pCon->Release();
+    if (m_pCon)
+        m_pCon->Release();
 
     if (!pCon)
         return E_POINTER;
 
-    this->pCon = pCon;
+    m_pCon = pCon;
 
     pCon->AddRef();
     return S_OK;
@@ -645,12 +648,12 @@
     HWND hwndParent,
     DWORD dwFlags)
 {
-    if (!pCon)
+    if (!m_pCon)
         return E_POINTER; //FIXME
 
 
     if (dwFlags & NCUC_NO_UI)
-        return pCon->Connect();
+        return m_pCon->Connect();
 
     return E_FAIL;
 }

Modified: trunk/reactos/dll/shellext/netshell/lanstatusui.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/lanstatusui.cpp?rev=67307&r1=67306&r2=67307&view=diff
==============================================================================
--- trunk/reactos/dll/shellext/netshell/lanstatusui.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/netshell/lanstatusui.cpp [iso-8859-1] Sun Apr 19 
20:18:25 2015
@@ -175,7 +175,7 @@
 
     ZeroMemory(&IfEntry, sizeof(IfEntry));
     IfEntry.dwIndex = pContext->dwAdapterIndex;
-    if(GetIfEntry(&IfEntry) != NO_ERROR)
+    if (GetIfEntry(&IfEntry) != NO_ERROR)
     {
         return;
     }
@@ -381,7 +381,7 @@
         }
         SubIndex++;
         pCur = pCur->Next;
-    }while(pCur && pCur->IpAddress.String[0]);
+    } while (pCur && pCur->IpAddress.String[0]);
 }
 
 static
@@ -423,7 +423,7 @@
     HWND hDlgCtrl;
     RECT rect;
 
-    switch(uMsg)
+    switch (uMsg)
     {
         case WM_INITDIALOG:
             pContext = (LANSTATUSUI_CONTEXT*)lParam;
@@ -444,16 +444,16 @@
             pAdapterInfo = NULL;
             if (GetAdaptersInfo(NULL, &dwSize) == ERROR_BUFFER_OVERFLOW)
             {
-                pAdapterInfo = (PIP_ADAPTER_INFO)CoTaskMemAlloc(dwSize);
+                pAdapterInfo = 
static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
                 if (pAdapterInfo)
                 {
                     if (GetAdaptersInfo(pAdapterInfo, &dwSize) == NO_ERROR)
                     {
                         pCurAdapter = pAdapterInfo;
-                        while(pCurAdapter && pCurAdapter->Index != 
pContext->dwAdapterIndex)
+                        while (pCurAdapter && pCurAdapter->Index != 
pContext->dwAdapterIndex)
                             pCurAdapter = pCurAdapter->Next;
 
-                        if(pCurAdapter->Index != pContext->dwAdapterIndex)
+                        if (pCurAdapter->Index != pContext->dwAdapterIndex)
                             pCurAdapter = NULL;
                     }
                 }
@@ -498,7 +498,7 @@
             dwSize = 0;
             if (GetPerAdapterInfo(pContext->dwAdapterIndex, NULL, &dwSize) == 
ERROR_BUFFER_OVERFLOW)
             {
-                pPerAdapter = (PIP_PER_ADAPTER_INFO)CoTaskMemAlloc(dwSize);
+                pPerAdapter = 
static_cast<PIP_PER_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
                 if (pPerAdapter)
                 {
                     if (GetPerAdapterInfo(pContext->dwAdapterIndex, 
pPerAdapter, &dwSize) == ERROR_SUCCESS)
@@ -544,7 +544,7 @@
     DWORD dwIpAddr;
 
 
-    switch(uMsg)
+    switch (uMsg)
     {
         case WM_INITDIALOG:
             page = (PROPSHEETPAGE*)lParam;
@@ -633,8 +633,7 @@
         {
             return TRUE;
         }
-    }
-    while(TRUE);
+    } while (TRUE);
 
     return FALSE;
 }
@@ -702,7 +701,7 @@
         return;
     }
 
-    pPnp = (LPWSTR)CoTaskMemAlloc(dwSize);
+    pPnp = static_cast<PWSTR>(CoTaskMemAlloc(dwSize));
     if (!pPnp)
     {
         RegCloseKey(hKey);
@@ -755,7 +754,7 @@
     LANSTATUSUI_CONTEXT * pContext;
     LPPSHNOTIFY lppsn;
 
-    switch(uMsg)
+    switch (uMsg)
     {
         case WM_INITDIALOG:
             page = (PROPSHEETPAGE*)lParam;
@@ -817,7 +816,7 @@
         return;
     }
 
-    pAdapterInfo = (PIP_ADAPTER_INFO)CoTaskMemAlloc(dwSize);
+    pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
     if (!pAdapterInfo)
     {
         CoTaskMemFree(pAdapterInfo);
@@ -840,7 +839,7 @@
     }
 
     pCurAdapter = pAdapterInfo;
-    while(pCurAdapter->Index != dwAdapterIndex)
+    while (pCurAdapter->Index != dwAdapterIndex)
         pCurAdapter = pCurAdapter->Next;
 
 
@@ -912,7 +911,7 @@
 {
     LANSTATUSUI_CONTEXT * pContext;
 
-    switch(uMsg)
+    switch (uMsg)
     {
         case WM_INITDIALOG:
             pContext = (LANSTATUSUI_CONTEXT *)lParam;
@@ -969,7 +968,7 @@
     if (pHead)
     {
        pItem = pHead;
-       while(pItem)
+       while (pItem)
        {
            hr = pItem->pNet->GetProperties(&pProps);
            if (SUCCEEDED(hr))
@@ -1018,11 +1017,11 @@
         if (hr == S_OK)
         {
             TRACE("new connection\n");
-            pItem = 
(NOTIFICATION_ITEM*)CoTaskMemAlloc(sizeof(NOTIFICATION_ITEM));
+            pItem = 
static_cast<NOTIFICATION_ITEM*>(CoTaskMemAlloc(sizeof(NOTIFICATION_ITEM)));
             if (!pItem)
                 break;
 
-            pContext = 
(LANSTATUSUI_CONTEXT*)CoTaskMemAlloc(sizeof(LANSTATUSUI_CONTEXT));
+            pContext = 
static_cast<LANSTATUSUI_CONTEXT*>(CoTaskMemAlloc(sizeof(LANSTATUSUI_CONTEXT)));
             if (!pContext)
             {
                 CoTaskMemFree(pItem);
@@ -1091,7 +1090,7 @@
             } else
                 ERR("CreateDialogParamW failed\n");
         }
-    } while(hr == S_OK);
+    } while (hr == S_OK);
 
     lpNetMan = pNetConMan;
     pEnumCon->Release();
@@ -1104,7 +1103,7 @@
     NOTIFICATION_ITEM *pItem;
 
     pItem = pHead;
-    while(pItem)
+    while (pItem)
     {
         if (IsEqualGUID(pItem->guidItem, *pguidCmdGroup))
         {

Modified: trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp?rev=67307&r1=67306&r2=67307&view=diff
==============================================================================
--- trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp   [iso-8859-1] 
(original)
+++ trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp   [iso-8859-1] 
Sun Apr 19 20:18:25 2015
@@ -33,6 +33,7 @@
 {
     public:
         CNetworkConnections();
+        ~CNetworkConnections();
 
         /* IUnknown */
         virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
@@ -40,7 +41,7 @@
         virtual ULONG WINAPI Release();
 
         // IShellFolder
-        virtual HRESULT WINAPI ParseDisplayName (HWND hwndOwner, LPBC pbc, 
LPOLESTR lpszDisplayName, DWORD *pchEaten, LPITEMIDLIST *ppidl, DWORD 
*pdwAttributes);
+        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(LPCITEMIDLIST pidl, LPBC 
pbcReserved, REFIID riid, LPVOID *ppvOut);
         virtual HRESULT WINAPI BindToStorage(LPCITEMIDLIST pidl, LPBC 
pbcReserved, REFIID riid, LPVOID *ppvOut);
@@ -51,7 +52,7 @@
         virtual HRESULT WINAPI GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD 
dwFlags, LPSTRRET strRet);
         virtual HRESULT WINAPI SetNameOf(HWND hwndOwner, LPCITEMIDLIST pidl, 
LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST *pPidlOut);
 
-        /* ShellFolder2 */
+        /* IShellFolder2 */
         virtual HRESULT WINAPI GetDefaultSearchGUID(GUID *pguid);
         virtual HRESULT WINAPI EnumSearches(IEnumExtraSearch **ppenum);
         virtual HRESULT WINAPI GetDefaultColumn(DWORD dwRes, ULONG *pSort, 
ULONG *pDisplay);
@@ -69,11 +70,10 @@
         virtual HRESULT WINAPI Execute(LPSHELLEXECUTEINFOW pei);
 
     private:
-        LONG ref;
+        LONG m_ref;
         /* both paths are parsible from the desktop */
-        LPITEMIDLIST pidlRoot; /* absolute pidl */
-        LPITEMIDLIST pidl; /* enumerated pidl */
-        IOleCommandTarget * lpOleCmd;
+        LPITEMIDLIST m_pidlRoot;       /* absolute pidl */
+        IOleCommandTarget *m_lpOleCmd;
 };
 
 class CNetConUiObject final :
@@ -110,10 +110,10 @@
         virtual HRESULT STDMETHODCALLTYPE Extract(LPCWSTR pszFile, UINT 
nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
 
     private:
-        LONG ref;
-        LPCITEMIDLIST apidl;
-        IUnknown *pUnknown;
-        IOleCommandTarget * lpOleCmd;
+        LONG m_ref;
+        LPCITEMIDLIST m_apidl;
+        IUnknown *m_pUnknown;
+        IOleCommandTarget *m_lpOleCmd;
 };
 
 static const shvheader NetConnectSFHeader[] = {
@@ -137,8 +137,15 @@
 HRESULT ShowNetConnectionStatus(IOleCommandTarget * lpOleCmd, INetConnection * 
pNetConnect, HWND hwnd);
 
 CNetworkConnections::CNetworkConnections()
-{
-    pidlRoot = _ILCreateNetConnect();  /* my qualified pidl */
+    : m_ref(0),
+      m_pidlRoot(_ILCreateNetConnect()),
+      m_lpOleCmd(NULL)
+{
+}
+
+CNetworkConnections::~CNetworkConnections()
+{
+    SHFree(m_pidlRoot);
 }
 
 /**************************************************************************
@@ -155,21 +162,21 @@
         IsEqualIID(riid, IID_IShellFolder) ||
         IsEqualIID(riid, IID_IShellFolder2))
     {
-        *ppvObj = (IShellFolder2*)this;
+        *ppvObj = static_cast<IShellFolder2*>(this);
     }
     else if (IsEqualIID (riid, IID_IPersistFolder) ||
              IsEqualIID (riid, IID_IPersistFolder2))
     {
-        *ppvObj = (IPersistFolder2*)this;
+        *ppvObj = static_cast<IPersistFolder2*>(this);
     }
     else if (IsEqualIID(riid, IID_IShellExecuteHookW))
     {
-        *ppvObj = (IShellExecuteHookW*)this;
+        *ppvObj = static_cast<IShellExecuteHookW*>(this);
     }
 #if 0
     else if (IsEqualIID(riid, IID_IPersistIDList))
     {
-        //*ppvObj = (IPersistIDList*)this;
+        //*ppvObj = static_cast<IPersistIDList*>(this);
     }
 #endif
     if (*ppvObj)
@@ -191,20 +198,18 @@
 
 ULONG WINAPI CNetworkConnections::AddRef()
 {
-    ULONG refCount = InterlockedIncrement(&ref);
+    ULONG refCount = InterlockedIncrement(&m_ref);
 
     return refCount;
 }
 
 ULONG WINAPI CNetworkConnections::Release()
 {
-    ULONG refCount = InterlockedDecrement(&ref);
+    ULONG refCount = InterlockedDecrement(&m_ref);
 
     if (!refCount)
-    {
-        SHFree(pidlRoot);
         delete this;
-    }
+
     return refCount;
 }
 
@@ -263,7 +268,7 @@
         {
             break;
         }
-    }while(TRUE);
+    } while (TRUE);
 
     pEnumCon->Release();
     pNetConMan->Release();
@@ -278,7 +283,7 @@
                HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
 {
     CEnumIDList *pList = new CEnumIDList;
-    *ppEnumIDList = (LPENUMIDLIST)pList;
+    *ppEnumIDList = static_cast<LPENUMIDLIST>(pList);
     if (!pList)
         return E_OUTOFMEMORY;
 
@@ -338,7 +343,7 @@
     {
         ZeroMemory(&cvf, sizeof(cvf));
         cvf.cbSize = sizeof(cvf);
-        cvf.pshf = (IShellFolder*)this;
+        cvf.pshf = static_cast<IShellFolder*>(this);
 
         IShellView* pShellView;
         hr = SHCreateShellFolderViewEx(&cvf, &pShellView);
@@ -375,7 +380,7 @@
     if (*rgfInOut == 0)
         *rgfInOut = ~0;
 
-    if(cidl == 0)
+    if (cidl == 0)
         *rgfInOut = dwNetConnectAttributes;
     else
         *rgfInOut = dwNetConnectItemAttributes;
@@ -423,10 +428,10 @@
 
     *ppvOut = NULL;
 
-    if ((IsEqualIID (riid, IID_IContextMenu) || IsEqualIID (riid, 
IID_IContextMenu2) || IsEqualIID(riid, IID_IContextMenu3) ||
+    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, lpOleCmd);
+        return IContextMenuImpl_Constructor(riid, apidl[0], ppvOut, 
m_lpOleCmd);
     }
     else
         hr = E_NOINTERFACE;
@@ -449,7 +454,7 @@
     if (!strRet)
         return E_INVALIDARG;
 
-    pszName = (WCHAR*)CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR));
+    pszName = static_cast<LPWSTR>(CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR)));
     if (!pszName)
         return E_OUTOFMEMORY;
 
@@ -593,7 +598,7 @@
         return E_FAIL;
 
 
-    switch(iColumn)
+    switch (iColumn)
     {
         case COLUMN_TYPE:
             if (pProperties->MediaType  == NCM_LAN || pProperties->MediaType 
== NCM_SHAREDACCESSHOST_RAS)
@@ -663,11 +668,11 @@
 */
 
 CNetConUiObject::CNetConUiObject(LPCITEMIDLIST apidl, IOleCommandTarget 
*lpOleCmd)
-{
-    this->apidl = apidl;
-    pUnknown = NULL;
-    this->lpOleCmd = lpOleCmd;
-    ref = 0;
+    : m_ref(0),
+      m_apidl(apidl),
+      m_pUnknown(NULL),
+      m_lpOleCmd(lpOleCmd)
+{
 }
 
 /************************************************************************
@@ -678,17 +683,17 @@
     *ppvObject = NULL;
 
     if (IsEqualIID(iid, IID_IContextMenu) || IsEqualIID(iid, 
IID_IContextMenu2) || IsEqualIID(iid, IID_IContextMenu3))
-        *ppvObject = (IContextMenu3*)this;
+        *ppvObject = static_cast<IContextMenu3*>(this);
     else if (IsEqualIID(iid, IID_IObjectWithSite))
-        *ppvObject = (IObjectWithSite*)this;
+        *ppvObject = static_cast<IObjectWithSite*>(this);
     else if (IsEqualIID(iid, IID_IQueryInfo))
-        *ppvObject = (IQueryInfo*)this;
-    else if(IsEqualIID(iid, IID_IExtractIconW))
-        *ppvObject = (IExtractIconW*)this;
+        *ppvObject = static_cast<IQueryInfo*>(this);
+    else if (IsEqualIID(iid, IID_IExtractIconW))
+        *ppvObject = static_cast<IExtractIconW*>(this);
 
     if (*ppvObject)
     {
-        InterlockedIncrement(&ref);
+        AddRef();
         return S_OK;
     }
 
@@ -705,7 +710,7 @@
 {
     ULONG refCount;
 
-    refCount = InterlockedIncrement(&ref);
+    refCount = InterlockedIncrement(&m_ref);
 
     return refCount;
 }
@@ -717,7 +722,7 @@
 {
     ULONG refCount;
 
-    refCount = InterlockedDecrement(&ref);
+    refCount = InterlockedDecrement(&m_ref);
     if (!refCount)
         delete this;
 
@@ -782,7 +787,7 @@
     VALUEStruct * val;
     NETCON_PROPERTIES * pProperties;
 
-    val = _ILGetValueStruct(apidl);
+    val = _ILGetValueStruct(m_apidl);
     if (!val)
         return E_FAIL;
 
@@ -903,7 +908,7 @@
         hr = pNCP->AddPages(hwnd, PropSheetExCallback, (LPARAM)&pinfo);
         if (SUCCEEDED(hr))
         {
-            if(PropertySheetW(&pinfo) < 0)
+            if (PropertySheetW(&pinfo) < 0)
                 hr = E_FAIL;
         }
     }
@@ -920,14 +925,14 @@
 {
     VALUEStruct * val;
 
-    val = _ILGetValueStruct(apidl);
+    val = _ILGetValueStruct(m_apidl);
     if (!val)
         return E_FAIL;
 
     if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_NET_STATUS) ||
         lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_NET_STATUS-1)) //HACK for 
Windows XP
     {
-        return ShowNetConnectionStatus(lpOleCmd, val->pItem, lpcmi->hwnd);
+        return ShowNetConnectionStatus(m_lpOleCmd, val->pItem, lpcmi->hwnd);
     }
     else if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_NET_PROPERTIES) ||
              lpcmi->lpVerb == MAKEINTRESOURCEA(10099)) //HACK for Windows XP
@@ -978,13 +983,13 @@
     HRESULT hr;
     IUnknown *pUnknown;
 
-    if (!this->pUnknown)
+    if (!m_pUnknown)
     {
         *ppvSite = NULL;
         return E_FAIL;
     }
 
-    hr = this->pUnknown->QueryInterface(riid, (LPVOID*)&pUnknown);
+    hr = m_pUnknown->QueryInterface(riid, reinterpret_cast<PVOID*>(&pUnknown));
     if (SUCCEEDED(hr))
     {
         pUnknown->AddRef();
@@ -998,20 +1003,20 @@
 
 HRESULT WINAPI CNetConUiObject::SetSite(IUnknown *pUnkSite)
 {
-    if(!pUnkSite)
-    {
-        if (this->pUnknown)
+    if (!pUnkSite)
+    {
+        if (m_pUnknown)
         {
-            this->pUnknown->Release();
-            this->pUnknown = NULL;
+            m_pUnknown->Release();
+            m_pUnknown = NULL;
         }
     }
     else
     {
         pUnkSite->AddRef();
-        if (this->pUnknown)
-            this->pUnknown->Release();
-        this->pUnknown = pUnkSite;
+        if (m_pUnknown)
+            m_pUnknown->Release();
+        m_pUnknown = pUnkSite;
     }
 
     return S_OK;
@@ -1037,7 +1042,7 @@
         return E_FAIL;
     }
 
-    val = _ILGetValueStruct(apidl);
+    val = _ILGetValueStruct(m_apidl);
     if (!val)
     {
         ERR("_ILGetValueStruct failed\n");
@@ -1107,8 +1112,8 @@
  */
 HRESULT WINAPI CNetworkConnections::Initialize(LPCITEMIDLIST pidl)
 {
-    SHFree(pidlRoot);
-    pidlRoot = ILClone(pidl);
+    SHFree(m_pidlRoot);
+    m_pidlRoot = ILClone(pidl);
 
     return S_OK;
 }
@@ -1121,7 +1126,7 @@
     if (!pidl)
         return E_POINTER;
 
-    *pidl = ILClone(pidlRoot);
+    *pidl = ILClone(m_pidlRoot);
 
     return S_OK;
 }
@@ -1144,7 +1149,7 @@
     if (pProperties->Status == NCS_CONNECTED)
     {
         NcFreeNetconProperties(pProperties);
-        return ShowNetConnectionStatus(lpOleCmd, val->pItem, pei->hwnd);
+        return ShowNetConnectionStatus(m_lpOleCmd, val->pItem, pei->hwnd);
     }
 
     NcFreeNetconProperties(pProperties);


Reply via email to