[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)

svn path=/trunk/; revision=67307
This commit is contained in:
Thomas Faber 2015-04-19 20:18:25 +00:00
parent 2a8f6b6f83
commit 1b57c10937
8 changed files with 276 additions and 263 deletions

View file

@ -5,7 +5,7 @@ set_cpp(WITH_RUNTIME)
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)

View file

@ -16,14 +16,14 @@ class CNetshellClassFactory :
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 @@ CNetshellClassFactory::QueryInterface(
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 @@ ULONG
WINAPI
CNetshellClassFactory::AddRef()
{
ULONG refCount = InterlockedIncrement(&ref);
ULONG refCount = InterlockedIncrement(&m_ref);
return refCount;
}
@ -55,13 +55,11 @@ ULONG
WINAPI
CNetshellClassFactory::Release()
{
ULONG refCount = InterlockedDecrement(&ref);
ULONG refCount = InterlockedDecrement(&m_ref);
if (!refCount)
{
CoTaskMemFree(this);
return 0;
}
return refCount;
}
@ -74,13 +72,13 @@ CNetshellClassFactory::CreateInstance(
{
*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;

View file

@ -30,9 +30,9 @@ class CNetConnectionManager final :
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 @@ class CNetConnection final :
{
public:
CNetConnection(PINetConnectionItem pItem);
~CNetConnection();
// IUnknown
virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
@ -56,18 +57,18 @@ class CNetConnection final :
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()
CNetConnectionManager::CNetConnectionManager() :
m_ref(0),
m_pHead(NULL),
m_pCurrent(NULL)
{
ref = 0;
pHead = NULL;
pCurrent = NULL;
}
HRESULT
@ -81,7 +82,7 @@ CNetConnectionManager::QueryInterface(
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 @@ ULONG
WINAPI
CNetConnectionManager::AddRef()
{
ULONG refCount = InterlockedIncrement(&ref);
ULONG refCount = InterlockedIncrement(&m_ref);
return refCount;
}
@ -102,7 +103,7 @@ ULONG
WINAPI
CNetConnectionManager::Release()
{
ULONG refCount = InterlockedDecrement(&ref);
ULONG refCount = InterlockedDecrement(&m_ref);
if (!refCount)
delete this;
@ -124,7 +125,7 @@ CNetConnectionManager::EnumConnections(
if (Flags != NCME_DEFAULT)
return E_FAIL;
*ppEnum = (IEnumNetConnection*)this;
*ppEnum = static_cast<IEnumNetConnection*>(this);
AddRef();
return S_OK;
}
@ -133,27 +134,32 @@ CNetConnectionManager::EnumConnections(
* INetConnection Interface
*/
CNetConnection::CNetConnection(PINetConnectionItem pItem)
CNetConnection::CNetConnection(PINetConnectionItem pItem) :
m_ref(0),
m_Props(pItem->Props),
m_dwAdapterIndex(pItem->dwAdapterIndex)
{
ref = 0;
dwAdapterIndex = pItem->dwAdapterIndex;
CopyMemory(&Props, &pItem->Props, sizeof(NETCON_PROPERTIES));
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
WINAPI
CNetConnection::QueryInterface(
@ -177,7 +183,7 @@ ULONG
WINAPI
CNetConnection::AddRef()
{
ULONG refCount = InterlockedIncrement(&ref);
ULONG refCount = InterlockedIncrement(&m_ref);
return refCount;
}
@ -186,14 +192,10 @@ ULONG
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 @@ CNetConnection::GetProperties(NETCON_PROPERTIES **ppProps)
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)
if (m_Props.pszwDeviceName)
{
pProperties->pszwDeviceName = (LPWSTR)CoTaskMemAlloc((wcslen(Props.pszwDeviceName)+1)*sizeof(WCHAR));
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 @@ CNetConnection::GetProperties(NETCON_PROPERTIES **ppProps)
{
/* 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 @@ HRESULT
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 @@ CNetConnection::Rename(LPCWSTR pszwDuplicateName)
if (pszwDuplicateName == NULL || wcslen(pszwDuplicateName) == 0)
return S_OK;
if (Props.pszwName)
if (m_Props.pszwName)
{
CoTaskMemFree(Props.pszwName);
Props.pszwName = NULL;
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);
wcscpy(m_Props.pszwName, pszwDuplicateName);
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}\\");
@ -360,7 +362,7 @@ CNetConnection::Rename(LPCWSTR pszwDuplicateName)
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 @@ HRESULT WINAPI IConnection_Constructor(INetConnection **ppv, PINetConnectionItem
return E_OUTOFMEMORY;
pConnection->AddRef();
*ppv = (INetConnection *)pConnection;
*ppv = pConnection;
return S_OK;
}
@ -405,11 +407,11 @@ CNetConnectionManager::Next(
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 @@ HRESULT
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 @@ HRESULT
WINAPI
CNetConnectionManager::Reset()
{
pCurrent = pHead;
m_pCurrent = m_pHead;
return S_OK;
}
@ -450,7 +452,7 @@ GetAdapterIndexFromNetCfgInstanceId(PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetC
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 @@ NormalizeOperStatus(
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 @@ CNetConnectionManager::EnumerateINetConnections()
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 @@ CNetConnectionManager::EnumerateINetConnections()
return FALSE;
}
pAdapterInfo = (PIP_ADAPTER_INFO)CoTaskMemAlloc(dwSize);
pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
if (!pAdapterInfo)
{
CoTaskMemFree(pIfTable);
@ -593,11 +595,11 @@ CNetConnectionManager::EnumerateINetConnections()
/* 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 @@ CNetConnectionManager::EnumerateINetConnections()
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 @@ CNetConnectionManager::EnumerateINetConnections()
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 @@ CNetConnectionManager::EnumerateINetConnections()
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 @@ CNetConnectionManager::EnumerateINetConnections()
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;
}

View file

@ -3,7 +3,7 @@
/**************************************************************************
* AddToEnumList()
*/
BOOL
BOOL
CEnumIDList::AddToEnumList(LPITEMIDLIST pidl)
{
LPENUMLIST pNew;
@ -11,37 +11,50 @@ CEnumIDList::AddToEnumList(LPITEMIDLIST pidl)
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()
CEnumIDList::CEnumIDList() :
m_ref(0),
m_pFirst(NULL),
m_pLast(NULL),
m_pCurrent(NULL)
{
ref = 0;
mpCurrent = NULL;
mpLast = NULL;
mpFirst = 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 @@ CEnumIDList::QueryInterface(
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 @@ ULONG
WINAPI
CEnumIDList::AddRef()
{
ULONG refCount = InterlockedIncrement(&ref);
ULONG refCount = InterlockedIncrement(&m_ref);
return refCount;
}
@ -74,20 +87,11 @@ CEnumIDList::AddRef()
ULONG
WINAPI CEnumIDList::Release()
{
LPENUMLIST pDelete;
ULONG refCount = InterlockedDecrement(&ref);
ULONG refCount = InterlockedDecrement(&m_ref);
if (!refCount)
{
while (mpFirst)
{
pDelete = mpFirst;
mpFirst = pDelete->pNext;
SHFree(pDelete->pidl);
SHFree(pDelete);
}
if (!refCount)
delete this;
}
return refCount;
}
@ -102,7 +106,7 @@ CEnumIDList::Next(
HRESULT hr = S_OK;
LPITEMIDLIST temp;
if(pceltFetched)
if (pceltFetched)
*pceltFetched = 0;
*rgelt=0;
@ -112,19 +116,19 @@ CEnumIDList::Next(
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 @@ CEnumIDList::Skip(ULONG celt)
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 @@ HRESULT
WINAPI
CEnumIDList::Reset()
{
mpCurrent = mpFirst;
m_pCurrent = m_pFirst;
return S_OK;
}
@ -173,7 +177,7 @@ CEnumIDList::Clone(
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 _ILAlloc(BYTE type, unsigned int size)
LPITEMIDLIST pidlOut = NULL;
pidlOut = (LPITEMIDLIST)SHAlloc(size + 5);
if(pidlOut)
if (pidlOut)
{
LPPIDLDATA pData;
@ -243,7 +247,7 @@ LPITEMIDLIST ILCreateNetConnectItem(INetConnection * pItem)
pidl = _ILAlloc(0x99, sizeof(PIDLDATA));
pdata = _ILGetDataPointer(pidl);
pdata->u.value.pItem = (INetConnection*)pItem;
pdata->u.value.pItem = pItem;
return pidl;
}

View file

@ -43,8 +43,10 @@ class CEnumIDList final :
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;
};

View file

@ -31,6 +31,7 @@ class CNetConnectionPropertyUi final :
{
public:
CNetConnectionPropertyUi();
~CNetConnectionPropertyUi();
// IUnknown
virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
@ -57,20 +58,37 @@ class CNetConnectionPropertyUi final :
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()
CNetConnectionPropertyUi::CNetConnectionPropertyUi() :
m_pCon(NULL),
m_NCfgLock(NULL),
m_pNCfg(NULL),
m_pProperties(NULL),
m_ref(0)
{
ref = 0;
pCon = NULL;
pNCfg = NULL;
NCfgLock = NULL;
pProperties = NULL;
}
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 @@ CNetConnectionPropertyUi::GetINetCfgComponent(INetCfg *pNCfg, INetCfgComponent *
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 @@ CNetConnectionPropertyUi::EnumComponents(HWND hDlgCtrl, INetCfg *pNCfg, const GU
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 @@ CNetConnectionPropertyUi::EnumComponents(HWND hDlgCtrl, INetCfg *pNCfg, const GU
}
}
pItem = (NET_ITEM*)CoTaskMemAlloc(sizeof(NET_ITEM));
pItem = static_cast<NET_ITEM*>(CoTaskMemAlloc(sizeof(NET_ITEM)));
if (!pItem)
continue;
@ -217,13 +235,13 @@ CNetConnectionPropertyUi::InitializeLANPropertiesUIDlg(HWND hwndDlg)
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 @@ CNetConnectionPropertyUi::InitializeLANPropertiesUIDlg(HWND hwndDlg)
return;
}
NCfgLock = pNCfgLock;
m_NCfgLock = pNCfgLock;
hr = pNCfg->Initialize(NULL);
if (FAILED(hr))
{
@ -266,7 +284,7 @@ CNetConnectionPropertyUi::InitializeLANPropertiesUIDlg(HWND hwndDlg)
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 @@ CNetConnectionPropertyUi::LANPropertiesUIDlg(
LPOLESTR pStr;
HKEY hKey;
switch(uMsg)
switch (uMsg)
{
case WM_INITDIALOG:
page = (PROPSHEETPAGE*)lParam;
@ -351,9 +369,9 @@ CNetConnectionPropertyUi::LANPropertiesUIDlg(
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 @@ CNetConnectionPropertyUi::LANPropertiesUIDlg(
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 @@ CNetConnectionPropertyUi::LANPropertiesUIDlg(
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 @@ CNetConnectionPropertyUi::GetDeviceInstanceID(
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 @@ CNetConnectionPropertyUi::GetDeviceInstanceID(
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 @@ ULONG
WINAPI
CNetConnectionPropertyUi::AddRef()
{
ULONG refCount = InterlockedIncrement(&ref);
ULONG refCount = InterlockedIncrement(&m_ref);
return refCount;
}
@ -546,25 +564,10 @@ ULONG
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 @@ CNetConnectionPropertyUi::AddPages(
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 @@ HRESULT
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 @@ HRESULT
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 @@ CNetConnectionPropertyUi::Connect(
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;
}

View file

@ -175,7 +175,7 @@ UpdateLanStatus(HWND hwndDlg, LANSTATUSUI_CONTEXT * pContext)
ZeroMemory(&IfEntry, sizeof(IfEntry));
IfEntry.dwIndex = pContext->dwAdapterIndex;
if(GetIfEntry(&IfEntry) != NO_ERROR)
if (GetIfEntry(&IfEntry) != NO_ERROR)
{
return;
}
@ -381,7 +381,7 @@ AddIPAddressToListView(
}
SubIndex++;
pCur = pCur->Next;
}while(pCur && pCur->IpAddress.String[0]);
} while (pCur && pCur->IpAddress.String[0]);
}
static
@ -423,7 +423,7 @@ LANStatusUiDetailsDlg(
HWND hDlgCtrl;
RECT rect;
switch(uMsg)
switch (uMsg)
{
case WM_INITDIALOG:
pContext = (LANSTATUSUI_CONTEXT*)lParam;
@ -444,16 +444,16 @@ LANStatusUiDetailsDlg(
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 @@ LANStatusUiDetailsDlg(
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 @@ LANStatusUiAdvancedDlg(
DWORD dwIpAddr;
switch(uMsg)
switch (uMsg)
{
case WM_INITDIALOG:
page = (PROPSHEETPAGE*)lParam;
@ -633,8 +633,7 @@ FindNetworkAdapter(HDEVINFO hInfo, SP_DEVINFO_DATA *pDevInfo, LPWSTR pGuid)
{
return TRUE;
}
}
while(TRUE);
} while (TRUE);
return FALSE;
}
@ -702,7 +701,7 @@ DisableNetworkAdapter(INetConnection * pNet, LANSTATUSUI_CONTEXT * pContext, HWN
return;
}
pPnp = (LPWSTR)CoTaskMemAlloc(dwSize);
pPnp = static_cast<PWSTR>(CoTaskMemAlloc(dwSize));
if (!pPnp)
{
RegCloseKey(hKey);
@ -755,7 +754,7 @@ LANStatusUiDlg(
LANSTATUSUI_CONTEXT * pContext;
LPPSHNOTIFY lppsn;
switch(uMsg)
switch (uMsg)
{
case WM_INITDIALOG:
page = (PROPSHEETPAGE*)lParam;
@ -817,7 +816,7 @@ InitializePropertyDialog(
return;
}
pAdapterInfo = (PIP_ADAPTER_INFO)CoTaskMemAlloc(dwSize);
pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
if (!pAdapterInfo)
{
CoTaskMemFree(pAdapterInfo);
@ -840,7 +839,7 @@ InitializePropertyDialog(
}
pCurAdapter = pAdapterInfo;
while(pCurAdapter->Index != dwAdapterIndex)
while (pCurAdapter->Index != dwAdapterIndex)
pCurAdapter = pCurAdapter->Next;
@ -912,7 +911,7 @@ LANStatusDlg(
{
LANSTATUSUI_CONTEXT * pContext;
switch(uMsg)
switch (uMsg)
{
case WM_INITDIALOG:
pContext = (LANSTATUSUI_CONTEXT *)lParam;
@ -969,7 +968,7 @@ CLanStatus::InitializeNetTaskbarNotifications()
if (pHead)
{
pItem = pHead;
while(pItem)
while (pItem)
{
hr = pItem->pNet->GetProperties(&pProps);
if (SUCCEEDED(hr))
@ -1018,11 +1017,11 @@ CLanStatus::InitializeNetTaskbarNotifications()
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 @@ CLanStatus::InitializeNetTaskbarNotifications()
} else
ERR("CreateDialogParamW failed\n");
}
} while(hr == S_OK);
} while (hr == S_OK);
lpNetMan = pNetConMan;
pEnumCon->Release();
@ -1104,7 +1103,7 @@ CLanStatus::ShowStatusDialogByCLSID(const GUID *pguidCmdGroup)
NOTIFICATION_ITEM *pItem;
pItem = pHead;
while(pItem)
while (pItem)
{
if (IsEqualGUID(pItem->guidItem, *pguidCmdGroup))
{

View file

@ -33,6 +33,7 @@ class CNetworkConnections final :
{
public:
CNetworkConnections();
~CNetworkConnections();
/* IUnknown */
virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
@ -40,7 +41,7 @@ class CNetworkConnections final :
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 @@ class CNetworkConnections final :
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 @@ class CNetworkConnections final :
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 @@ class CNetConUiObject final :
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 @@ static const shvheader NetConnectSFHeader[] = {
HRESULT ShowNetConnectionStatus(IOleCommandTarget * lpOleCmd, INetConnection * pNetConnect, HWND hwnd);
CNetworkConnections::CNetworkConnections()
: m_ref(0),
m_pidlRoot(_ILCreateNetConnect()),
m_lpOleCmd(NULL)
{
pidlRoot = _ILCreateNetConnect(); /* my qualified pidl */
}
CNetworkConnections::~CNetworkConnections()
{
SHFree(m_pidlRoot);
}
/**************************************************************************
@ -155,21 +162,21 @@ HRESULT WINAPI CNetworkConnections::QueryInterface(REFIID riid, LPVOID *ppvObj)
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 @@ HRESULT WINAPI CNetworkConnections::QueryInterface(REFIID riid, LPVOID *ppvObj)
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 @@ static BOOL CreateNetConnectEnumList(CEnumIDList *list, DWORD dwFlags)
{
break;
}
}while(TRUE);
} while (TRUE);
pEnumCon->Release();
pNetConMan->Release();
@ -278,7 +283,7 @@ HRESULT WINAPI CNetworkConnections::EnumObjects(
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 @@ HRESULT WINAPI CNetworkConnections::CreateViewObject(
{
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 @@ HRESULT WINAPI CNetworkConnections::GetAttributesOf(
if (*rgfInOut == 0)
*rgfInOut = ~0;
if(cidl == 0)
if (cidl == 0)
*rgfInOut = dwNetConnectAttributes;
else
*rgfInOut = dwNetConnectItemAttributes;
@ -423,10 +428,10 @@ HRESULT WINAPI CNetworkConnections::GetUIObjectOf(
*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 @@ HRESULT WINAPI CNetworkConnections::GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD d
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 @@ HRESULT WINAPI CNetworkConnections::GetDetailsOf(
return E_FAIL;
switch(iColumn)
switch (iColumn)
{
case COLUMN_TYPE:
if (pProperties->MediaType == NCM_LAN || pProperties->MediaType == NCM_SHAREDACCESSHOST_RAS)
@ -663,11 +668,11 @@ HRESULT WINAPI CNetworkConnections::MapColumnToSCID(UINT column, SHCOLUMNID *psc
*/
CNetConUiObject::CNetConUiObject(LPCITEMIDLIST apidl, IOleCommandTarget *lpOleCmd)
: m_ref(0),
m_apidl(apidl),
m_pUnknown(NULL),
m_lpOleCmd(lpOleCmd)
{
this->apidl = apidl;
pUnknown = NULL;
this->lpOleCmd = lpOleCmd;
ref = 0;
}
/************************************************************************
@ -678,17 +683,17 @@ HRESULT WINAPI CNetConUiObject::QueryInterface(REFIID iid, LPVOID *ppvObject)
*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 WINAPI CNetConUiObject::AddRef()
{
ULONG refCount;
refCount = InterlockedIncrement(&ref);
refCount = InterlockedIncrement(&m_ref);
return refCount;
}
@ -717,7 +722,7 @@ ULONG WINAPI CNetConUiObject::Release()
{
ULONG refCount;
refCount = InterlockedDecrement(&ref);
refCount = InterlockedDecrement(&m_ref);
if (!refCount)
delete this;
@ -782,7 +787,7 @@ HRESULT WINAPI CNetConUiObject::QueryContextMenu(
VALUEStruct * val;
NETCON_PROPERTIES * pProperties;
val = _ILGetValueStruct(apidl);
val = _ILGetValueStruct(m_apidl);
if (!val)
return E_FAIL;
@ -903,7 +908,7 @@ ShowNetConnectionProperties(
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 @@ HRESULT WINAPI CNetConUiObject::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
{
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 WINAPI CNetConUiObject::GetSite(REFIID riid, PVOID *ppvSite)
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::GetSite(REFIID riid, PVOID *ppvSite)
HRESULT WINAPI CNetConUiObject::SetSite(IUnknown *pUnkSite)
{
if(!pUnkSite)
if (!pUnkSite)
{
if (this->pUnknown)
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 @@ HRESULT WINAPI CNetConUiObject::GetIconLocation(
return E_FAIL;
}
val = _ILGetValueStruct(apidl);
val = _ILGetValueStruct(m_apidl);
if (!val)
{
ERR("_ILGetValueStruct failed\n");
@ -1107,8 +1112,8 @@ HRESULT WINAPI CNetworkConnections::GetClassID(CLSID *lpClassId)
*/
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 @@ HRESULT WINAPI CNetworkConnections::GetCurFolder(LPITEMIDLIST *pidl)
if (!pidl)
return E_POINTER;
*pidl = ILClone(pidlRoot);
*pidl = ILClone(m_pidlRoot);
return S_OK;
}
@ -1144,7 +1149,7 @@ HRESULT WINAPI CNetworkConnections::Execute(LPSHELLEXECUTEINFOW pei)
if (pProperties->Status == NCS_CONNECTED)
{
NcFreeNetconProperties(pProperties);
return ShowNetConnectionStatus(lpOleCmd, val->pItem, pei->hwnd);
return ShowNetConnectionStatus(m_lpOleCmd, val->pItem, pei->hwnd);
}
NcFreeNetconProperties(pProperties);