- Cleaned up the implementation of shell folders and put them into

separate files.
- Fixed some memory leaks.
- Some more fixes.
This commit is contained in:
Juergen Schmied 2002-07-24 01:56:03 +00:00 committed by Alexandre Julliard
parent 75ce72ea44
commit 1e5ec8893d
22 changed files with 3208 additions and 2965 deletions

View File

@ -26,18 +26,21 @@ C_SRCS = \
iconcache.c \
memorystream.c \
pidl.c \
shell32_main.c \
shell.c \
shell32_main.c \
shelllink.c \
shlmenu.c \
shellole.c \
shellord.c \
shellpath.c \
shellstring.c \
shellreg.c \
shellstring.c \
shfldr_desktop.c \
shfldr_fs.c \
shfldr_mycomp.c \
shlexec.c \
shlfileop.c \
shlfolder.c \
shlmenu.c \
shlview.c \
shpolicy.c \
shv_bg_cmenu.c \

View File

@ -14,6 +14,11 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* FIXME:
* - view with root unequal desktop
* - many memory leaks
* - show only filesystem objects
*/
#include <stdlib.h>
@ -52,7 +57,7 @@ static void InitializeTreeView(HWND hwndParent, LPCITEMIDLIST root)
/* so far, this method doesn't work (still missing the upper level), keep the old way */
#if 0
if (root == NULL) {
if (_ILIsDesktop (root)) {
hr = SHGetDesktopFolder(&lpsf);
} else {
IShellFolder * lpsfdesktop;

View File

@ -30,7 +30,7 @@
#include "shell32_main.h"
#include "shlguid.h"
#include "shresdef.h"
#include "wine/obj_queryassociations.h"
#include "shlwapi.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell);
@ -62,36 +62,24 @@ BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL
RegCloseKey(hkey);
TRACE("-- %s\n", szFileType );
TRACE("--UE;
} %s\n", szFileType );
return TRUE;
}
BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
{
HKEY hkey;
char sTemp[MAX_PATH];
DWORD dwType;
BOOL ret = FALSE;
TRACE("%s %s\n",szClass, szVerb );
sprintf(sTemp, "%s\\shell\\%s\\command",szClass, szVerb);
snprintf(sTemp, MAX_PATH, "%s\\shell\\%s\\command",szClass, szVerb);
if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
{
if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
{
if (dwType == REG_EXPAND_SZ)
{
ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
strcpy(szDest, sTemp);
}
ret = TRUE;
}
RegCloseKey(hkey);
if (ERROR_SUCCESS == SHGetValueA(HKEY_CLASSES_ROOT, sTemp, NULL, NULL, szDest, &len)) {
TRACE("-- %s\n", debugstr_a(szDest) );
return TRUE;
}
TRACE("-- %s\n", szDest );
return ret;
return FALSE;
}
/***************************************************************************************
* HCR_GetDefaultIcon [internal]
@ -243,7 +231,6 @@ IQueryAssociations* IQueryAssociations_Constructor(void)
ICOM_VTBL(ei) = &qavt;
TRACE("(%p)\n",ei);
shell32_ObjCount++;
return (IQueryAssociations *)ei;
}
/**************************************************************************
@ -288,8 +275,6 @@ static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations * iface)
TRACE("(%p)->(count=%lu)\n",This, This->ref );
shell32_ObjCount++;
return ++(This->ref);
}
/**************************************************************************
@ -301,8 +286,6 @@ static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations * iface)
TRACE("(%p)->()\n",This);
shell32_ObjCount--;
if (!--(This->ref))
{
TRACE(" destroying IExtractIcon(%p)\n",This);

View File

@ -84,8 +84,6 @@ LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[])
{
memcpy(ef->pFmt, afmt, size);
}
shell32_ObjCount++;
}
TRACE("(%p)->(%u,%p)\n",ef, cfmt, afmt);
@ -123,7 +121,6 @@ static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPENUMFORMATETC iface)
{
ICOM_THIS(IEnumFORMATETCImpl,iface);
TRACE("(%p)->(count=%lu)\n",This, This->ref);
shell32_ObjCount++;
return ++(This->ref);
}
@ -132,8 +129,6 @@ static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface)
ICOM_THIS(IEnumFORMATETCImpl,iface);
TRACE("(%p)->()\n",This);
shell32_ObjCount--;
if (!--(This->ref))
{
TRACE(" destroying IEnumFORMATETC(%p)\n",This);
@ -246,8 +241,6 @@ LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, LPITEMIDLIST pMyPidl, LPITE
InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL);
InitFormatEtc(dto->pFormatEtc[1], CF_HDROP, TYMED_HGLOBAL);
InitFormatEtc(dto->pFormatEtc[2], dto->cfFileName, TYMED_HGLOBAL);
shell32_ObjCount++;
}
TRACE("(%p)->(apidl=%p cidl=%u)\n",dto, apidl, cidl);
@ -289,10 +282,7 @@ static HRESULT WINAPI IDataObject_fnQueryInterface(LPDATAOBJECT iface, REFIID ri
static ULONG WINAPI IDataObject_fnAddRef(LPDATAOBJECT iface)
{
ICOM_THIS(IDataObjectImpl,iface);
TRACE("(%p)->(count=%lu)\n",This, This->ref);
shell32_ObjCount++;
return ++(This->ref);
}
@ -304,12 +294,11 @@ static ULONG WINAPI IDataObject_fnRelease(LPDATAOBJECT iface)
ICOM_THIS(IDataObjectImpl,iface);
TRACE("(%p)->()\n",This);
shell32_ObjCount--;
if (!--(This->ref))
{
TRACE(" destroying IDataObject(%p)\n",This);
_ILFreeaPidl(This->apidl, This->cidl);
ILFree(This->pidl),
HeapFree(GetProcessHeap(),0,This);
return 0;
}
@ -454,4 +443,3 @@ static struct ICOM_VTABLE(IDataObject) dtovt =
IDataObject_fnDUnadvise,
IDataObject_fnEnumDAdvise
};

View File

@ -127,10 +127,6 @@ REFIID _dbg_ILGetGUIDPointer(LPCITEMIDLIST pidl)
case PT_SPECIAL:
case PT_MYCOMP:
return (REFIID) &(pdata->u.mycomp.guid);
default:
TRACE("Unknown pidl type 0x%04x\n", pdata->type);
break;
}
}
return NULL;
@ -169,10 +165,6 @@ DWORD _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize)
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
dwReturn = strlen (szTemp);
}
else
{
ERR("-- no text\n");
}
return dwReturn;
}
@ -209,7 +201,7 @@ void pdump (LPCITEMIDLIST pidl)
else if( PT_VALUE == type)
dwAttrib = pData->u.file.uFileAttribs;
MESSAGE ("-- pidl=%p size=%u type=%lx attr=0x%08lx name=%s (%s,%s)\n",
MESSAGE ("[%p] size=%04u type=%lx attr=0x%08lx name=\"%s\" (%s,%s)\n",
pidltemp, pidltemp->mkid.cb,type,dwAttrib,szName,debugstr_a(szLongName), debugstr_a(szShortName));
pidltemp = _dbg_ILGetNext(pidltemp);
@ -267,7 +259,7 @@ BOOL pcheck (LPCITEMIDLIST pidl)
szTemp[i+BYTES_PRINTED*3] = (c>=0x20 && c <=0x80) ? c : '.';
}
szTemp[BYTES_PRINTED*4] = 0x00;
ERR("unknown IDLIST type size=%u type=%lx\n%s\n",pidltemp->mkid.cb,type, szTemp);
ERR("unknown IDLIST %p [%p] size=%u type=%lx\n%s\n",pidl, pidltemp, pidltemp->mkid.cb,type, szTemp);
ret = FALSE;
}
}
@ -277,14 +269,16 @@ BOOL pcheck (LPCITEMIDLIST pidl)
return ret;
}
static char shdebugstr_buf[100];
static char shdebugstr_buf1[100];
static char shdebugstr_buf2[100];
static char * shdebugstr_buf = shdebugstr_buf1;
static struct {
REFIID riid;
char *name;
} InterfaceDesc[] = {
{&IID_IUnknown, "IID_IUnknown"},
{&IID_IClassFactory, "IID_IClassFactory"},
{&IID_IShellView, "IID_IShellView"},
{&IID_IOleCommandTarget, "IID_IOleCommandTarget"},
{&IID_IDropTarget, "IID_IDropTarget"},
@ -309,6 +303,8 @@ const char * shdebugstr_guid( const struct _GUID *id )
char* name = NULL;
char clsidbuf[100];
shdebugstr_buf = (shdebugstr_buf == shdebugstr_buf1) ? shdebugstr_buf2 : shdebugstr_buf1;
if (!id) {
strcpy (shdebugstr_buf, "(null)");
} else {

View File

@ -317,9 +317,9 @@ IEnumIDList * IEnumIDList_Constructor(
IEnumIDListImpl* lpeidl;
BOOL ret = FALSE;
lpeidl = (IEnumIDListImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumIDListImpl));
TRACE("()->(%s flags=0x%08lx kind=0x%08lx)\n",debugstr_a(lpszPath),dwFlags, dwKind);
TRACE("(%p)->(%s flags=0x%08lx kind=0x%08lx)\n",lpeidl,debugstr_a(lpszPath),dwFlags, dwKind);
lpeidl = (IEnumIDListImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumIDListImpl));
if (lpeidl)
{
@ -341,17 +341,10 @@ IEnumIDList * IEnumIDList_Constructor(
break;
}
if(ret)
{
shell32_ObjCount++;
}
else
{
if (lpeidl)
{
HeapFree(GetProcessHeap(),0,lpeidl);
if(!ret) {
HeapFree(GetProcessHeap(),0,lpeidl);
lpeidl = NULL;
}
}
}
TRACE("-- (%p)->()\n",lpeidl);
@ -397,10 +390,7 @@ static ULONG WINAPI IEnumIDList_fnAddRef(
IEnumIDList * iface)
{
ICOM_THIS(IEnumIDListImpl,iface);
TRACE("(%p)->(%lu)\n",This,This->ref);
shell32_ObjCount++;
return ++(This->ref);
}
/******************************************************************************
@ -413,10 +403,8 @@ static ULONG WINAPI IEnumIDList_fnRelease(
TRACE("(%p)->(%lu)\n",This,This->ref);
shell32_ObjCount--;
if (!--(This->ref))
{ TRACE(" destroying IEnumIDList(%p)\n",This);
if (!--(This->ref)) {
TRACE(" destroying IEnumIDList(%p)\n",This);
DeleteList((IEnumIDList*)This);
HeapFree(GetProcessHeap(),0,This);
return 0;

View File

@ -69,7 +69,6 @@ IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
pdump(pidl);
TRACE("(%p)\n",ei);
shell32_ObjCount++;
return (IExtractIconA *)ei;
}
/**************************************************************************
@ -111,8 +110,6 @@ static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
TRACE("(%p)->(count=%lu)\n",This, This->ref );
shell32_ObjCount++;
return ++(This->ref);
}
/**************************************************************************
@ -124,8 +121,6 @@ static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
TRACE("(%p)->()\n",This);
shell32_ObjCount--;
if (!--(This->ref))
{ TRACE(" destroying IExtractIcon(%p)\n",This);
SHFree(This->pidl);
@ -340,4 +335,3 @@ static struct ICOM_VTABLE(IPersistFile) pfvt =
(void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
(void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */
};

View File

@ -96,8 +96,6 @@ HRESULT CreateStreamOnFile (LPCSTR pszFilename, IStream ** ppstm)
fstr->ref = 1;
fstr->dwLength = GetFileSize (hFile, NULL);
shell32_ObjCount++;
if (!(fstr->hMapping = CreateFileMappingA(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL)))
{
WARN("failed to create filemap.\n");
@ -158,7 +156,6 @@ static ULONG WINAPI IStream_fnAddRef(IStream *iface)
TRACE("(%p)->(count=%lu)\n",This, This->ref);
shell32_ObjCount++;
return ++(This->ref);
}
@ -171,8 +168,6 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface)
TRACE("(%p)->()\n",This);
shell32_ObjCount--;
if (!--(This->ref))
{ TRACE(" destroying SHFileStream (%p)\n",This);

View File

@ -563,12 +563,15 @@ LPITEMIDLIST WINAPI ILGetNext(LPITEMIDLIST pidl)
{
WORD len;
TRACE("%p\n", pidl);
if(pidl)
{
len = pidl->mkid.cb;
if (len)
{
pidl = (LPITEMIDLIST) (((LPBYTE)pidl)+len);
TRACE("-- %p\n", pidl);
return pidl;
}
}
@ -907,40 +910,28 @@ HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n
* FIXME
* fnGetDisplayNameOf can return different types of OLEString
*/
BOOL WINAPI SHGetPathFromIDListA (LPCITEMIDLIST pidl,LPSTR pszPath)
{ STRRET str;
BOOL WINAPI SHGetPathFromIDListA (LPCITEMIDLIST pidl, LPSTR pszPath)
{
HRESULT hr;
STRRET str;
LPSHELLFOLDER shellfolder;
TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath);
pdump(pidl);
if (!pidl) return FALSE;
pdump(pidl);
if(_ILIsDesktop(pidl))
{
SHGetSpecialFolderPathA(0, pszPath, CSIDL_DESKTOPDIRECTORY, FALSE);
}
else if (_ILIsSpecialFolder(ILFindLastID(pidl)))
{
/* we are somewhere in a special folder */
return FALSE;
}
else
{
if (SHGetDesktopFolder(&shellfolder)==S_OK)
{
if(!SUCCEEDED(IShellFolder_GetDisplayNameOf(shellfolder,pidl,SHGDN_FORPARSING,&str))) {
IShellFolder_Release(shellfolder);
return FALSE;
hr = SHGetDesktopFolder(&shellfolder);
if (SUCCEEDED (hr)) {
hr = IShellFolder_GetDisplayNameOf(shellfolder,pidl,SHGDN_FORPARSING,&str);
if(SUCCEEDED(hr)) {
StrRetToStrNA (pszPath, MAX_PATH, &str, pidl);
}
StrRetToStrNA (pszPath, MAX_PATH, &str, pidl);
IShellFolder_Release(shellfolder);
}
}
TRACE_(shell)("-- (%s)\n",pszPath);
return TRUE;
TRACE_(shell)("-- %s, 0x%08lx\n",pszPath, hr);
return SUCCEEDED(hr);
}
/*************************************************************************
* SHGetPathFromIDListW [SHELL32.@]
@ -1287,7 +1278,7 @@ DWORD _ILGetDrive(LPCITEMIDLIST pidl,LPSTR pOut, UINT uSize)
*/
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
{ TRACE("(%p)\n",pidl);
return ( !pidl || (pidl && pidl->mkid.cb == 0x00) );
return pidl && pidl->mkid.cb ? 0 : 1;
}
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
@ -1562,12 +1553,18 @@ BOOL _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
{
FILETIME ft,lft;
SYSTEMTIME time;
BOOL ret;
if (! _ILGetFileDateTime( pidl, &ft )) return FALSE;
if (_ILGetFileDateTime( pidl, &ft )) {
FileTimeToLocalFileTime(&ft, &lft);
FileTimeToSystemTime (&lft, &time);
ret = GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, pOut, uOutSize);
} else {
pOut[0] = '\0';
ret = FALSE;
}
return ret;
FileTimeToLocalFileTime(&ft, &lft);
FileTimeToSystemTime (&lft, &time);
return GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, pOut, uOutSize);
}
/*************************************************************************

View File

@ -215,7 +215,7 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
IExtractIconA * pei = NULL;
LPITEMIDLIST pidlLast = NULL, pidl = NULL;
HRESULT hr = S_OK;
BOOL IconNotYetLoaded=TRUE;
BOOL IconNotYetLoaded=TRUE;
TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
(flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
@ -289,25 +289,20 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
/* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
the pidl functions fail on not existing file names */
if (flags & SHGFI_PIDL)
{
pidl = (LPCITEMIDLIST) path;
if (!pidl )
{
ERR("pidl is null!\n");
return FALSE;
}
}
else if (!(flags & SHGFI_USEFILEATTRIBUTES))
{
hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
/* note: the attributes in ISF::ParseDisplayName are not implemented */
if (flags & SHGFI_PIDL) {
pidl = ILClone((LPCITEMIDLIST)path);
} else if (!(flags & SHGFI_USEFILEATTRIBUTES)) {
hr = SHILCreateFromPathA(path, &pidl, &dwAttributes);
}
/* get the parent shellfolder */
if (pidl)
{
hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
if (pidl) {
hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
ILFree(pidl);
} else {
ERR("pidl is null!\n");
return FALSE;
}
/* get the attributes of the child */
@ -928,7 +923,6 @@ INT (WINAPI *pEnumMRUListA) (HANDLE hList, INT nItemPos, LPVOID lpBuffer, DW
static HINSTANCE hComctl32;
LONG shell32_ObjCount = 0;
HINSTANCE shell32_hInstance = 0;
HIMAGELIST ShellSmallIconList = 0;
HIMAGELIST ShellBigIconList = 0;
@ -995,15 +989,8 @@ BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
case DLL_PROCESS_DETACH:
shell32_hInstance = 0;
SIC_Destroy();
FreeChangeNotifications();
/* this one is here to check if AddRef/Release is balanced */
if (shell32_ObjCount)
{
WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
}
break;
}
return TRUE;

View File

@ -24,7 +24,7 @@
#include "commctrl.h"
#include "docobj.h"
#include "undocshell.h"
#include "wine/obj_shellfolder.h"
#include "wine/obj_dataobject.h"
#include "wine/obj_contextmenu.h"
@ -38,7 +38,6 @@
*/
extern HMODULE huser32;
extern HINSTANCE shell32_hInstance;
extern LONG shell32_ObjCount;
extern HIMAGELIST ShellSmallIconList;
extern HIMAGELIST ShellBigIconList;
extern HDPA sic_hdpa;
@ -98,6 +97,7 @@ LPSHELLVIEW IShellView_Constructor(LPSHELLFOLDER);
HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
HRESULT WINAPI IShellLink_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
HRESULT WINAPI ISF_Desktop_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
HRESULT WINAPI ISF_MyComputer_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
/* kind of enumidlist */
#define EIDL_DESK 0
@ -195,4 +195,22 @@ inline static BOOL SHELL_OsIsUnicode(void)
return !(GetVersion() & 0x80000000);
}
#define __SHFreeAndNil(ptr) \
{\
SHFree(*ptr); \
*ptr = NULL; \
};
inline static void __SHCloneStrA(char ** target,const char * source)
{
*target = SHAlloc(strlen(source)+1); \
strcpy(*target, source); \
}
inline static void __SHCloneStrWtoA(char ** target, const WCHAR * source)
{
int len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
*target = SHAlloc(len);
WideCharToMultiByte(CP_ACP, 0, source, -1, *target, len, NULL, NULL);
}
#endif

View File

@ -991,7 +991,6 @@ HRESULT WINAPI IShellLink_Constructor (
return E_NOINTERFACE;
}
shell32_ObjCount++;
return S_OK;
}
@ -1042,7 +1041,6 @@ static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
TRACE("(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount++;
return ++(This->ref);
}
/******************************************************************************
@ -1054,7 +1052,6 @@ static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface)
TRACE("(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount--;
if (!--(This->ref))
{ TRACE("-- destroying IShellLink(%p)\n",This);

View File

@ -37,6 +37,7 @@
#include "wine/debug.h"
#include "shlwapi.h"
#include "winuser.h"
#include "debughlp.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell);
@ -57,10 +58,11 @@ IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll,
struct {
REFIID riid;
LPFNCREATEINSTANCE lpfnCI;
} InterfaceTable[4] = {
{&CLSID_ShellFSFolder, &IFSFolder_Constructor},
{&CLSID_ShellDesktop, &ISF_Desktop_Constructor},
{&CLSID_ShellLink, &IShellLink_Constructor},
} InterfaceTable[5] = {
{&CLSID_ShellFSFolder, &IFSFolder_Constructor},
{&CLSID_MyComputer, &ISF_MyComputer_Constructor},
{&CLSID_ShellDesktop, &ISF_Desktop_Constructor},
{&CLSID_ShellLink, &IShellLink_Constructor},
{NULL,NULL}
};
@ -137,6 +139,9 @@ LRESULT WINAPI SHCoCreateInstance(
BOOLEAN bLoadWithoutCOM = FALSE;
IClassFactory * pcf = NULL;
if(!ppv) return E_POINTER;
*ppv=NULL;
/* if the clsid is a string, convert it */
if (!clsid)
{
@ -145,8 +150,8 @@ LRESULT WINAPI SHCoCreateInstance(
myclsid = &iid;
}
TRACE("(%p,\n\tCLSID:\t%s, unk:%p\n\tIID:\t%s,%p)\n",
aclsid,debugstr_guid(myclsid),pUnkOuter,debugstr_guid(refiid),ppv);
TRACE("(%p,%s,unk:%p,%s,%p)\n",
aclsid,shdebugstr_guid(myclsid),pUnkOuter,shdebugstr_guid(refiid),ppv);
/* we look up the dll path in the registry */
__SHGUIDToStringW(myclsid, sClassID);
@ -173,11 +178,9 @@ LRESULT WINAPI SHCoCreateInstance(
TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32);
/* now we create a instance */
*ppv=NULL;
if (bLoadFromShell32) {
if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
ERR("LoadFromShell failed for CLSID=%s\n", debugstr_guid(myclsid));
ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid));
}
} else if (bLoadWithoutCOM) {
@ -215,8 +218,8 @@ LRESULT WINAPI SHCoCreateInstance(
end:
if(hres!=S_OK)
{
ERR("failed (0x%08lx) to create \n\tCLSID:\t%s\n\tIID:\t%s\n",
hres, debugstr_guid(myclsid), debugstr_guid(refiid));
ERR("failed (0x%08lx) to create CLSID:%s IID:%s\n",
hres, shdebugstr_guid(myclsid), shdebugstr_guid(refiid));
ERR("class not found in registry\n");
}
@ -233,7 +236,7 @@ HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *pp
IClassFactory * pcf = NULL;
int i;
TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid),shdebugstr_guid(iid));
if (!ppv) return E_INVALIDARG;
*ppv = NULL;
@ -242,12 +245,12 @@ HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *pp
for(i=0;InterfaceTable[i].riid;i++) {
if(IsEqualIID(InterfaceTable[i].riid, rclsid)) {
TRACE("index[%u]\n", i);
pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, &shell32_ObjCount, NULL);
pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
}
}
if (!pcf) {
FIXME("failed for CLSID=%s\n", debugstr_guid(rclsid));
FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid));
return CLASS_E_CLASSNOTAVAILABLE;
}
@ -307,8 +310,7 @@ IMalloc * ShellTaskAllocator = NULL;
*/
static HRESULT WINAPI IShellMalloc_fnQueryInterface(LPMALLOC iface, REFIID refiid, LPVOID *obj)
{
TRACE("(%s,%p)\n",debugstr_guid(refiid),obj);
TRACE("(%s,%p)\n",shdebugstr_guid(refiid),obj);
if (IsEqualIID(refiid, &IID_IUnknown) || IsEqualIID(refiid, &IID_IMalloc)) {
*obj = (LPMALLOC) &Shell_Malloc;
return S_OK;
@ -458,7 +460,6 @@ LPVOID WINAPI SHAlloc(DWORD len)
if (!ShellTaskAllocator) SHGetMalloc(&ppv);
ret = (LPVOID) IMalloc_Alloc(ShellTaskAllocator, len);
if(ret) ZeroMemory(ret, len); /*FIXME*/
TRACE("%lu bytes at %p\n",len, ret);
return (LPVOID)ret;
}
@ -484,7 +485,7 @@ void WINAPI SHFree(LPVOID pv)
DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
{
HRESULT hres = S_OK;
TRACE("%p->(%p)\n",psf,*psf);
TRACE("\n");
if(!psf) return E_INVALIDARG;
*psf = NULL;
@ -493,7 +494,6 @@ DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
TRACE("-- %p->(%p)\n",psf, *psf);
return hres;
}
/**************************************************************************
* Default ClassFactory Implementation
*
@ -534,7 +534,7 @@ IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll,
if (pcRefDll) InterlockedIncrement(pcRefDll);
lpclf->riidInst = riidInst;
TRACE("(%p)\n\tIID:\t%s\n",lpclf, debugstr_guid(riidInst));
TRACE("(%p)%s\n",lpclf, shdebugstr_guid(riidInst));
return (LPCLASSFACTORY)lpclf;
}
/**************************************************************************
@ -545,7 +545,7 @@ static HRESULT WINAPI IDefClF_fnQueryInterface(
{
ICOM_THIS(IDefClFImpl,iface);
TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid));
*ppvObj = NULL;
@ -594,7 +594,7 @@ static HRESULT WINAPI IDefClF_fnCreateInstance(
{
ICOM_THIS(IDefClFImpl,iface);
TRACE("%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnkOuter,debugstr_guid(riid),ppvObject);
TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject);
*ppvObject = NULL;
@ -605,7 +605,7 @@ static HRESULT WINAPI IDefClF_fnCreateInstance(
return This->lpfnCI(pUnkOuter, riid, ppvObject);
}
ERR("unknown IID requested\n\tIID:\t%s\n",debugstr_guid(riid));
ERR("unknown IID requested %s\n",shdebugstr_guid(riid));
return E_NOINTERFACE;
}
/******************************************************************************
@ -640,8 +640,8 @@ HRESULT WINAPI SHCreateDefClassObject(
{
IClassFactory * pcf;
TRACE("\n\tIID:\t%s %p %p %p \n\tIIDIns:\t%s\n",
debugstr_guid(riid), ppv, lpfnCI, pcRefDll, debugstr_guid(riidInst));
TRACE("%s %p %p %p %s\n",
shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst));
if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE;
if (! (pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst))) return E_OUTOFMEMORY;

View File

@ -47,7 +47,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
{
TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
TRACE("dest=0x%p len=0x%lx strret=%p(%s) pidl=%p\n",
dest,len,src,
(src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
(src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
(src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
pidl);
switch (src->uType)
{
@ -66,21 +71,23 @@ HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, const ITEMID
default:
FIXME("unknown type!\n");
if (len)
{
*(LPSTR)dest = '\0';
}
if (len) *(LPSTR)dest = '\0';
return(FALSE);
}
TRACE("-- %s\n", debugstr_a(dest) );
return S_OK;
}
/************************************************************************/
HRESULT WINAPI StrRetToStrNW (LPVOID dest1, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
HRESULT WINAPI StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
{
LPWSTR dest = (LPWSTR) dest1;
TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
TRACE("dest=0x%p len=0x%lx strret=%p(%s) pidl=%p\n",
dest,len,src,
(src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
(src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
(src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
pidl);
switch (src->uType)
{
@ -90,24 +97,18 @@ HRESULT WINAPI StrRetToStrNW (LPVOID dest1, DWORD len, LPSTRRET src, const ITEMI
break;
case STRRET_CSTR:
if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
dest[len-1] = 0;
if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
((LPWSTR)dest)[len-1] = 0;
break;
case STRRET_OFFSET:
if (pidl)
{
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
dest, len ) && len)
dest[len-1] = 0;
}
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len ) && len)
((LPWSTR)dest)[len-1] = 0;
break;
default:
FIXME("unknown type!\n");
if (len)
{ *(LPSTR)dest = '\0';
}
if (len) *(LPWSTR)dest = '\0';
return(FALSE);
}
return S_OK;

48
dlls/shell32/shfldr.h Normal file
View File

@ -0,0 +1,48 @@
/*
* Virtual Folder
* common definitions
*
* Copyright 1997 Marcus Meissner
* Copyright 1998, 1999, 2002 Juergen Schmied
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
< * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
typedef struct {
int colnameid;
int pcsFlags;
int fmt;
int cxChar;
} shvheader;
#define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
#define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
LPCWSTR GetNextElementW (LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut);
HRESULT SHELL32_ParseNextElement (HWND hwndOwner, IShellFolder2 * psf, LPITEMIDLIST * pidlInOut, LPOLESTR szNext,
DWORD * pEaten, DWORD * pdwAttributes);
HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPITEMIDLIST pidl, LPDWORD pdwAttributes);
HRESULT SHELL32_CoCreateInitSF (LPITEMIDLIST pidlRoot, LPITEMIDLIST pidlChild, REFCLSID clsid, REFIID iid,
LPVOID * ppvOut);
HRESULT SHELL32_CoCreateInitSFEx (LPITEMIDLIST pidlRoot, LPCSTR pathRoot, LPITEMIDLIST pidlChild, REFCLSID clsid,
REFIID iid, LPVOID * ppvOut);
HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTR szOut,
DWORD dwOutLen);
HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut);
HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);

View File

@ -0,0 +1,664 @@
/*
* Virtual Desktop Folder
*
* Copyright 1997 Marcus Meissner
* Copyright 1998, 1999, 2002 Juergen Schmied
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "winerror.h"
#include "winbase.h"
#include "winreg.h"
#include "oleidl.h"
#include "shlguid.h"
#include "pidl.h"
#include "wine/obj_base.h"
#include "wine/obj_dragdrop.h"
#include "wine/obj_shellfolder.h"
#include "undocshell.h"
#include "shell32_main.h"
#include "shresdef.h"
#include "shlwapi.h"
#include "shellfolder.h"
#include "wine/debug.h"
#include "debughlp.h"
#include "shfldr.h"
WINE_DEFAULT_DEBUG_CHANNEL (shell);
/***********************************************************************
* Desktopfolder implementation
*/
typedef struct {
ICOM_VFIELD (IShellFolder2);
DWORD ref;
CLSID *pclsid;
/* both paths are parsible from the desktop */
LPSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */
LPITEMIDLIST pidlRoot; /* absolute pidl */
int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */
UINT cfShellIDList; /* clipboardformat for IDropTarget */
BOOL fAcceptFmt; /* flag for pending Drop */
} IGenericSFImpl;
#define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
static struct ICOM_VTABLE (IShellFolder2) vt_MCFldr_ShellFolder2;
static shvheader DesktopSFHeader[] = {
{IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
{IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12},
{IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
};
#define DESKTOPSHELLVIEWCOLUMNS 5
/**************************************************************************
* ISF_Desktop_Constructor
*/
HRESULT WINAPI ISF_Desktop_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
{
IGenericSFImpl *sf;
char szMyPath[MAX_PATH];
TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
if (!ppv)
return E_POINTER;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
if (!SHGetSpecialFolderPathA (0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE))
return E_UNEXPECTED;
sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
if (!sf)
return E_OUTOFMEMORY;
sf->ref = 0;
ICOM_VTBL (sf) = &vt_MCFldr_ShellFolder2;
sf->pidlRoot = _ILCreateDesktop (); /* my qualified pidl */
sf->sPathTarget = SHAlloc (strlen (szMyPath) + 1);
lstrcpyA (sf->sPathTarget, szMyPath);
if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) {
IUnknown_Release (_IUnknown_ (sf));
return E_NOINTERFACE;
}
TRACE ("--(%p)\n", sf);
return S_OK;
}
/**************************************************************************
* ISF_Desktop_fnQueryInterface
*
* NOTES supports not IPersist/IPersistFolder
*/
static HRESULT WINAPI ISF_Desktop_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
*ppvObj = NULL;
if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IShellFolder)
|| IsEqualIID (riid, &IID_IShellFolder2)) {
*ppvObj = This;
}
if (*ppvObj) {
IUnknown_AddRef ((IUnknown *) (*ppvObj));
TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
return S_OK;
}
TRACE ("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(count=%lu)\n", This, This->ref);
return ++(This->ref);
}
static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(count=%lu)\n", This, This->ref);
if (!--(This->ref)) {
TRACE ("-- destroying IShellFolder(%p)\n", This);
if (This->pidlRoot)
SHFree (This->pidlRoot);
if (This->sPathTarget)
SHFree (This->sPathTarget);
LocalFree ((HLOCAL) This);
}
return This->ref;
}
/**************************************************************************
* ISF_Desktop_fnParseDisplayName
*
* NOTES
* "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
* to MyComputer
*/
static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
HWND hwndOwner,
LPBC pbcReserved,
LPOLESTR lpszDisplayName,
DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
{
ICOM_THIS (IGenericSFImpl, iface);
WCHAR szElement[MAX_PATH];
LPCWSTR szNext = NULL;
LPITEMIDLIST pidlTemp = NULL;
HRESULT hr = E_OUTOFMEMORY;
CLSID clsid;
TRACE ("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
This, hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
*ppidl = 0;
if (pchEaten)
*pchEaten = 0; /* strange but like the original */
if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') {
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
TRACE ("-- element: %s\n", debugstr_w (szElement));
CLSIDFromString (szElement + 2, &clsid);
pidlTemp = _ILCreate (PT_MYCOMP, &clsid, sizeof (clsid));
} else if (PathGetDriveNumberW (lpszDisplayName) >= 0) {
/* it's a filesystem path with a drive. Let MyComputer parse it */
pidlTemp = _ILCreateMyComputer ();
szNext = lpszDisplayName;
} else {
/* it's a filesystem path on the desktop. Let a FSFolder parse it */
WCHAR szCompletePath[MAX_PATH];
/* build a complete path to create a simpel pidl */
MultiByteToWideChar (CP_ACP, 0, This->sPathTarget, -1, szCompletePath, MAX_PATH);
PathAddBackslashW (szCompletePath);
lstrcatW (szCompletePath, lpszDisplayName);
pidlTemp = SHSimpleIDListFromPathW (lpszDisplayName);
szNext = lpszDisplayName;
}
if (pidlTemp) {
if (szNext && *szNext) {
hr = SHELL32_ParseNextElement (hwndOwner, iface, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
} else {
hr = S_OK;
if (pdwAttributes && *pdwAttributes) {
SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
}
}
}
*ppidl = pidlTemp;
TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
return hr;
}
/**************************************************************************
* ISF_Desktop_fnEnumObjects
*/
static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface,
HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
*ppEnumIDList = NULL;
*ppEnumIDList = IEnumIDList_Constructor (NULL, dwFlags, EIDL_DESK);
TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
if (!*ppEnumIDList)
return E_OUTOFMEMORY;
return S_OK;
}
/**************************************************************************
* ISF_Desktop_fnBindToObject
*/
static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface,
LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut);
}
/**************************************************************************
* ISF_Desktop_fnBindToStorage
*/
static HRESULT WINAPI ISF_Desktop_fnBindToStorage (IShellFolder2 * iface,
LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
*ppvOut = NULL;
return E_NOTIMPL;
}
/**************************************************************************
* ISF_Desktop_fnCompareIDs
*/
static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 * iface,
LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
{
ICOM_THIS (IGenericSFImpl, iface);
int nReturn;
TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
TRACE ("-- %i\n", nReturn);
return nReturn;
}
/**************************************************************************
* ISF_Desktop_fnCreateViewObject
*/
static HRESULT WINAPI ISF_Desktop_fnCreateViewObject (IShellFolder2 * iface,
HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
{
ICOM_THIS (IGenericSFImpl, iface);
LPSHELLVIEW pShellView;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(hwnd=0x%x,%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)) {
pShellView = IShellView_Constructor ((IShellFolder *) iface);
if (pShellView) {
hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
IShellView_Release (pShellView);
}
}
}
TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
return hr;
}
/**************************************************************************
* ISF_Desktop_fnGetAttributesOf
*/
static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface,
UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
{
ICOM_THIS (IGenericSFImpl, iface);
HRESULT hr = S_OK;
TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
if ((!cidl) || (!apidl) || (!rgfInOut))
return E_INVALIDARG;
while (cidl > 0 && *apidl) {
pdump (*apidl);
SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
apidl++;
cidl--;
}
TRACE ("-- result=0x%08lx\n", *rgfInOut);
return hr;
}
/**************************************************************************
* ISF_Desktop_fnGetUIObjectOf
*
* PARAMETERS
* HWND hwndOwner, //[in ] Parent window for any output
* UINT cidl, //[in ] array size
* LPCITEMIDLIST* apidl, //[in ] simple pidl array
* REFIID riid, //[in ] Requested Interface
* UINT* prgfInOut, //[ ] reserved
* LPVOID* ppvObject) //[out] Resulting Interface
*
*/
static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
HWND hwndOwner,
UINT cidl,
LPCITEMIDLIST * apidl,
REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
{
ICOM_THIS (IGenericSFImpl, iface);
LPITEMIDLIST pidl;
IUnknown *pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(0x%04x,%u,apidl=%p,%s,%p,%p)\n",
This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
if (ppvOut) {
*ppvOut = NULL;
if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) {
pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
hr = S_OK;
} else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
hr = S_OK;
} else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
pidl = ILCombine (This->pidlRoot, apidl[0]);
pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
SHFree (pidl);
hr = S_OK;
} else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
} else {
hr = E_NOINTERFACE;
}
if (!pObj)
hr = E_OUTOFMEMORY;
*ppvOut = pObj;
}
TRACE ("(%p)->hr=0x%08lx\n", This, hr);
return hr;
}
/**************************************************************************
* ISF_Desktop_fnGetDisplayNameOf
*
* NOTES
* special case: pidl = null gives desktop-name back
*/
DWORD WINAPI __SHGUIDToStringA (REFGUID guid, LPSTR str)
{
CHAR sFormat[52] = "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
return wsprintfA (str, sFormat,
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
}
static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
{
ICOM_THIS (IGenericSFImpl, iface);
CHAR szPath[MAX_PATH] = "";
GUID const *clsid;
HRESULT hr = S_OK;
TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
pdump (pidl);
if (!strRet)
return E_INVALIDARG;
if (_ILIsDesktop (pidl)) {
if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)) {
lstrcpyA (szPath, This->sPathTarget);
} else {
HCR_GetClassName (&CLSID_ShellDesktop, szPath, MAX_PATH);
}
} else if (_ILIsPidlSimple (pidl)) {
if ((clsid = _ILGetGUIDPointer (pidl))) {
if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) {
int bWantsForParsing;
/*
* we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in
* CLSID\\{...}\\shellfolder exists
* exception: the MyComputer folder has this keys not but like any filesystem backed
* folder it needs these behaviour
*/
if (IsEqualIID (clsid, &CLSID_MyComputer)) {
bWantsForParsing = 1;
} else {
/* get the "WantsFORPARSING" flag from the registry */
char szRegPath[100];
lstrcpyA (szRegPath, "CLSID\\");
__SHGUIDToStringA (clsid, &szRegPath[6]);
lstrcatA (szRegPath, "\\shellfolder");
bWantsForParsing =
(ERROR_SUCCESS ==
SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL));
}
if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) {
/* we need the filesystem path to the destination folder. Only the folder itself can know it */
hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
} else {
/* parsing name like ::{...} */
lstrcpyA (szPath, "::");
__SHGUIDToStringA (clsid, &szPath[2]);
}
} else {
/* user friendly name */
HCR_GetClassName (clsid, szPath, MAX_PATH);
}
} else {
/* file system folder */
_ILSimpleGetText (pidl, szPath, MAX_PATH);
}
} else {
/* a complex pidl, let the subfolder do the work */
hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
}
if (SUCCEEDED (hr)) {
strRet->uType = STRRET_CSTR;
lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
}
TRACE ("-- (%p)->(%s,0x%08lx)\n", This, szPath, hr);
return hr;
}
/**************************************************************************
* ISF_Desktop_fnSetNameOf
* Changes the name of a file object or subfolder, possibly changing its item
* identifier in the process.
*
* PARAMETERS
* HWND hwndOwner, //[in ] Owner window for output
* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
* LPCOLESTR lpszName, //[in ] the items new display name
* DWORD dwFlags, //[in ] SHGNO formatting flags
* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
*/
static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)->(%u,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
return E_FAIL;
}
static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface,
DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)\n", This);
if (pSort)
*pSort = 0;
if (pDisplay)
*pDisplay = 0;
return S_OK;
}
static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)\n", This);
if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
return E_INVALIDARG;
*pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
return S_OK;
}
static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface,
LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
{
ICOM_THIS (IGenericSFImpl, iface);
HRESULT hr = E_FAIL;
TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
return E_INVALIDARG;
if (!pidl) {
psd->fmt = DesktopSFHeader[iColumn].fmt;
psd->cxChar = DesktopSFHeader[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
return S_OK;
} else {
/* the data from the pidl */
switch (iColumn) {
case 0: /* name */
hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
break;
case 1: /* size */
_ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 2: /* type */
_ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 3: /* date */
_ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 4: /* attributes */
_ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
break;
}
hr = S_OK;
psd->str.uType = STRRET_CSTR;
}
return hr;
}
static HRESULT WINAPI ISF_Desktop_fnMapNameToSCID (IShellFolder2 * iface, LPCWSTR pwszName, SHCOLUMNID * pscid)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static ICOM_VTABLE (IShellFolder2) vt_MCFldr_ShellFolder2 =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
ISF_Desktop_fnQueryInterface,
ISF_Desktop_fnAddRef,
ISF_Desktop_fnRelease,
ISF_Desktop_fnParseDisplayName,
ISF_Desktop_fnEnumObjects,
ISF_Desktop_fnBindToObject,
ISF_Desktop_fnBindToStorage,
ISF_Desktop_fnCompareIDs,
ISF_Desktop_fnCreateViewObject,
ISF_Desktop_fnGetAttributesOf,
ISF_Desktop_fnGetUIObjectOf,
ISF_Desktop_fnGetDisplayNameOf,
ISF_Desktop_fnSetNameOf,
/* ShellFolder2 */
ISF_Desktop_fnGetDefaultSearchGUID,
ISF_Desktop_fnEnumSearches,
ISF_Desktop_fnGetDefaultColumn,
ISF_Desktop_fnGetDefaultColumnState,
ISF_Desktop_fnGetDetailsEx,
ISF_Desktop_fnGetDetailsOf,
ISF_Desktop_fnMapNameToSCID};

