mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-27 03:43:36 +00:00
[SHELL32]
- Improve code readability in defcontextmenu.cpp - Fix few leaks - Properly handle reference count when creating objects svn path=/trunk/; revision=54979
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -123,11 +123,9 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST
|
||||
{
|
||||
HPSXA hpsx = NULL;
|
||||
HPROPSHEETPAGE hpsp[MAX_PROPERTY_SHEET_PAGE];
|
||||
WCHAR wszName[256];
|
||||
PROPSHEETHEADERW psh;
|
||||
HRESULT hr;
|
||||
CComObject<CDrvDefExt> *pDrvDefExt = NULL;
|
||||
|
||||
|
||||
ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
|
||||
psh.dwSize = sizeof(PROPSHEETHEADERW);
|
||||
psh.dwFlags = 0; // FIXME: make it modeless
|
||||
@@ -135,6 +133,7 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST
|
||||
psh.nStartPage = 0;
|
||||
psh.phpage = hpsp;
|
||||
|
||||
WCHAR wszName[256];
|
||||
if (GetVolumeInformationW(pwszDrive, wszName, sizeof(wszName) / sizeof(WCHAR), NULL, NULL, NULL, NULL, 0))
|
||||
{
|
||||
psh.pszCaption = wszName;
|
||||
@@ -148,13 +147,14 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST
|
||||
}
|
||||
|
||||
CComPtr<IDataObject> pDataObj;
|
||||
hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_IDataObject, (LPVOID *)&pDataObj);
|
||||
HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_IDataObject, (LPVOID *)&pDataObj);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ATLTRY(pDrvDefExt = new CComObject<CDrvDefExt>);
|
||||
if (pDrvDefExt)
|
||||
hr = CComObject<CDrvDefExt>::CreateInstance(&pDrvDefExt);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
pDrvDefExt->AddRef(); // CreateInstance returns object with 0 ref count
|
||||
hr = pDrvDefExt->Initialize(pidlFolder, pDataObj, NULL);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
||||
@@ -97,8 +97,6 @@ LoadPropSheetHandlers(LPCWSTR pwszPath, PROPSHEETHEADERW *pHeader, UINT cMaxPage
|
||||
BOOL
|
||||
SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl)
|
||||
{
|
||||
HRESULT hr;
|
||||
HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE];
|
||||
HPSXA hpsxa[3] = {NULL, NULL, NULL};
|
||||
CComObject<CFileDefExt> *pFileDefExt = NULL;
|
||||
|
||||
@@ -107,6 +105,7 @@ SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, LPCITEMIDLIS
|
||||
if (pwszPath == NULL || !wcslen(pwszPath))
|
||||
return FALSE;
|
||||
|
||||
HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE];
|
||||
memset(hppages, 0x0, sizeof(HPROPSHEETPAGE) * MAX_PROPERTY_SHEET_PAGE);
|
||||
|
||||
/* Make a copy of path */
|
||||
@@ -129,13 +128,14 @@ SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, LPCITEMIDLIS
|
||||
Header.pszCaption = PathFindFileNameW(wszPath);
|
||||
|
||||
CComPtr<IDataObject> pDataObj;
|
||||
hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_IDataObject, (LPVOID *)&pDataObj);
|
||||
HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_IDataObject, (LPVOID *)&pDataObj);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ATLTRY(pFileDefExt = new CComObject<CFileDefExt>);
|
||||
if (pFileDefExt)
|
||||
hr = CComObject<CFileDefExt>::CreateInstance(&pFileDefExt);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
pFileDefExt->AddRef(); // CreateInstance returns object with 0 ref count
|
||||
hr = pFileDefExt->Initialize(pidlFolder, pDataObj, NULL);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user