Author: cmihail
Date: Thu Sep 8 22:42:01 2011
New Revision: 53650
URL:
http://svn.reactos.org/svn/reactos?rev=53650&view=rev
Log:
[shell32.dll]
- Fix bug 6336 of shell32_new. The bug was caused by not properly verifying the return
value of ShellExecuteExW.
[FORMATTING]
- First wave of accidental formatting (sorry again about mixing code and formatting heh).
Modified:
branches/shell32_new-bringup/dll/win32/shell32/shfldr_cpanel.cpp
Modified: branches/shell32_new-bringup/dll/win32/shell32/shfldr_cpanel.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
==============================================================================
--- branches/shell32_new-bringup/dll/win32/shell32/shfldr_cpanel.cpp [iso-8859-1]
(original)
+++ branches/shell32_new-bringup/dll/win32/shell32/shfldr_cpanel.cpp [iso-8859-1] Thu Sep
8 22:42:01 2011
@@ -22,7 +22,7 @@
/*
TODO:
1. The selected items list should not be stored in CControlPanelFolder, it should
- be a result returned by an internal method.
+ be a result returned by an internal method.
*/
#include <precomp.h>
@@ -34,20 +34,20 @@
*/
class CControlPanelEnum :
- public IEnumIDListImpl
+ public IEnumIDListImpl
{
private:
public:
- CControlPanelEnum();
- ~CControlPanelEnum();
- HRESULT WINAPI Initialize(DWORD dwFlags);
- BOOL SHELL_RegisterCPanelApp(LPCSTR path);
- int SHELL_RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR szRepPath);
- int SHELL_RegisterCPanelFolders(HKEY hkey_root, LPCSTR szRepPath);
- BOOL CreateCPanelEnumList(DWORD dwFlags);
+ CControlPanelEnum();
+ ~CControlPanelEnum();
+ HRESULT WINAPI Initialize(DWORD dwFlags);
+ BOOL SHELL_RegisterCPanelApp(LPCSTR path);
+ int SHELL_RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR szRepPath);
+ int SHELL_RegisterCPanelFolders(HKEY hkey_root, LPCSTR szRepPath);
+ BOOL CreateCPanelEnumList(DWORD dwFlags);
BEGIN_COM_MAP(CControlPanelEnum)
- COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList)
+ COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList)
END_COM_MAP()
};
@@ -72,52 +72,52 @@
HRESULT WINAPI CControlPanelEnum::Initialize(DWORD dwFlags)
{
- if (CreateCPanelEnumList(dwFlags) == FALSE)
- return E_FAIL;
- return S_OK;
+ if (CreateCPanelEnumList(dwFlags) == FALSE)
+ return E_FAIL;
+ return S_OK;
}
static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR name, LPCSTR displayName, LPCSTR
comment, int iconIdx)
{
- PIDLCPanelStruct *p;
- LPITEMIDLIST pidl;
- PIDLDATA tmp;
- int size0 = (char*)&tmp.u.cpanel.szName - (char*)&tmp.u.cpanel;
- int size = size0;
- int l;
-
- tmp.type = PT_CPLAPPLET;
- tmp.u.cpanel.dummy = 0;
- tmp.u.cpanel.iconIdx = iconIdx;
-
- l = strlen(name);
- size += l + 1;
-
- tmp.u.cpanel.offsDispName = l+1;
- l = strlen(displayName);
- size += l + 1;
-
- tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName + 1 + l;
- l = strlen(comment);
- size += l + 1;
-
- pidl = (LPITEMIDLIST)SHAlloc(size + 4);
- if (!pidl)
- return NULL;
-
- pidl->mkid.cb = size + 2;
- memcpy(pidl->mkid.abID, &tmp, 2 + size0);
-
- p = &((PIDLDATA *)pidl->mkid.abID)->u.cpanel;
- strcpy(p->szName, name);
- strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName);
- strcpy(p->szName+tmp.u.cpanel.offsComment, comment);
-
- *(WORD*)((char*)pidl + (size + 2)) = 0;
-
- pcheck(pidl);
-
- return pidl;
+ PIDLCPanelStruct *p;
+ LPITEMIDLIST pidl;
+ PIDLDATA tmp;
+ int size0 = (char*)&tmp.u.cpanel.szName - (char*)&tmp.u.cpanel;
+ int size = size0;
+ int l;
+
+ tmp.type = PT_CPLAPPLET;
+ tmp.u.cpanel.dummy = 0;
+ tmp.u.cpanel.iconIdx = iconIdx;
+
+ l = strlen(name);
+ size += l + 1;
+
+ tmp.u.cpanel.offsDispName = l+1;
+ l = strlen(displayName);
+ size += l + 1;
+
+ tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName + 1 + l;
+ l = strlen(comment);
+ size += l + 1;
+
+ pidl = (LPITEMIDLIST)SHAlloc(size + 4);
+ if (!pidl)
+ return NULL;
+
+ pidl->mkid.cb = size + 2;
+ memcpy(pidl->mkid.abID, &tmp, 2 + size0);
+
+ p = &((PIDLDATA *)pidl->mkid.abID)->u.cpanel;
+ strcpy(p->szName, name);
+ strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName);
+ strcpy(p->szName+tmp.u.cpanel.offsComment, comment);
+
+ *(WORD*)((char*)pidl + (size + 2)) = 0;
+
+ pcheck(pidl);
+
+ return pidl;
}
/**************************************************************************
@@ -126,114 +126,114 @@
*/
static PIDLCPanelStruct *_ILGetCPanelPointer(LPCITEMIDLIST pidl)
{
- LPPIDLDATA pdata = _ILGetDataPointer(pidl);
-
- if (pdata && pdata->type == PT_CPLAPPLET)
- return (PIDLCPanelStruct *)&(pdata->u.cpanel);
-
- return NULL;
+ LPPIDLDATA pdata = _ILGetDataPointer(pidl);
+
+ if (pdata && pdata->type == PT_CPLAPPLET)
+ return (PIDLCPanelStruct *)&(pdata->u.cpanel);
+
+ return NULL;
}
BOOL CControlPanelEnum::SHELL_RegisterCPanelApp(LPCSTR path)
{
- LPITEMIDLIST pidl;
- CPlApplet* applet;
- CPanel panel;
- CPLINFO info;
- unsigned i;
- int iconIdx;
-
- char displayName[MAX_PATH];
- char comment[MAX_PATH];
-
- WCHAR wpath[MAX_PATH];
-
- MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
-
- panel.first = NULL;
- applet = Control_LoadApplet(0, wpath, &panel);
-
- if (applet)
- {
- for (i = 0; i < applet->count; ++i)
- {
- WideCharToMultiByte(CP_ACP, 0, applet->info[i].szName, -1, displayName, MAX_PATH,
0, 0);
- WideCharToMultiByte(CP_ACP, 0, applet->info[i].szInfo, -1, comment, MAX_PATH, 0,
0);
-
- applet->proc(0, CPL_INQUIRE, i, (LPARAM)&info);
-
- if (info.idIcon > 0)
- iconIdx = -info.idIcon; /* negative icon index instead of icon number */
- else
- iconIdx = 0;
-
- pidl = _ILCreateCPanelApplet(path, displayName, comment, iconIdx);
-
- if (pidl)
- AddToEnumList(pidl);
- }
- Control_UnloadApplet(applet);
- }
- return TRUE;
+ LPITEMIDLIST pidl;
+ CPlApplet* applet;
+ CPanel panel;
+ CPLINFO info;
+ unsigned i;
+ int iconIdx;
+
+ char displayName[MAX_PATH];
+ char comment[MAX_PATH];
+
+ WCHAR wpath[MAX_PATH];
+
+ MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
+
+ panel.first = NULL;
+ applet = Control_LoadApplet(0, wpath, &panel);
+
+ if (applet)
+ {
+ for (i = 0; i < applet->count; ++i)
+ {
+ WideCharToMultiByte(CP_ACP, 0, applet->info[i].szName, -1, displayName,
MAX_PATH, 0, 0);
+ WideCharToMultiByte(CP_ACP, 0, applet->info[i].szInfo, -1, comment,
MAX_PATH, 0, 0);
+
+ applet->proc(0, CPL_INQUIRE, i, (LPARAM)&info);
+
+ if (info.idIcon > 0)
+ iconIdx = -info.idIcon; /* negative icon index instead of icon number */
+ else
+ iconIdx = 0;
+
+ pidl = _ILCreateCPanelApplet(path, displayName, comment, iconIdx);
+
+ if (pidl)
+ AddToEnumList(pidl);
+ }
+ Control_UnloadApplet(applet);
+ }
+ return TRUE;
}
int CControlPanelEnum::SHELL_RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR
szRepPath)
{
- char name[MAX_PATH];
- char value[MAX_PATH];
- HKEY hkey;
-
- int cnt = 0;
-
- if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
- {
- int idx = 0;
-
- for(; ; idx++)
- {
- DWORD nameLen = MAX_PATH;
- DWORD valueLen = MAX_PATH;
-
- if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)&value,
&valueLen) != ERROR_SUCCESS)
- break;
-
- if (SHELL_RegisterCPanelApp(value))
- ++cnt;
- }
- RegCloseKey(hkey);
- }
-
- return cnt;
+ char name[MAX_PATH];
+ char value[MAX_PATH];
+ HKEY hkey;
+
+ int cnt = 0;
+
+ if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
+ {
+ int idx = 0;
+
+ for(; ; idx++)
+ {
+ DWORD nameLen = MAX_PATH;
+ DWORD valueLen = MAX_PATH;
+
+ if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL,
(LPBYTE)&value, &valueLen) != ERROR_SUCCESS)
+ break;
+
+ if (SHELL_RegisterCPanelApp(value))
+ ++cnt;
+ }
+ RegCloseKey(hkey);
+ }
+
+ return cnt;
}
int CControlPanelEnum::SHELL_RegisterCPanelFolders(HKEY hkey_root, LPCSTR szRepPath)
{
- char name[MAX_PATH];
- HKEY hkey;
-
- int cnt = 0;
-
- if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
- {
- int idx = 0;
- for (; ; idx++)
- {
- if (RegEnumKeyA(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS)
- break;
-
- if (*name == '{')
- {
- LPITEMIDLIST pidl = _ILCreateGuidFromStrA(name);
-
- if (pidl && AddToEnumList(pidl))
- ++cnt;
- }
- }
-
- RegCloseKey(hkey);
- }
-
- return cnt;
+ char name[MAX_PATH];
+ HKEY hkey;
+
+ int cnt = 0;
+
+ if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
+ {
+ int idx = 0;
+ for (; ; idx++)
+ {
+ if (RegEnumKeyA(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS)
+ break;
+
+ if (*name == '{')
+ {
+ LPITEMIDLIST pidl = _ILCreateGuidFromStrA(name);
+
+ if (pidl && AddToEnumList(pidl))
+ ++cnt;
+ }
+ }
+
+ RegCloseKey(hkey);
+ }
+
+ return cnt;
}
/**************************************************************************
@@ -241,79 +241,79 @@
*/
BOOL CControlPanelEnum::CreateCPanelEnumList(DWORD dwFlags)
{
- CHAR szPath[MAX_PATH];
- WIN32_FIND_DATAA wfd;
- HANDLE hFile;
-
- TRACE("(%p)->(flags=0x%08x)\n", this, dwFlags);
-
- /* enumerate control panel folders */
- if (dwFlags & SHCONTF_FOLDERS)
- SHELL_RegisterCPanelFolders(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
-
- /* enumerate the control panel applets */
- if (dwFlags & SHCONTF_NONFOLDERS)
- {
- LPSTR p;
-
- GetSystemDirectoryA(szPath, MAX_PATH);
- p = PathAddBackslashA(szPath);
- strcpy(p, "*.cpl");
-
- TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n", this,
debugstr_a(szPath));
- hFile = FindFirstFileA(szPath, &wfd);
-
- if (hFile != INVALID_HANDLE_VALUE)
- {
- do
- {
- if (!(dwFlags & SHCONTF_INCLUDEHIDDEN) && (wfd.dwFileAttributes &
FILE_ATTRIBUTE_HIDDEN))
- continue;
-
- if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- strcpy(p, wfd.cFileName);
- if (strcmp(wfd.cFileName, "ncpa.cpl"))
- SHELL_RegisterCPanelApp(szPath);
- }
- } while(FindNextFileA(hFile, &wfd));
- FindClose(hFile);
- }
-
- SHELL_RegisterRegistryCPanelApps(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
- SHELL_RegisterRegistryCPanelApps(HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
- }
- return TRUE;
+ CHAR szPath[MAX_PATH];
+ WIN32_FIND_DATAA wfd;
+ HANDLE hFile;
+
+ TRACE("(%p)->(flags=0x%08x)\n", this, dwFlags);
+
+ /* enumerate control panel folders */
+ if (dwFlags & SHCONTF_FOLDERS)
+ SHELL_RegisterCPanelFolders(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
+
+ /* enumerate the control panel applets */
+ if (dwFlags & SHCONTF_NONFOLDERS)
+ {
+ LPSTR p;
+
+ GetSystemDirectoryA(szPath, MAX_PATH);
+ p = PathAddBackslashA(szPath);
+ strcpy(p, "*.cpl");
+
+ TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n", this,
debugstr_a(szPath));
+ hFile = FindFirstFileA(szPath, &wfd);
+
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if (!(dwFlags & SHCONTF_INCLUDEHIDDEN) &&
(wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
+ continue;
+
+ if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+ strcpy(p, wfd.cFileName);
+ if (strcmp(wfd.cFileName, "ncpa.cpl"))
+ SHELL_RegisterCPanelApp(szPath);
+ }
+ } while(FindNextFileA(hFile, &wfd));
+ FindClose(hFile);
+ }
+
+ SHELL_RegisterRegistryCPanelApps(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
+ SHELL_RegisterRegistryCPanelApps(HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
+ }
+ return TRUE;
}
CControlPanelFolder::CControlPanelFolder()
{
- pidlRoot = NULL; /* absolute pidl */
- dwAttributes = 0; /* attributes returned by GetAttributesOf FIXME: use it */
- apidl = NULL;
- cidl = 0;
+ pidlRoot = NULL; /* absolute pidl */
+ dwAttributes = 0; /* attributes returned by GetAttributesOf FIXME: use it */
+ apidl = NULL;
+ cidl = 0;
}
CControlPanelFolder::~CControlPanelFolder()
{
- TRACE("-- destroying IShellFolder(%p)\n", this);
- SHFree(pidlRoot);
+ TRACE("-- destroying IShellFolder(%p)\n", this);
+ SHFree(pidlRoot);
}
HRESULT WINAPI CControlPanelFolder::FinalConstruct()
{
- pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */
- if (pidlRoot == NULL)
- return E_OUTOFMEMORY;
- return S_OK;
-}
-
-/**************************************************************************
-* ISF_ControlPanel_fnParseDisplayName
+ pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */
+ if (pidlRoot == NULL)
+ return E_OUTOFMEMORY;
+ return S_OK;
+}
+
+/**************************************************************************
+* ISF_ControlPanel_fnParseDisplayName
*/
HRESULT WINAPI CControlPanelFolder::ParseDisplayName(HWND hwndOwner,
- LPBC pbc,
- LPOLESTR lpszDisplayName,
- DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
+ LPBC pbc,
+ LPOLESTR lpszDisplayName,
+ DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
{
WCHAR szElement[MAX_PATH];
LPCWSTR szNext = NULL;
@@ -369,40 +369,40 @@
}
/**************************************************************************
-* ISF_ControlPanel_fnEnumObjects
+* ISF_ControlPanel_fnEnumObjects
*/
HRESULT WINAPI CControlPanelFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags,
LPENUMIDLIST * ppEnumIDList)
{
- CComObject<CControlPanelEnum> *theEnumerator;
- CComPtr<IEnumIDList> result;
- HRESULT hResult;
-
- TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", this, hwndOwner,
dwFlags, ppEnumIDList);
-
- if (ppEnumIDList == NULL)
- return E_POINTER;
- *ppEnumIDList = NULL;
- ATLTRY (theEnumerator = new CComObject<CControlPanelEnum>);
- if (theEnumerator == NULL)
- return E_OUTOFMEMORY;
- hResult = theEnumerator->QueryInterface (IID_IEnumIDList, (void **)&result);
- if (FAILED (hResult))
- {
- delete theEnumerator;
- return hResult;
- }
- hResult = theEnumerator->Initialize (dwFlags);
- if (FAILED (hResult))
- return hResult;
- *ppEnumIDList = result.Detach ();
+ CComObject<CControlPanelEnum> *theEnumerator;
+ CComPtr<IEnumIDList> result;
+ HRESULT hResult;
+
+ TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", this, hwndOwner,
dwFlags, ppEnumIDList);
+
+ if (ppEnumIDList == NULL)
+ return E_POINTER;
+ *ppEnumIDList = NULL;
+ ATLTRY (theEnumerator = new CComObject<CControlPanelEnum>);
+ if (theEnumerator == NULL)
+ return E_OUTOFMEMORY;
+ hResult = theEnumerator->QueryInterface (IID_IEnumIDList, (void **)&result);
+ if (FAILED (hResult))
+ {
+ delete theEnumerator;
+ return hResult;
+ }
+ hResult = theEnumerator->Initialize (dwFlags);
+ if (FAILED (hResult))
+ return hResult;
+ *ppEnumIDList = result.Detach ();
TRACE ("-- (%p)->(new ID List: %p)\n", this, *ppEnumIDList);
- return S_OK;
-}
-
-/**************************************************************************
-* ISF_ControlPanel_fnBindToObject
+ return S_OK;
+}
+
+/**************************************************************************
+* ISF_ControlPanel_fnBindToObject
*/
HRESULT WINAPI CControlPanelFolder::BindToObject(LPCITEMIDLIST pidl, LPBC pbcReserved,
REFIID riid, LPVOID * ppvOut)
{
@@ -412,7 +412,7 @@
}
/**************************************************************************
-* ISF_ControlPanel_fnBindToStorage
+* ISF_ControlPanel_fnBindToStorage
*/
HRESULT WINAPI CControlPanelFolder::BindToStorage(LPCITEMIDLIST pidl, LPBC pbcReserved,
REFIID riid, LPVOID * ppvOut)
{
@@ -423,7 +423,7 @@
}
/**************************************************************************
-* ISF_ControlPanel_fnCompareIDs
+* ISF_ControlPanel_fnCompareIDs
*/
HRESULT WINAPI CControlPanelFolder::CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1,
LPCITEMIDLIST pidl2)
@@ -437,30 +437,30 @@
}
/**************************************************************************
-* ISF_ControlPanel_fnCreateViewObject
+* ISF_ControlPanel_fnCreateViewObject
*/
HRESULT WINAPI CControlPanelFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID
* ppvOut)
{
- CComPtr<IShellView> pShellView;
+ CComPtr<IShellView> pShellView;
HRESULT hr = E_INVALIDARG;
TRACE("(%p)->(hwnd=%p,%s,%p)\n", this, hwndOwner,
shdebugstr_guid(&riid), ppvOut);
if (ppvOut) {
- *ppvOut = NULL;
-
- if (IsEqualIID(riid, IID_IDropTarget)) {
- WARN("IDropTarget not implemented\n");
- hr = E_NOTIMPL;
- } else if (IsEqualIID(riid, IID_IContextMenu)) {
- WARN("IContextMenu not implemented\n");
- hr = E_NOTIMPL;
- } else if (IsEqualIID(riid, IID_IShellView)) {
- hr = IShellView_Constructor((IShellFolder *)this, &pShellView);
- if (pShellView) {
- hr = pShellView->QueryInterface(riid, ppvOut);
- }
- }
+ *ppvOut = NULL;
+
+ if (IsEqualIID(riid, IID_IDropTarget)) {
+ WARN("IDropTarget not implemented\n");
+ hr = E_NOTIMPL;
+ } else if (IsEqualIID(riid, IID_IContextMenu)) {
+ WARN("IContextMenu not implemented\n");
+ hr = E_NOTIMPL;
+ } else if (IsEqualIID(riid, IID_IShellView)) {
+ hr = IShellView_Constructor((IShellFolder *)this, &pShellView);
+ if (pShellView) {
+ hr = pShellView->QueryInterface(riid, ppvOut);
+ }
+ }
}
TRACE("--(%p)->(interface=%p)\n", this, ppvOut);
return hr;
@@ -482,13 +482,13 @@
return E_INVALIDARG;
if (*rgfInOut == 0)
- *rgfInOut = ~0;
+ *rgfInOut = ~0;
while(cidl > 0 && *apidl) {
- pdump(*apidl);
- SHELL32_GetItemAttributes(this, *apidl, rgfInOut);
- apidl++;
- cidl--;
+ pdump(*apidl);
+ SHELL32_GetItemAttributes(this, *apidl, rgfInOut);
+ apidl++;
+ cidl--;
}
/* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
*rgfInOut &= ~SFGAO_VALIDATE;
@@ -498,7 +498,7 @@
}
/**************************************************************************
-* ISF_ControlPanel_fnGetUIObjectOf
+* ISF_ControlPanel_fnGetUIObjectOf
*
* PARAMETERS
* HWND hwndOwner, //[in ] Parent window for any output
@@ -510,59 +510,59 @@
*
*/
HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner,
- UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
+ UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID *
ppvOut)
{
LPITEMIDLIST pidl;
IUnknown *pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
- this, hwndOwner, cidl, apidl, shdebugstr_guid(&riid), prgfInOut, ppvOut);
+ this, hwndOwner, cidl, apidl, shdebugstr_guid(&riid), prgfInOut, ppvOut);
if (ppvOut) {
- *ppvOut = NULL;
-
- if (IsEqualIID(riid, IID_IContextMenu) &&(cidl >= 1)) {
- // TODO
- // create a seperate item struct
- //
- pObj = (IContextMenu *)this;
- this->apidl = apidl;
- cidl = cidl;
- pObj->AddRef();
- hr = S_OK;
- } else if (IsEqualIID(riid, IID_IDataObject) &&(cidl >= 1)) {
- hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, (IDataObject
**)&pObj);
- } else if (IsEqualIID(riid, IID_IExtractIconA) &&(cidl == 1)) {
- pidl = ILCombine(pidlRoot, apidl[0]);
- pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
- SHFree(pidl);
- hr = S_OK;
- } else if (IsEqualIID(riid, IID_IExtractIconW) &&(cidl == 1)) {
- pidl = ILCombine(pidlRoot, apidl[0]);
- pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
- SHFree(pidl);
- hr = S_OK;
- } else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid, IID_IShellLinkA))
- && (cidl == 1)) {
- pidl = ILCombine(pidlRoot, apidl[0]);
- hr = IShellLink_ConstructFromFile(NULL, riid, pidl,(LPVOID*)&pObj);
- SHFree(pidl);
- } else {
- hr = E_NOINTERFACE;
- }
-
- if (SUCCEEDED(hr) && !pObj)
- hr = E_OUTOFMEMORY;
-
- *ppvOut = pObj;
+ *ppvOut = NULL;
+
+ if (IsEqualIID(riid, IID_IContextMenu) &&(cidl >= 1)) {
+ // TODO
+ // create a seperate item struct
+ //
+ pObj = (IContextMenu *)this;
+ this->apidl = apidl;
+ cidl = cidl;
+ pObj->AddRef();
+ hr = S_OK;
+ } else if (IsEqualIID(riid, IID_IDataObject) &&(cidl >= 1)) {
+ hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, (IDataObject
**)&pObj);
+ } else if (IsEqualIID(riid, IID_IExtractIconA) &&(cidl == 1)) {
+ pidl = ILCombine(pidlRoot, apidl[0]);
+ pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
+ SHFree(pidl);
+ hr = S_OK;
+ } else if (IsEqualIID(riid, IID_IExtractIconW) &&(cidl == 1)) {
+ pidl = ILCombine(pidlRoot, apidl[0]);
+ pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
+ SHFree(pidl);
+ hr = S_OK;
+ } else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid, IID_IShellLinkA))
+ && (cidl == 1)) {
+ pidl = ILCombine(pidlRoot, apidl[0]);
+ hr = IShellLink_ConstructFromFile(NULL, riid, pidl,(LPVOID*)&pObj);
+ SHFree(pidl);
+ } else {
+ hr = E_NOINTERFACE;
+ }
+
+ if (SUCCEEDED(hr) && !pObj)
+ hr = E_OUTOFMEMORY;
+
+ *ppvOut = pObj;
}
TRACE("(%p)->hr=0x%08x\n", this, hr);
return hr;
}
/**************************************************************************
-* ISF_ControlPanel_fnGetDisplayNameOf
+* ISF_ControlPanel_fnGetDisplayNameOf
*/
HRESULT WINAPI CControlPanelFolder::GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD dwFlags,
LPSTRRET strRet)
{
@@ -576,43 +576,53 @@
pdump(pidl);
if (!pidl || !strRet)
- return E_INVALIDARG;
+ return E_INVALIDARG;
pcpanel = _ILGetCPanelPointer(pidl);
- if (pcpanel) {
- lstrcpyA(szPath, pcpanel->szName+pcpanel->offsDispName);
-
- if (!(dwFlags & SHGDN_FORPARSING))
- FIXME("retrieve display name from control panel app\n");
+ if (pcpanel)
+ {
+ lstrcpyA(szPath, pcpanel->szName+pcpanel->offsDispName);
+
+ if (!(dwFlags & SHGDN_FORPARSING))
+ FIXME("retrieve display name from control panel app\n");
}
/* take names of special folders only if it's only this folder */
- else if (_ILIsSpecialFolder(pidl)) {
- BOOL bSimplePidl = _ILIsPidlSimple(pidl);
-
- if (bSimplePidl) {
- _ILSimpleGetTextW(pidl, wszPath, MAX_PATH); /* append my own path */
- } else {
- FIXME("special pidl\n");
- }
-
- if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed
*/
- int len = 0;
-
- PathAddBackslashW(wszPath);
- len = wcslen(wszPath);
-
- if (!SUCCEEDED
- (SHELL32_GetDisplayNameOfChild(this, pidl, dwFlags, wszPath + len, MAX_PATH + 1 -
len)))
- return E_OUTOFMEMORY;
- if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL, NULL))
- wszPath[0] = '\0';
- } else {
- if (bSimplePidl) {
- if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL, NULL))
- wszPath[0] = '\0';
- }
- }
+ else if (_ILIsSpecialFolder(pidl))
+ {
+ BOOL bSimplePidl = _ILIsPidlSimple(pidl);
+
+ if (bSimplePidl)
+ {
+ _ILSimpleGetTextW(pidl, wszPath, MAX_PATH); /* append my own path */
+ }
+ else
+ {
+ FIXME("special pidl\n");
+ }
+
+ if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl)
+ {
+ /* go deeper if needed */
+ int len = 0;
+
+ PathAddBackslashW(wszPath);
+ len = wcslen(wszPath);
+
+ if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild(this, pidl, dwFlags, wszPath +
len, MAX_PATH + 1 - len)))
+ return E_OUTOFMEMORY;
+
+ if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL,
NULL))
+ wszPath[0] = '\0';
+ }
+ else
+ {
+ if (bSimplePidl)
+ {
+ if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL,
NULL))
+ wszPath[0] = '\0';
+ }
+ }
}
strRet->uType = STRRET_CSTR;
@@ -634,8 +644,8 @@
* DWORD dwFlags, //[in ] SHGNO formatting flags
* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
*/
-HRESULT WINAPI CControlPanelFolder::SetNameOf(HWND hwndOwner, LPCITEMIDLIST
pidl, /*simple pidl */
- LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
+HRESULT WINAPI CControlPanelFolder::SetNameOf(HWND hwndOwner, LPCITEMIDLIST pidl,
/*simple pidl */
+ LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
{
FIXME("(%p)->(%p,pidl=%p,%s,%u,%p)\n", this, hwndOwner, pidl,
debugstr_w(lpName), dwFlags, pPidlOut);
return E_FAIL;
@@ -684,26 +694,26 @@
TRACE("(%p)->(%p %i %p)\n", this, pidl, iColumn, psd);
if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS)
- return E_INVALIDARG;
+ return E_INVALIDARG;
if (!pidl) {
- psd->fmt = ControlPanelSFHeader[iColumn].fmt;
- psd->cxChar = ControlPanelSFHeader[iColumn].cxChar;
- psd->str.uType = STRRET_CSTR;
- LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid,
psd->str.cStr, MAX_PATH);
- return S_OK;
+ psd->fmt = ControlPanelSFHeader[iColumn].fmt;
+ psd->cxChar = ControlPanelSFHeader[iColumn].cxChar;
+ psd->str.uType = STRRET_CSTR;
+ LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid,
psd->str.cStr, MAX_PATH);
+ return S_OK;
} else {
- psd->str.cStr[0] = 0x00;
- psd->str.uType = STRRET_CSTR;
- switch(iColumn) {
- case 0: /* name */
- hr = GetDisplayNameOf(pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
- break;
- case 1: /* comment */
- _ILGetFileType(pidl, psd->str.cStr, MAX_PATH);
- break;
- }
- hr = S_OK;
+ psd->str.cStr[0] = 0x00;
+ psd->str.uType = STRRET_CSTR;
+ switch(iColumn) {
+ case 0: /* name */
+ hr = GetDisplayNameOf(pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
+ break;
+ case 1: /* comment */
+ _ILGetFileType(pidl, psd->str.cStr, MAX_PATH);
+ break;
+ }
+ hr = S_OK;
}
return hr;
@@ -715,21 +725,21 @@
}
/************************************************************************
- * ICPanel_PersistFolder2_GetClassID
+ * ICPanel_PersistFolder2_GetClassID
*/
HRESULT WINAPI CControlPanelFolder::GetClassID(CLSID *lpClassId)
{
TRACE("(%p)\n", this);
if (!lpClassId)
- return E_POINTER;
+ return E_POINTER;
*lpClassId = CLSID_ControlPanel;
return S_OK;
}
/************************************************************************
- * ICPanel_PersistFolder2_Initialize
+ * ICPanel_PersistFolder2_Initialize
*
* NOTES: it makes no sense to change the pidl
*/
@@ -743,14 +753,14 @@
}
/**************************************************************************
- * IPersistFolder2_fnGetCurFolder
+ * IPersistFolder2_fnGetCurFolder
*/
HRESULT WINAPI CControlPanelFolder::GetCurFolder(LPITEMIDLIST * pidl)
{
TRACE("(%p)->(%p)\n", this, pidl);
if (!pidl)
- return E_POINTER;
+ return E_POINTER;
*pidl = ILClone(pidlRoot);
return S_OK;
}
@@ -759,8 +769,8 @@
{
PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl);
- if (!pcpanel)
- return E_INVALIDARG;
+ if (!pcpanel)
+ return E_INVALIDARG;
MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, szIconFile, cchMax);
*piIndex = (int)pcpanel->iconIdx != -1 ? pcpanel->iconIdx : 0;
@@ -803,7 +813,7 @@
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
- if (!CreateProcessW(NULL, szExpCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si,
&pi))
+ if (!CreateProcessW(NULL, szExpCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si,
&pi))
return E_FAIL;
CloseHandle(pi.hProcess);
@@ -885,12 +895,12 @@
TRACE("(%p)->execute(%p)\n", this, psei);
if (!psei)
- return E_INVALIDARG;
+ return E_INVALIDARG;
pcpanel = _ILGetCPanelPointer(ILFindLastID((LPCITEMIDLIST)psei->lpIDList));
if (!pcpanel)
- return E_INVALIDARG;
+ return E_INVALIDARG;
path[0] = '\"';
lstrcpyA(path+1, pcpanel->szName);
@@ -905,9 +915,9 @@
ret = ShellExecuteExA(&sei_tmp);
if (ret)
- return S_OK;
+ return S_OK;
else
- return S_FALSE;
+ return S_FALSE;
}
/**************************************************************************
@@ -918,11 +928,11 @@
* ICPanel_IContextMenu_QueryContextMenu()
*/
HRESULT WINAPI CControlPanelFolder::QueryContextMenu(
- HMENU hMenu,
- UINT indexMenu,
- UINT idCmdFirst,
- UINT idCmdLast,
- UINT uFlags)
+ HMENU hMenu,
+ UINT indexMenu,
+ UINT idCmdFirst,
+ UINT idCmdLast,
+ UINT uFlags)
{
WCHAR szBuffer[30] = {0};
ULONG Count = 1;
@@ -963,9 +973,9 @@
WCHAR* pszPath;
INT Length, cLength;
PIDLCPanelStruct *pcpanel;
- CComPtr<IPersistFile> ppf;
- CComPtr<IShellLinkA> isl;
- HRESULT hResult;
+ CComPtr<IPersistFile> ppf;
+ CComPtr<IShellLinkA> isl;
+ HRESULT hResult;
TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",this,lpcmi,lpcmi->lpVerb,
lpcmi->hwnd);
@@ -978,9 +988,9 @@
sei.hwnd = lpcmi->hwnd;
sei.nShow = SW_SHOWNORMAL;
sei.lpVerb = L"open";
- ShellExecuteExW(&sei);
- if (sei.hInstApp == FALSE)
- return E_FAIL;
+
+ if (ShellExecuteExW(&sei) == FALSE)
+ return E_FAIL;
}
else if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_CREATELINK)) //FIXME
{
@@ -1029,7 +1039,7 @@
FIXME("Couldn't retrieve pointer to cpl structure\n");
return E_FAIL;
}
- hResult = ShellLink::_CreatorClass::CreateInstance(NULL, IID_IShellLinkA, (void
**)&isl);
+ hResult = ShellLink::_CreatorClass::CreateInstance(NULL, IID_IShellLinkA, (void
**)&isl);
if (SUCCEEDED(hResult))
{
isl->SetPath(szTarget);
@@ -1046,25 +1056,25 @@
*
*/
HRESULT WINAPI CControlPanelFolder::GetCommandString(
- UINT_PTR idCommand,
- UINT uFlags,
- UINT* lpReserved,
- LPSTR lpszName,
- UINT uMaxNameLen)
-{
- TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",this, idCommand,
uFlags, lpReserved, lpszName, uMaxNameLen);
-
- FIXME("unknown command string\n");
- return E_FAIL;
+ UINT_PTR idCommand,
+ UINT uFlags,
+ UINT* lpReserved,
+ LPSTR lpszName,
+ UINT uMaxNameLen)
+{
+ TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",this, idCommand,
uFlags, lpReserved, lpszName, uMaxNameLen);
+
+ FIXME("unknown command string\n");
+ return E_FAIL;
}
/**************************************************************************
* ICPanel_IContextMenu_HandleMenuMsg()
*/
HRESULT WINAPI CControlPanelFolder::HandleMenuMsg(
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
{
TRACE("ICPanel_IContextMenu_HandleMenuMsg (%p)->(msg=%x wp=%lx
lp=%lx)\n",this, uMsg, wParam, lParam);