1356
dlls/shell32/shfldr_fs.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,711 @@
/*
* Virtual Workplace folder
*
* Copyright 1997 Marcus Meissner
* Copyright 1998, 1999, 2002 Juergen Schmied
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "winerror.h"
#include "winbase.h"
#include "winreg.h"
#include "oleidl.h"
#include "shlguid.h"
#include "pidl.h"
#include "wine/obj_base.h"
#include "wine/obj_dragdrop.h"
#include "wine/obj_shellfolder.h"
#include "undocshell.h"
#include "shell32_main.h"
#include "shresdef.h"
#include "shlwapi.h"
#include "shellfolder.h"
#include "wine/debug.h"
#include "debughlp.h"
#include "shfldr.h"
WINE_DEFAULT_DEBUG_CHANNEL (shell);
/***********************************************************************
* IShellFolder implementation
*/
typedef struct {
ICOM_VFIELD (IShellFolder2);
DWORD ref;
ICOM_VTABLE (IPersistFolder2) * lpVtblPersistFolder2;
/* both paths are parsible from the desktop */
LPITEMIDLIST pidlRoot; /* absolute pidl */
int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */
} IGenericSFImpl;
static struct ICOM_VTABLE (IShellFolder2) vt_ShellFolder2;
static struct ICOM_VTABLE (IPersistFolder2) vt_PersistFolder2;
HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
#define _IPersistFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2)))
#define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
/*
converts This to a interface pointer
*/
#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
#define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl)
#define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2)
#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2)
#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2)
/***********************************************************************
* IShellFolder [MyComputer] implementation
*/
static shvheader MyComputerSFHeader[] = {
{IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
{IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
};
#define MYCOMPUTERSHELLVIEWCOLUMNS 4
/**************************************************************************
* ISF_MyComputer_Constructor
*/
HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
{
IGenericSFImpl *sf;
TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
if (!ppv)
return E_POINTER;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
if (!sf)
return E_OUTOFMEMORY;
sf->ref = 0;
ICOM_VTBL (sf) = &vt_ShellFolder2;
sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
sf->pidlRoot = _ILCreateMyComputer (); /* my qualified pidl */
if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) {
IUnknown_Release (_IUnknown_ (sf));
return E_NOINTERFACE;
}
TRACE ("--(%p)\n", sf);
return S_OK;
}
/**************************************************************************
* ISF_MyComputer_fnQueryInterface
*
* NOTES supports not IPersist/IPersistFolder
*/
static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
*ppvObj = NULL;
if (IsEqualIID (riid, &IID_IUnknown) ||
IsEqualIID (riid, &IID_IShellFolder) || IsEqualIID (riid, &IID_IShellFolder2)) {
*ppvObj = This;
} else if (IsEqualIID (riid, &IID_IPersist) ||
IsEqualIID (riid, &IID_IPersistFolder) || IsEqualIID (riid, &IID_IPersistFolder2)) {
*ppvObj = _IPersistFolder2_ (This);
}
if (*ppvObj) {
IUnknown_AddRef ((IUnknown *) (*ppvObj));
TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
return S_OK;
}
TRACE ("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(count=%lu)\n", This, This->ref);
return ++(This->ref);
}
static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(count=%lu)\n", This, This->ref);
if (!--(This->ref)) {
TRACE ("-- destroying IShellFolder(%p)\n", This);
if (This->pidlRoot)
SHFree (This->pidlRoot);
LocalFree ((HLOCAL) This);
}
return This->ref;
}
/**************************************************************************
* ISF_MyComputer_fnParseDisplayName
*/
static HRESULT WINAPI
ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface,
HWND hwndOwner,
LPBC pbcReserved,
LPOLESTR lpszDisplayName,
DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
{
ICOM_THIS (IGenericSFImpl, iface);
HRESULT hr = E_OUTOFMEMORY;
LPCWSTR szNext = NULL;
WCHAR szElement[MAX_PATH];
CHAR szTempA[MAX_PATH];
LPITEMIDLIST pidlTemp;
TRACE ("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
This, hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
*ppidl = 0;
if (pchEaten)
*pchEaten = 0; /* strange but like the original */
/* do we have an absolute path name ? */
if (PathGetDriveNumberW (lpszDisplayName) >= 0 && lpszDisplayName[2] == (WCHAR) '\\') {
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
WideCharToMultiByte (CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL);
pidlTemp = _ILCreateDrive (szTempA);
if (szNext && *szNext) {
hr = SHELL32_ParseNextElement (hwndOwner, iface, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
} else {
if (pdwAttributes && *pdwAttributes) {
SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
}
hr = S_OK;
}
*ppidl = pidlTemp;
}
TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnEnumObjects
*/
static HRESULT WINAPI
ISF_MyComputer_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
*ppEnumIDList = IEnumIDList_Constructor (NULL, dwFlags, EIDL_MYCOMP);
TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
}
/**************************************************************************
* ISF_MyComputer_fnBindToObject
*/
static HRESULT WINAPI
ISF_MyComputer_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl,
LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut);
}
/**************************************************************************
* ISF_MyComputer_fnBindToStorage
*/
static HRESULT WINAPI
ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface,
LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
*ppvOut = NULL;
return E_NOTIMPL;
}
/**************************************************************************
* ISF_MyComputer_fnCompareIDs
*/
static HRESULT WINAPI
ISF_MyComputer_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
{
ICOM_THIS (IGenericSFImpl, iface);
int nReturn;
TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
TRACE ("-- %i\n", nReturn);
return nReturn;
}
/**************************************************************************
* ISF_MyComputer_fnCreateViewObject
*/
static HRESULT WINAPI
ISF_MyComputer_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
{
ICOM_THIS (IGenericSFImpl, iface);
LPSHELLVIEW pShellView;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(hwnd=0x%x,%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)) {
pShellView = IShellView_Constructor ((IShellFolder *) iface);
if (pShellView) {
hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
IShellView_Release (pShellView);
}
}
}
TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnGetAttributesOf
*/
static HRESULT WINAPI
ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
{
ICOM_THIS (IGenericSFImpl, iface);
HRESULT hr = S_OK;
TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
if ((!cidl) || (!apidl) || (!rgfInOut))
return E_INVALIDARG;
while (cidl > 0 && *apidl) {
pdump (*apidl);
SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
apidl++;
cidl--;
}
TRACE ("-- result=0x%08lx\n", *rgfInOut);
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnGetUIObjectOf
*
* PARAMETERS
* HWND hwndOwner, //[in ] Parent window for any output
* UINT cidl, //[in ] array size
* LPCITEMIDLIST* apidl, //[in ] simple pidl array
* REFIID riid, //[in ] Requested Interface
* UINT* prgfInOut, //[ ] reserved
* LPVOID* ppvObject) //[out] Resulting Interface
*
*/
static HRESULT WINAPI
ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
HWND hwndOwner,
UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
{
ICOM_THIS (IGenericSFImpl, iface);
LPITEMIDLIST pidl;
IUnknown *pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(0x%04x,%u,apidl=%p,%s,%p,%p)\n",
This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
if (ppvOut) {
*ppvOut = NULL;
if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) {
pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
hr = S_OK;
} else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
hr = S_OK;
} else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
pidl = ILCombine (This->pidlRoot, apidl[0]);
pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
SHFree (pidl);
hr = S_OK;
} else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
} else {
hr = E_NOINTERFACE;
}
if (!pObj)
hr = E_OUTOFMEMORY;
*ppvOut = pObj;
}
TRACE ("(%p)->hr=0x%08lx\n", This, hr);
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnGetDisplayNameOf
*
* NOTES
* The desktopfolder creates only complete paths (SHGDN_FORPARSING).
* SHGDN_INFOLDER makes no sense.
*/
static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
{
ICOM_THIS (IGenericSFImpl, iface);
char szPath[MAX_PATH],
szDrive[18];
int len = 0;
BOOL bSimplePidl;
TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
pdump (pidl);
if (!strRet)
return E_INVALIDARG;
szPath[0] = 0x00;
szDrive[0] = 0x00;
bSimplePidl = _ILIsPidlSimple (pidl);
if (_ILIsSpecialFolder (pidl)) {
/* take names of special folders only if its only this folder */
if (bSimplePidl) {
_ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */
} else {
FIXME ("special folder\n");
}
} else {
if (!_ILIsDrive (pidl)) {
ERR ("Wrong pidl type\n");
return E_INVALIDARG;
}
_ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */
/* long view "lw_name (C:)" */
if (bSimplePidl && !(dwFlags & SHGDN_FORPARSING)) {
DWORD dwVolumeSerialNumber,
dwMaximumComponetLength,
dwFileSystemFlags;
GetVolumeInformationA (szPath, szDrive, sizeof (szDrive) - 6, &dwVolumeSerialNumber,
&dwMaximumComponetLength, &dwFileSystemFlags, NULL, 0);
strcat (szDrive, " (");
strncat (szDrive, szPath, 2);
strcat (szDrive, ")");
strcpy (szPath, szDrive);
}
}
if (!bSimplePidl) { /* go deeper if needed */
PathAddBackslashA (szPath);
len = strlen (szPath);
if (!SUCCEEDED
(SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len)))
return E_OUTOFMEMORY;
}
strRet->uType = STRRET_CSTR;
lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
TRACE ("-- (%p)->(%s)\n", This, szPath);
return S_OK;
}
/**************************************************************************
* ISF_MyComputer_fnSetNameOf
* Changes the name of a file object or subfolder, possibly changing its item
* identifier in the process.
*
* PARAMETERS
* HWND hwndOwner, //[in ] Owner window for output
* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
* LPCOLESTR lpszName, //[in ] the items new display name
* DWORD dwFlags, //[in ] SHGNO formatting flags
* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
*/
static HRESULT WINAPI ISF_MyComputer_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)->(%u,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
return E_FAIL;
}
static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_MyComputer_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)\n", This);
if (pSort) *pSort = 0;
if (pDisplay) *pDisplay = 0;
return S_OK;
}
static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
{
ICOM_THIS (IGenericSFImpl, iface);
TRACE ("(%p)\n", This);
if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) return E_INVALIDARG;
*pcsFlags = MyComputerSFHeader[iColumn].pcsFlags;
return S_OK;
}
static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
/* FIXME: drive size >4GB is rolling over */
static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
{
ICOM_THIS (IGenericSFImpl, iface);
HRESULT hr;
TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
return E_INVALIDARG;
if (!pidl) {
psd->fmt = MyComputerSFHeader[iColumn].fmt;
psd->cxChar = MyComputerSFHeader[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA (shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
return S_OK;
} else {
char szPath[MAX_PATH];
ULARGE_INTEGER ulBytes;
psd->str.u.cStr[0] = 0x00;
psd->str.uType = STRRET_CSTR;
switch (iColumn) {
case 0: /* name */
hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
break;
case 1: /* type */
_ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 2: /* total size */
if (_ILIsDrive (pidl)) {
_ILSimpleGetText (pidl, szPath, MAX_PATH);
GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL);
StrFormatByteSizeA (ulBytes.s.LowPart, psd->str.u.cStr, MAX_PATH);
}
break;
case 3: /* free size */
if (_ILIsDrive (pidl)) {
_ILSimpleGetText (pidl, szPath, MAX_PATH);
GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL);
StrFormatByteSizeA (ulBytes.s.LowPart, psd->str.u.cStr, MAX_PATH);
}
break;
}
hr = S_OK;
}
return hr;
}
static HRESULT WINAPI ISF_MyComputer_fnMapNameToSCID (IShellFolder2 * iface, LPCWSTR pwszName, SHCOLUMNID * pscid)
{
ICOM_THIS (IGenericSFImpl, iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static ICOM_VTABLE (IShellFolder2) vt_ShellFolder2 =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
ISF_MyComputer_fnQueryInterface,
ISF_MyComputer_fnAddRef,
ISF_MyComputer_fnRelease,
ISF_MyComputer_fnParseDisplayName,
ISF_MyComputer_fnEnumObjects,
ISF_MyComputer_fnBindToObject,
ISF_MyComputer_fnBindToStorage,
ISF_MyComputer_fnCompareIDs,
ISF_MyComputer_fnCreateViewObject,
ISF_MyComputer_fnGetAttributesOf,
ISF_MyComputer_fnGetUIObjectOf,
ISF_MyComputer_fnGetDisplayNameOf,
ISF_MyComputer_fnSetNameOf,
/* ShellFolder2 */
ISF_MyComputer_fnGetDefaultSearchGUID,
ISF_MyComputer_fnEnumSearches,
ISF_MyComputer_fnGetDefaultColumn,
ISF_MyComputer_fnGetDefaultColumnState,
ISF_MyComputer_fnGetDetailsEx,
ISF_MyComputer_fnGetDetailsOf,
ISF_MyComputer_fnMapNameToSCID
};
/************************************************************************
* IMCFldr_PersistFolder2_QueryInterface
*/
static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
TRACE ("(%p)\n", This);
return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj);
}
/************************************************************************
* IMCFldr_PersistFolder2_AddRef
*/
static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
TRACE ("(%p)->(count=%lu)\n", This, This->ref);
return IUnknown_AddRef (_IUnknown_ (This));
}
/************************************************************************
* ISFPersistFolder_Release
*/
static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
TRACE ("(%p)->(count=%lu)\n", This, This->ref);
return IUnknown_Release (_IUnknown_ (This));
}
/************************************************************************
* IMCFldr_PersistFolder2_GetClassID
*/
static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID (IPersistFolder2 * iface, CLSID * lpClassId)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
TRACE ("(%p)\n", This);
if (!lpClassId)
return E_POINTER;
*lpClassId = CLSID_MyComputer;
return S_OK;
}
/************************************************************************
* IMCFldr_PersistFolder2_Initialize
*
* NOTES: it makes no sense to change the pidl
*/
static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize (IPersistFolder2 * iface, LPCITEMIDLIST pidl)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
TRACE ("(%p)->(%p)\n", This, pidl);
return E_NOTIMPL;
}
/**************************************************************************
* IPersistFolder2_fnGetCurFolder
*/
static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder (IPersistFolder2 * iface, LPITEMIDLIST * pidl)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
TRACE ("(%p)->(%p)\n", This, pidl);
if (!pidl)
return E_POINTER;
*pidl = ILClone (This->pidlRoot);
return S_OK;
}
static ICOM_VTABLE (IPersistFolder2) vt_PersistFolder2 =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IMCFldr_PersistFolder2_QueryInterface,
IMCFldr_PersistFolder2_AddRef,
IMCFldr_PersistFolder2_Release,
IMCFldr_PersistFolder2_GetClassID,
IMCFldr_PersistFolder2_Initialize,
IMCFldr_PersistFolder2_GetCurFolder
};

File diff suppressed because it is too large Load Diff

View File

@ -169,7 +169,6 @@ IShellView * IShellView_Constructor( IShellFolder * pFolder)
IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
TRACE("(%p)->(%p)\n",sv, pFolder);
shell32_ObjCount++;
return (IShellView *) sv;
}
@ -1502,7 +1501,6 @@ static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
TRACE("(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount++;
return ++(This->ref);
}
/**********************************************************
@ -1514,8 +1512,6 @@ static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
TRACE("(%p)->()\n",This);
shell32_ObjCount--;
if (!--(This->ref))
{
TRACE(" destroying IShellView(%p)\n",This);
@ -1529,9 +1525,6 @@ static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
if (This->apidl)
SHFree(This->apidl);
if (This->pCommDlgBrowser)
ICommDlgBrowser_Release(This->pCommDlgBrowser);
HeapFree(GetProcessHeap(),0,This);
return 0;
}
@ -1733,7 +1726,9 @@ static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
}
DestroyWindow(This->hWnd);
IShellBrowser_Release(This->pShellBrowser);
if(This->pShellBrowser) IShellBrowser_Release(This->pShellBrowser);
if(This->pCommDlgBrowser) ICommDlgBrowser_Release(This->pCommDlgBrowser);
return S_OK;
}
@ -2272,4 +2267,3 @@ static struct ICOM_VTABLE(IViewObject) vovt =
ISVViewObject_SetAdvise,
ISVViewObject_GetAdvise
};

View File

@ -61,7 +61,6 @@ IContextMenu *ISvBgCm_Constructor(IShellFolder* pSFParent)
if(pSFParent) IShellFolder_AddRef(pSFParent);
TRACE("(%p)->()\n",cm);
shell32_ObjCount++;
return (IContextMenu*)cm;
}
@ -108,7 +107,6 @@ static ULONG WINAPI ISVBgCm_fnAddRef(IContextMenu *iface)
TRACE("(%p)->(count=%lu)\n",This, This->ref);
shell32_ObjCount++;
return ++(This->ref);
}
@ -132,8 +130,6 @@ static ULONG WINAPI ISVBgCm_fnRelease(IContextMenu *iface)
return 0;
}
shell32_ObjCount--;
return This->ref;
}
@ -428,4 +424,3 @@ static struct ICOM_VTABLE(IContextMenu) cmvt =
ISVBgCm_fnHandleMenuMsg,
(void *) 0xdeadbabe /* just paranoia (IContextMenu3) */
};

View File

@ -98,7 +98,6 @@ IContextMenu *ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl,
TRACE("(%p)->()\n",cm);
shell32_ObjCount++;
return (IContextMenu*)cm;
}
@ -145,7 +144,6 @@ static ULONG WINAPI ISvItemCm_fnAddRef(IContextMenu *iface)
TRACE("(%p)->(count=%lu)\n",This, This->ref);
shell32_ObjCount++;
return ++(This->ref);
}
@ -158,8 +156,6 @@ static ULONG WINAPI ISvItemCm_fnRelease(IContextMenu *iface)
TRACE("(%p)->()\n",This);
shell32_ObjCount--;
if (!--(This->ref))
{
TRACE(" destroying IContextMenu(%p)\n",This);