diff --git a/reactos/include/wine/shlguid.h b/reactos/include/wine/shlguid.h index df44eb018dc..2206ca234bd 100644 --- a/reactos/include/wine/shlguid.h +++ b/reactos/include/wine/shlguid.h @@ -44,6 +44,7 @@ DEFINE_GUID(CLSID_ShellFSFolder, 0xF3364BA0, 0x65B9, 0x11CE, 0xA9, 0xBA, 0x00, 0 DEFINE_GUID(CLSID_RecycleBin, 0x645FF040, 0x5081, 0x101B, 0x9F, 0x08, 0x00, 0xAA, 0x00, 0x2F, 0x95, 0x4E); DEFINE_GUID(CLSID_ControlPanel, 0x21EC2020, 0x3AEA, 0x1069, 0xA2, 0xDD, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D); DEFINE_GUID(CLSID_Printers, 0x2227A280, 0x3AEA, 0x1069, 0xA2, 0xDE, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D); +DEFINE_GUID(CLSID_MyDocuments, 0x450d8fba, 0xad25, 0x11d0, 0x98, 0xa8, 0x08, 0x00, 0x36, 0x1b, 0x11, 0x03); DEFINE_GUID(IID_IQueryAssociations, 0xc46ca590, 0x3c3f, 0x11d2, 0xbe, 0xe6, 0x00, 0x00, 0xf8, 0x05, 0xca, 0x57); diff --git a/reactos/lib/shell32/Makefile.in b/reactos/lib/shell32/Makefile.in index 9d74b969c1d..b28dfc420cb 100644 --- a/reactos/lib/shell32/Makefile.in +++ b/reactos/lib/shell32/Makefile.in @@ -62,6 +62,7 @@ RC_BINARIES = \ mycomputer.ico \ netdrive.ico \ netdrive2.ico \ + printer.ico \ ramdisk.ico C_SRCS16 = shell.c diff --git a/reactos/lib/shell32/autocomplete.c b/reactos/lib/shell32/autocomplete.c index f4f9b42548e..9d75ccf08d6 100644 --- a/reactos/lib/shell32/autocomplete.c +++ b/reactos/lib/shell32/autocomplete.c @@ -83,7 +83,7 @@ static struct IAutoComplete2Vtbl ac2vt; #define _ICOM_THIS_From_IAutoComplete2(class, name) class* This = (class*)(((char*)name)-_IAutoComplete2_Offset); /* - converts This to a interface pointer + converts This to an interface pointer */ #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) #define _IAutoComplete2_(This) (IAutoComplete2*)&(This->lpvtblAutoComplete2) @@ -101,8 +101,7 @@ HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVO if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) return CLASS_E_NOAGGREGATION; - lpac = (IAutoCompleteImpl*)HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, sizeof(IAutoCompleteImpl)); + lpac = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAutoCompleteImpl)); if (!lpac) return E_OUTOFMEMORY; @@ -280,7 +279,7 @@ static HRESULT WINAPI IAutoComplete_fnInit( LONG len; /* pwszRegKeyPath contains the key as well as the value, so we split */ - key = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwzsRegKeyPath)+1)*sizeof(WCHAR)); + key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwzsRegKeyPath)+1)*sizeof(WCHAR)); strcpyW(key, pwzsRegKeyPath); value = strrchrW(key, '\\'); *value = 0; @@ -294,7 +293,7 @@ static HRESULT WINAPI IAutoComplete_fnInit( if (res == ERROR_SUCCESS) { res = RegQueryValueW(hKey, value, result, &len); if (res == ERROR_SUCCESS) { - This->quickComplete = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR)); + This->quickComplete = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR)); strcpyW(This->quickComplete, result); } RegCloseKey(hKey); @@ -303,7 +302,7 @@ static HRESULT WINAPI IAutoComplete_fnInit( } if ((pwszQuickComplete) && (!This->quickComplete)) { - This->quickComplete = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwszQuickComplete)+1)*sizeof(WCHAR)); + This->quickComplete = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwszQuickComplete)+1)*sizeof(WCHAR)); lstrcpyW(This->quickComplete, pwszQuickComplete); } @@ -482,7 +481,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, /* If quickComplete is set and control is pressed, replace the string */ control = GetKeyState(VK_CONTROL) & 0x8000; if (control && This->quickComplete) { - hwndQCText = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + hwndQCText = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(This->quickComplete)+lstrlenW(hwndText))*sizeof(WCHAR)); sel = sprintfW(hwndQCText, This->quickComplete, hwndText); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)hwndQCText); @@ -525,7 +524,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, int len; len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL); - msg = (WCHAR*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); + msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg); SendMessageW(hwnd, EM_SETSEL, lstrlenW(msg), lstrlenW(msg)); @@ -562,7 +561,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, SendMessageW(This->hwndListBox, LB_RESETCONTENT, 0, 0); HeapFree(GetProcessHeap(), 0, This->txtbackup); - This->txtbackup = (WCHAR*) HeapAlloc(GetProcessHeap(), + This->txtbackup = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(hwndText)+1)*sizeof(WCHAR)); lstrcpyW(This->txtbackup, hwndText); @@ -631,7 +630,7 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, break; case WM_LBUTTONDOWN: len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL); - msg = (WCHAR*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); + msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); sel = (INT)SendMessageW(hwnd, LB_GETCURSEL, 0, 0); SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg); SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg); diff --git a/reactos/lib/shell32/classes.c b/reactos/lib/shell32/classes.c index f5e8c382951..96635f9765b 100644 --- a/reactos/lib/shell32/classes.c +++ b/reactos/lib/shell32/classes.c @@ -223,7 +223,12 @@ BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr ret = HCR_RegGetDefaultIconW(hkey, szDest, len, dwNr); RegCloseKey(hkey); } - TRACE("-- %s %li\n", debugstr_w(szDest), *dwNr ); + + if(ret) + TRACE("-- %s %li\n", debugstr_w(szDest), *dwNr ); + else + TRACE("-- not found\n"); + return ret; } diff --git a/reactos/lib/shell32/cpanelfolder.c b/reactos/lib/shell32/cpanelfolder.c index 6a918017ef2..0b41c079eed 100644 --- a/reactos/lib/shell32/cpanelfolder.c +++ b/reactos/lib/shell32/cpanelfolder.c @@ -87,7 +87,7 @@ static IShellExecuteHookAVtbl vt_ShellExecuteHookA; /* - converts This to a interface pointer + converts This to an interface pointer */ #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) @@ -124,7 +124,7 @@ HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOI if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) return CLASS_E_NOAGGREGATION; - sf = (ICPanelImpl *) LocalAlloc(GMEM_ZEROINIT, sizeof(ICPanelImpl)); + sf = (ICPanelImpl *) LocalAlloc(LMEM_ZEROINIT, sizeof(ICPanelImpl)); if (!sf) return E_OUTOFMEMORY; @@ -904,20 +904,8 @@ static IPersistFolder2Vtbl vt_PersistFolder2 = ICPanel_PersistFolder2_GetCurFolder }; -HRESULT WINAPI CPanel_GetIconLocationA(LPITEMIDLIST pidl, LPSTR szIconFile, UINT cchMax, int* piIndex) -{ - PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl); - - if (!pcpanel) - return E_INVALIDARG; - - lstrcpyA(szIconFile, pcpanel->szName); - *piIndex = pcpanel->iconIdx!=-1? pcpanel->iconIdx: 0; - - return S_OK; -} - -HRESULT WINAPI CPanel_GetIconLocationW(LPITEMIDLIST pidl, LPWSTR szIconFile, UINT cchMax, int* piIndex) +HRESULT CPanel_GetIconLocationW(LPITEMIDLIST pidl, + LPWSTR szIconFile, UINT cchMax, int* piIndex) { PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl); @@ -935,7 +923,8 @@ HRESULT WINAPI CPanel_GetIconLocationW(LPITEMIDLIST pidl, LPWSTR szIconFile, UIN * IShellExecuteHookW Implementation */ -static HRESULT WINAPI IShellExecuteHookW_fnQueryInterface(IShellExecuteHookW* iface, REFIID riid, void** ppvObject) +static HRESULT WINAPI IShellExecuteHookW_fnQueryInterface( + IShellExecuteHookW* iface, REFIID riid, void** ppvObject) { _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl, iface); @@ -1087,10 +1076,8 @@ static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA* iface, LP static IShellExecuteHookAVtbl vt_ShellExecuteHookA = { - IShellExecuteHookA_fnQueryInterface, IShellExecuteHookA_fnAddRef, IShellExecuteHookA_fnRelease, - IShellExecuteHookA_fnExecute }; diff --git a/reactos/lib/shell32/dataobject.c b/reactos/lib/shell32/dataobject.c index b311e30424f..d4d5b217917 100644 --- a/reactos/lib/shell32/dataobject.c +++ b/reactos/lib/shell32/dataobject.c @@ -50,51 +50,8 @@ typedef struct LPFORMATETC pFmt; } IEnumFORMATETCImpl; -static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface(LPENUMFORMATETC iface, REFIID riid, LPVOID* ppvObj); -static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPENUMFORMATETC iface); -static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface); -static HRESULT WINAPI IEnumFORMATETC_fnNext(LPENUMFORMATETC iface, ULONG celt, FORMATETC* rgelt, ULONG* pceltFethed); -static HRESULT WINAPI IEnumFORMATETC_fnSkip(LPENUMFORMATETC iface, ULONG celt); -static HRESULT WINAPI IEnumFORMATETC_fnReset(LPENUMFORMATETC iface); -static HRESULT WINAPI IEnumFORMATETC_fnClone(LPENUMFORMATETC iface, LPENUMFORMATETC* ppenum); - -static struct IEnumFORMATETCVtbl efvt = -{ - IEnumFORMATETC_fnQueryInterface, - IEnumFORMATETC_fnAddRef, - IEnumFORMATETC_fnRelease, - IEnumFORMATETC_fnNext, - IEnumFORMATETC_fnSkip, - IEnumFORMATETC_fnReset, - IEnumFORMATETC_fnClone -}; - -LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[]) -{ - IEnumFORMATETCImpl* ef; - DWORD size=cfmt * sizeof(FORMATETC); - - ef=(IEnumFORMATETCImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumFORMATETCImpl)); - - if(ef) - { - ef->ref=1; - ef->lpVtbl=&efvt; - - ef->countFmt = cfmt; - ef->pFmt = SHAlloc (size); - - if (ef->pFmt) - { - memcpy(ef->pFmt, afmt, size); - } - } - - TRACE("(%p)->(%u,%p)\n",ef, cfmt, afmt); - return (LPENUMFORMATETC)ef; -} - -static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface(LPENUMFORMATETC iface, REFIID riid, LPVOID* ppvObj) +static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface( + LPENUMFORMATETC iface, REFIID riid, LPVOID* ppvObj) { IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); @@ -118,7 +75,6 @@ static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface(LPENUMFORMATETC iface, REF } TRACE("-- Interface: E_NOINTERFACE\n"); return E_NOINTERFACE; - } static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPENUMFORMATETC iface) @@ -203,6 +159,40 @@ static HRESULT WINAPI IEnumFORMATETC_fnClone(LPENUMFORMATETC iface, LPENUMFORMAT return S_OK; } +static struct IEnumFORMATETCVtbl efvt = +{ + IEnumFORMATETC_fnQueryInterface, + IEnumFORMATETC_fnAddRef, + IEnumFORMATETC_fnRelease, + IEnumFORMATETC_fnNext, + IEnumFORMATETC_fnSkip, + IEnumFORMATETC_fnReset, + IEnumFORMATETC_fnClone +}; + +LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[]) +{ + IEnumFORMATETCImpl* ef; + DWORD size=cfmt * sizeof(FORMATETC); + + ef = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumFORMATETCImpl)); + + if(ef) + { + ef->ref=1; + ef->lpVtbl=&efvt; + + ef->countFmt = cfmt; + ef->pFmt = SHAlloc (size); + + if (ef->pFmt) + memcpy(ef->pFmt, afmt, size); + } + + TRACE("(%p)->(%u,%p)\n",ef, cfmt, afmt); + return (LPENUMFORMATETC)ef; +} + /*********************************************************************** * IDataObject implementation @@ -229,38 +219,6 @@ typedef struct } IDataObjectImpl; -static struct IDataObjectVtbl dtovt; - -/************************************************************************** -* IDataObject_Constructor -*/ -LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl, LPCITEMIDLIST * apidl, UINT cidl) -{ - IDataObjectImpl* dto; - - dto = (IDataObjectImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDataObjectImpl)); - - if (dto) - { - dto->ref = 1; - dto->lpVtbl = &dtovt; - dto->pidl = ILClone(pMyPidl); - dto->apidl = _ILCopyaPidl(apidl, cidl); - dto->cidl = cidl; - - dto->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); - dto->cfFileNameA = RegisterClipboardFormatA(CFSTR_FILENAMEA); - dto->cfFileNameW = RegisterClipboardFormatA(CFSTR_FILENAMEW); - InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL); - InitFormatEtc(dto->pFormatEtc[1], CF_HDROP, TYMED_HGLOBAL); - InitFormatEtc(dto->pFormatEtc[2], dto->cfFileNameA, TYMED_HGLOBAL); - InitFormatEtc(dto->pFormatEtc[3], dto->cfFileNameW, TYMED_HGLOBAL); - } - - TRACE("(%p)->(apidl=%p cidl=%u)\n",dto, apidl, cidl); - return (LPDATAOBJECT)dto; -} - /*************************************************************************** * IDataObject_QueryInterface */ @@ -465,3 +423,34 @@ static struct IDataObjectVtbl dtovt = IDataObject_fnDUnadvise, IDataObject_fnEnumDAdvise }; + +/************************************************************************** +* IDataObject_Constructor +*/ +LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, + LPCITEMIDLIST pMyPidl, LPCITEMIDLIST * apidl, UINT cidl) +{ + IDataObjectImpl* dto; + + dto = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDataObjectImpl)); + + if (dto) + { + dto->ref = 1; + dto->lpVtbl = &dtovt; + dto->pidl = ILClone(pMyPidl); + dto->apidl = _ILCopyaPidl(apidl, cidl); + dto->cidl = cidl; + + dto->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + dto->cfFileNameA = RegisterClipboardFormatA(CFSTR_FILENAMEA); + dto->cfFileNameW = RegisterClipboardFormatA(CFSTR_FILENAMEW); + InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL); + InitFormatEtc(dto->pFormatEtc[1], CF_HDROP, TYMED_HGLOBAL); + InitFormatEtc(dto->pFormatEtc[2], dto->cfFileNameA, TYMED_HGLOBAL); + InitFormatEtc(dto->pFormatEtc[3], dto->cfFileNameW, TYMED_HGLOBAL); + } + + TRACE("(%p)->(apidl=%p cidl=%u)\n",dto, apidl, cidl); + return (LPDATAOBJECT)dto; +} diff --git a/reactos/lib/shell32/debughlp.c b/reactos/lib/shell32/debughlp.c index 181410390f5..2282f6c9418 100644 --- a/reactos/lib/shell32/debughlp.c +++ b/reactos/lib/shell32/debughlp.c @@ -136,6 +136,7 @@ IID* _dbg_ILGetGUIDPointer(LPCITEMIDLIST pidl) { case PT_SHELLEXT: case PT_GUID: + case PT_YAGUID: return &(pdata->u.guid.guid); } } @@ -158,13 +159,13 @@ DWORD _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize) if (_dbg_ILIsDesktop(pidl)) { /* desktop */ - if (szOut) strncpy(szOut, "Desktop", uOutSize); + if (szOut) lstrcpynA(szOut, "Desktop", uOutSize); dwReturn = strlen ("Desktop"); } else if (( szSrc = _dbg_ILGetTextPointer(pidl) )) { /* filesystem */ - if (szOut) strncpy(szOut, szSrc, uOutSize); + if (szOut) lstrcpynA(szOut, szSrc, uOutSize); dwReturn = strlen(szSrc); } else if (( riid = _dbg_ILGetGUIDPointer(pidl) )) @@ -215,7 +216,7 @@ void pdump (LPCITEMIDLIST pidl) pidltemp = _dbg_ILGetNext(pidltemp); - } while (pidltemp->mkid.cb); + } while (pidltemp && pidltemp->mkid.cb); } else { @@ -224,60 +225,69 @@ void pdump (LPCITEMIDLIST pidl) pcheck(pidl); } } -#define BYTES_PRINTED 32 -BOOL pcheck (LPCITEMIDLIST pidl) + +static void dump_pidl_hex( LPCITEMIDLIST pidl ) { - DWORD type, ret=TRUE; - LPCITEMIDLIST pidltemp = pidl; + const unsigned char *p = (const unsigned char *)pidl; + const int max_bytes = 0x80, max_line = 0x10; + char szHex[max_line*3+1], szAscii[max_line+1]; + int i, n; - if (pidltemp && pidltemp->mkid.cb) - { do - { type = _dbg_ILGetDataPointer(pidltemp)->type; - switch (type) - { case PT_CPLAPPLET: - case PT_GUID: - case PT_SHELLEXT: - case PT_DRIVE: - case PT_DRIVE1: - case PT_DRIVE2: - case PT_DRIVE3: - case PT_FOLDER: - case PT_VALUE: - case PT_FOLDER1: - case PT_WORKGRP: - case PT_COMP: - case PT_NETPROVIDER: - case PT_NETWORK: - case PT_IESPECIAL1: - case PT_YAGUID: - case PT_IESPECIAL2: - case PT_SHARE: - break; - default: - { - char szTemp[BYTES_PRINTED*4 + 1]; - int i; - unsigned char c; + n = pidl->mkid.cb; + if( n>max_bytes ) + n = max_bytes; + for( i=0; imkid.cb) && (i>4)>9)? (c>>4)+55 : (c>>4)+48; - szTemp[i*3+1] = ((0x0F&c)>9)? (0x0F&c)+55 : (0x0F&c)+48; - szTemp[i*3+2] = ' '; - szTemp[i+BYTES_PRINTED*3] = (c>=0x20 && c <=0x80) ? c : '.'; - } - szTemp[BYTES_PRINTED*4] = 0x00; - ERR("unknown IDLIST %p [%p] size=%u type=%lx\n%s\n",pidl, pidltemp, pidltemp->mkid.cb,type, szTemp); - ret = FALSE; - } - } - pidltemp = _dbg_ILGetNext(pidltemp); - } while (pidltemp->mkid.cb); - } - return ret; +BOOL pcheck( LPCITEMIDLIST pidl ) +{ + DWORD type; + LPCITEMIDLIST pidltemp = pidl; + + while( pidltemp && pidltemp->mkid.cb ) + { + type = _dbg_ILGetDataPointer(pidltemp)->type; + switch( type ) + { + case PT_CPLAPPLET: + case PT_GUID: + case PT_SHELLEXT: + case PT_DRIVE: + case PT_DRIVE1: + case PT_DRIVE2: + case PT_DRIVE3: + case PT_FOLDER: + case PT_VALUE: + case PT_VALUEW: + case PT_FOLDER1: + case PT_WORKGRP: + case PT_COMP: + case PT_NETPROVIDER: + case PT_NETWORK: + case PT_IESPECIAL1: + case PT_YAGUID: + case PT_IESPECIAL2: + case PT_SHARE: + break; + default: + ERR("unknown IDLIST %p [%p] size=%u type=%lx\n", + pidl, pidltemp, pidltemp->mkid.cb,type ); + dump_pidl_hex( pidltemp ); + return FALSE; + } + pidltemp = _dbg_ILGetNext(pidltemp); + } + return TRUE; } static char shdebugstr_buf1[100]; @@ -308,6 +318,8 @@ static struct { {&IID_IDataObject, "IID_IDataObject"}, {&IID_IAutoComplete, "IID_IAutoComplete"}, {&IID_IAutoComplete2, "IID_IAutoComplete2"}, + {&IID_IShellLinkA, "IID_IShellLinkA"}, + {&IID_IShellLinkW, "IID_IShellLinkW"}, {NULL,NULL}}; const char * shdebugstr_guid( const struct _GUID *id ) diff --git a/reactos/lib/shell32/dragdrophelper.c b/reactos/lib/shell32/dragdrophelper.c index 53a879f186b..f46823049b9 100644 --- a/reactos/lib/shell32/dragdrophelper.c +++ b/reactos/lib/shell32/dragdrophelper.c @@ -71,7 +71,7 @@ HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, if (pUnkOuter) return CLASS_E_NOAGGREGATION; - dth = (IDropTargetHelperImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IDropTargetHelperImpl)); + dth = (IDropTargetHelperImpl *) LocalAlloc (LMEM_ZEROINIT, sizeof (IDropTargetHelperImpl)); if (!dth) return E_OUTOFMEMORY; dth->ref = 0; diff --git a/reactos/lib/shell32/enumidlist.c b/reactos/lib/shell32/enumidlist.c index 072e3288f3d..7e1cb064a3e 100644 --- a/reactos/lib/shell32/enumidlist.c +++ b/reactos/lib/shell32/enumidlist.c @@ -193,7 +193,7 @@ static BOOL DeleteList( IEnumIDList * IEnumIDList_Constructor(void) { - IEnumIDListImpl *lpeidl = (IEnumIDListImpl*)HeapAlloc(GetProcessHeap(), + IEnumIDListImpl *lpeidl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumIDListImpl)); if (lpeidl) diff --git a/reactos/lib/shell32/folders.c b/reactos/lib/shell32/folders.c index efa3b2bdcb7..6a53efb86fb 100644 --- a/reactos/lib/shell32/folders.c +++ b/reactos/lib/shell32/folders.c @@ -40,6 +40,7 @@ #include "pidl.h" #include "shell32_main.h" #include "shfldr.h" +#include "shresdef.h" WINE_DEFAULT_DEBUG_CHANNEL(shell); @@ -74,7 +75,7 @@ IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl) TRACE("%p\n", pidl); - ei = (IExtractIconWImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconWImpl)); + ei = HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconWImpl)); ei->ref=1; ei->lpVtbl = &eivt; ei->lpvtblPersistFile = &pfvt; @@ -196,9 +197,9 @@ static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags, if (!HCR_GetDefaultIconW(folder, szIconFile, cchMax, &dwNr)) { lstrcpynW(szIconFile, swShell32Name, cchMax); - dwNr = 3; + dwNr = IDI_SHELL_FOLDER; } - *piIndex = (uFlags & GIL_OPENICON) ? dwNr + 1 : dwNr; + *piIndex = -((uFlags & GIL_OPENICON) ? dwNr + 1 : dwNr); } return S_OK; } @@ -233,7 +234,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( if (_ILIsDesktop(pSimplePidl)) { lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = 34; + *piIndex = -IDI_SHELL_DESKTOP; } /* my computer and other shell extensions */ @@ -257,7 +258,14 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( else { lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = 15; + if(IsEqualGUID(riid, &CLSID_MyComputer)) + *piIndex = -IDI_SHELL_MY_COMPUTER; + else if(IsEqualGUID(riid, &CLSID_MyDocuments)) + *piIndex = -IDI_SHELL_FOLDER; + else if(IsEqualGUID(riid, &CLSID_NetworkPlaces)) + *piIndex = -IDI_SHELL_MY_NETWORK_PLACES; + else + *piIndex = -IDI_SHELL_FOLDER; } } @@ -271,17 +279,17 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( { switch(GetDriveTypeA(sTemp)) { - case DRIVE_REMOVABLE: icon_idx = 5; break; - case DRIVE_CDROM: icon_idx = 11; break; - case DRIVE_REMOTE: icon_idx = 9; break; - case DRIVE_RAMDISK: icon_idx = 12; break; + case DRIVE_REMOVABLE: icon_idx = IDI_SHELL_FLOPPY; break; + case DRIVE_CDROM: icon_idx = IDI_SHELL_CDROM; break; + case DRIVE_REMOTE: icon_idx = IDI_SHELL_NETDRIVE; break; + case DRIVE_RAMDISK: icon_idx = IDI_SHELL_RAMDISK; break; } } if (icon_idx != -1) { lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = icon_idx; + *piIndex = -icon_idx; } else { @@ -292,14 +300,14 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( else { lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = 8; + *piIndex = -IDI_SHELL_DRIVE; } } } else if (_ILIsFolder (pSimplePidl)) { - getIconLocationForFolder(iface, uFlags, szIconFile, cchMax, piIndex, - pwFlags); + getIconLocationForFolder(iface, uFlags, szIconFile, cchMax, piIndex, + pwFlags); } else { @@ -370,14 +378,18 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( static HRESULT WINAPI IExtractIconW_fnExtract(IExtractIconW * iface, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) { IExtractIconWImpl *This = (IExtractIconWImpl *)iface; + int index; - FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, debugstr_w(pszFile), nIconIndex, phiconLarge, phiconSmall, nIconSize); + FIXME("(%p) (file=%p index=%d %p %p size=%08x) semi-stub\n", This, debugstr_w(pszFile), (signed)nIconIndex, + phiconLarge, phiconSmall, nIconSize); + + index = SIC_GetIconIndex(pszFile, nIconIndex); if (phiconLarge) - *phiconLarge = ImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT); + *phiconLarge = ImageList_GetIcon(ShellBigIconList, index, ILD_TRANSPARENT); if (phiconSmall) - *phiconSmall = ImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT); + *phiconSmall = ImageList_GetIcon(ShellSmallIconList, index, ILD_TRANSPARENT); return S_OK; } diff --git a/reactos/lib/shell32/iconcache.c b/reactos/lib/shell32/iconcache.c index 3ca829c2fbf..264cb3e68da 100644 --- a/reactos/lib/shell32/iconcache.c +++ b/reactos/lib/shell32/iconcache.c @@ -257,7 +257,8 @@ BOOL SIC_Initialize(void) hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(1), IMAGE_ICON, cx_small, cy_small, LR_SHARED); hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(1), IMAGE_ICON, cx_large, cy_large, LR_SHARED); } - SIC_IconAppend (swShell32Name, index, hSm, hLg); + SIC_IconAppend (swShell32Name, index - 1, hSm, hLg); + SIC_IconAppend (swShell32Name, -index, hSm, hLg); } TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList); diff --git a/reactos/lib/shell32/memorystream.c b/reactos/lib/shell32/memorystream.c index e6460a6d6c1..f4c17f4c50c 100644 --- a/reactos/lib/shell32/memorystream.c +++ b/reactos/lib/shell32/memorystream.c @@ -1,12 +1,12 @@ /* - * this class implements a pure IStream object - * and can be used for many purposes + * This class implements a pure IStream object + * and can be used for many purposes. * - * the main reason for implementing this was + * The main reason for implementing this was * a cleaner implementation of IShellLink which - * needs to be able to load lnk's from a IStream + * needs to be able to load lnks from an IStream * interface so it was obvious to capsule the file - * access in a IStream to. + * access in an IStream to. * * Copyright 1999 Juergen Schmied * Copyright 2003 Mike McCormack for CodeWeavers @@ -42,58 +42,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); -static const IStreamVtbl stvt; +#define STGM_ACCESS_MODE(stgm) ((stgm)&0x0000f) +#define STGM_SHARE_MODE(stgm) ((stgm)&0x000f0) +#define STGM_CREATE_MODE(stgm) ((stgm)&0x0f000) typedef struct { const IStreamVtbl *lpvtst; - DWORD ref; - HANDLE handle; + DWORD ref; + HANDLE handle; } ISHFileStream; -/************************************************************************** - * CreateStreamOnFile() - * - * similar to CreateStreamOnHGlobal - */ -HRESULT CreateStreamOnFile (LPCWSTR pszFilename, DWORD grfMode, IStream ** ppstm) -{ - ISHFileStream* fstr; - HANDLE handle; - DWORD access = GENERIC_READ, creat; - - if( grfMode & STGM_TRANSACTED ) - return E_INVALIDARG; - - if( grfMode & STGM_WRITE ) - access |= GENERIC_WRITE; - if( grfMode & STGM_READWRITE ) - access = GENERIC_WRITE | GENERIC_READ; - - if( grfMode & STGM_CREATE ) - creat = CREATE_ALWAYS; - else - creat = OPEN_EXISTING; - - TRACE("Opening %s\n", debugstr_w(pszFilename) ); - - handle = CreateFileW( pszFilename, access, FILE_SHARE_READ, NULL, creat, 0, NULL ); - if( handle == INVALID_HANDLE_VALUE ) - return HRESULT_FROM_WIN32(GetLastError()); - - fstr = (ISHFileStream*)HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY,sizeof(ISHFileStream)); - if( !fstr ) - return E_OUTOFMEMORY; - fstr->lpvtst=&stvt; - fstr->ref = 1; - fstr->handle = handle; - - (*ppstm) = (IStream*)fstr; - - return S_OK; -} - /************************************************************************** * IStream_fnQueryInterface */ @@ -105,17 +64,14 @@ static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVO *ppvObj = NULL; - if(IsEqualIID(riid, &IID_IUnknown) || - IsEqualIID(riid, &IID_IStream)) - { - *ppvObj = This; - } + if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IStream)) + *ppvObj = This; if(*ppvObj) { - IStream_AddRef((IStream*)*ppvObj); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; + IStream_AddRef((IStream*)*ppvObj); + TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); + return S_OK; } TRACE("-- Interface: E_NOINTERFACE\n"); return E_NOINTERFACE; @@ -294,5 +250,60 @@ static const IStreamVtbl stvt = IStream_fnUnlockRegion, IStream_fnStat, IStream_fnClone - }; + +/************************************************************************** + * CreateStreamOnFile() + * + * similar to CreateStreamOnHGlobal + */ +HRESULT CreateStreamOnFile (LPCWSTR pszFilename, DWORD grfMode, IStream ** ppstm) +{ + ISHFileStream* fstr; + HANDLE handle; + DWORD access = GENERIC_READ, creat; + + if( grfMode & STGM_TRANSACTED ) + return E_INVALIDARG; + + switch( STGM_ACCESS_MODE( grfMode ) ) + { + case STGM_READ: + access = GENERIC_READ; + break; + case STGM_WRITE: + case STGM_READWRITE: + access = GENERIC_WRITE | GENERIC_READ; + break; + default: + return STG_E_INVALIDFLAG; + } + + switch( STGM_CREATE_MODE( grfMode ) ) + { + case STGM_CREATE: + creat = CREATE_ALWAYS; + break; + case STGM_FAILIFTHERE: + creat = OPEN_EXISTING; + break; + default: + return STG_E_INVALIDFLAG; + } + + handle = CreateFileW( pszFilename, access, + FILE_SHARE_READ, NULL, creat, 0, NULL ); + if( handle == INVALID_HANDLE_VALUE ) + return HRESULT_FROM_WIN32(GetLastError()); + + fstr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ISHFileStream)); + if( !fstr ) + return E_OUTOFMEMORY; + fstr->lpvtst = &stvt; + fstr->ref = 1; + fstr->handle = handle; + + (*ppstm) = (IStream*)fstr; + + return S_OK; +} diff --git a/reactos/lib/shell32/pidl.c b/reactos/lib/shell32/pidl.c index 1c1cf1b9158..265c3641f3d 100644 --- a/reactos/lib/shell32/pidl.c +++ b/reactos/lib/shell32/pidl.c @@ -1226,7 +1226,7 @@ HRESULT SHELL_GetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSiz if (SUCCEEDED(hr)) PathAddBackslashA(pszPath); } - /* The only other valid case is a item ID list beginning at "My Computer" */ + /* The only other valid case is an item ID list beginning at "My Computer" */ else if (_ILIsMyComputer(pidl)) pidl = ILGetNext(pidl); @@ -1338,7 +1338,7 @@ HRESULT SHELL_GetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSi if (SUCCEEDED(hr)) PathAddBackslashW(pszPath); } - /* The only other valid case is a item ID list beginning at "My Computer" */ + /* The only other valid case is an item ID list beginning at "My Computer" */ else if (_ILIsMyComputer(pidl)) pidl = ILGetNext(pidl); @@ -1825,7 +1825,7 @@ BOOL _ILIsSpecialFolder (LPCITEMIDLIST pidl) TRACE("(%p)\n",pidl); - return (pidl && ( (lpPData && (PT_GUID== lpPData->type || PT_SHELLEXT== lpPData->type)) || + return (pidl && ( (lpPData && (PT_GUID== lpPData->type || PT_SHELLEXT== lpPData->type || PT_YAGUID == lpPData->type)) || (pidl && pidl->mkid.cb == 0x00) )); } @@ -2081,6 +2081,7 @@ IID* _ILGetGUIDPointer(LPCITEMIDLIST pidl) { case PT_SHELLEXT: case PT_GUID: + case PT_YAGUID: return &(pdata->u.guid.guid); default: diff --git a/reactos/lib/shell32/pidl.h b/reactos/lib/shell32/pidl.h index 1bf1828beba..9f5ef5a1d31 100644 --- a/reactos/lib/shell32/pidl.h +++ b/reactos/lib/shell32/pidl.h @@ -97,6 +97,7 @@ #define PT_FOLDER1 0x30 #define PT_FOLDER 0x31 #define PT_VALUE 0x32 +#define PT_VALUEW 0x34 #define PT_WORKGRP 0x41 #define PT_COMP 0x42 #define PT_NETPROVIDER 0x46 @@ -142,6 +143,11 @@ typedef struct tagFileStruct The second the dos name when needed or just 0x00 */ } FileStruct; +typedef struct tagValueW +{ + WCHAR name[1]; +} ValueWStruct; + typedef struct tagPIDLDATA { PIDLTYPE type; /*00*/ union @@ -159,6 +165,7 @@ typedef struct tagPIDLDATA CHAR szName[1]; /*06*/ /* terminated by 0x00 0x00 */ } htmlhelp; struct tagPIDLCPanelStruct cpanel; + struct tagValueW valueW; }u; } PIDLDATA, *LPPIDLDATA; #include "poppack.h" diff --git a/reactos/lib/shell32/regsvr.c b/reactos/lib/shell32/regsvr.c index accf46e5c87..87a58332007 100644 --- a/reactos/lib/shell32/regsvr.c +++ b/reactos/lib/shell32/regsvr.c @@ -477,6 +477,12 @@ static struct regsvr_coclass const coclass_list[] = { "shell32.dll", "Apartment" }, + { &CLSID_DragDropHelper, + "Shell Drag and Drop Helper", + NULL, + "shell32.dll", + "Apartment" + }, { &CLSID_MyComputer, "My Computer", NULL, diff --git a/reactos/lib/shell32/shell.c b/reactos/lib/shell32/shell.c index b6307a7beea..dfa19376317 100644 --- a/reactos/lib/shell32/shell.c +++ b/reactos/lib/shell32/shell.c @@ -287,11 +287,11 @@ HICON16 WINAPI ExtractIconEx16( int i; if (phiconLarge) - ilarge = (HICON*)HeapAlloc(GetProcessHeap(),0,nIcons*sizeof(HICON)); + ilarge = HeapAlloc(GetProcessHeap(),0,nIcons*sizeof(HICON)); else ilarge = NULL; if (phiconSmall) - ismall = (HICON*)HeapAlloc(GetProcessHeap(),0,nIcons*sizeof(HICON)); + ismall = HeapAlloc(GetProcessHeap(),0,nIcons*sizeof(HICON)); else ismall = NULL; ret = HICON_16(ExtractIconExA(lpszFile,nIconIndex,ilarge,ismall,nIcons)); @@ -368,7 +368,7 @@ SEGPTR WINAPI FindEnvironmentString16(LPSTR str) DWORD WINAPI DoEnvironmentSubst16(LPSTR str,WORD length) { LPSTR lpEnv = MapSL(GetDOSEnvironment16()); - LPSTR lpBuffer = (LPSTR)HeapAlloc( GetProcessHeap(), 0, length); + LPSTR lpBuffer = HeapAlloc( GetProcessHeap(), 0, length); LPSTR lpstr = str; LPSTR lpbstr = lpBuffer; diff --git a/reactos/lib/shell32/shell32_main.c b/reactos/lib/shell32/shell32_main.c index 44d3e0139ea..ed592feee20 100644 --- a/reactos/lib/shell32/shell32_main.c +++ b/reactos/lib/shell32/shell32_main.c @@ -44,6 +44,7 @@ #include "pidl.h" #include "shell32_main.h" #include "version.h" +#include "shresdef.h" #include "wine/debug.h" #include "wine/unicode.h" @@ -501,7 +502,7 @@ DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, lstrcpynW(sTemp, szFullPath, MAX_PATH); if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - psfi->iIcon = 2; + psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER); else { static const WCHAR p1W[] = {'%','1',0}; diff --git a/reactos/lib/shell32/shell32_main.h b/reactos/lib/shell32/shell32_main.h index 97ba2dc003c..805cc5524c5 100644 --- a/reactos/lib/shell32/shell32_main.h +++ b/reactos/lib/shell32/shell32_main.h @@ -93,8 +93,7 @@ HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV); HRESULT WINAPI IControlPanel_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); HRESULT WINAPI UnixFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); -HRESULT WINAPI CPanel_GetIconLocationA(LPITEMIDLIST pidl, LPSTR szIconFile, UINT cchMax, int* piIndex); -HRESULT WINAPI CPanel_GetIconLocationW(LPITEMIDLIST pidl, LPWSTR szIconFile, UINT cchMax, int* piIndex); +extern HRESULT CPanel_GetIconLocationW(LPITEMIDLIST, LPWSTR, UINT, int*); HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize); HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize); diff --git a/reactos/lib/shell32/shellfolder.h b/reactos/lib/shell32/shellfolder.h index e222e15d841..1e9bf24a956 100644 --- a/reactos/lib/shell32/shellfolder.h +++ b/reactos/lib/shell32/shellfolder.h @@ -1,5 +1,5 @@ /* - * defines helperfunctions to manipulate the contents of a IShellFolder + * Defines helper functions to manipulate the contents of an IShellFolder * * Copyright 2000 Juergen Schmied * diff --git a/reactos/lib/shell32/shelllink.c b/reactos/lib/shell32/shelllink.c index 70f26907f40..3b6b89cefa1 100644 --- a/reactos/lib/shell32/shelllink.c +++ b/reactos/lib/shell32/shelllink.c @@ -78,18 +78,6 @@ DEFINE_GUID( SHELL32_AdvtShortcutComponent, /* link file formats */ -/* flag1: lnk elements: simple link has 0x0B */ -#define SCF_PIDL 1 -#define SCF_LOCATION 2 -#define SCF_DESCRIPTION 4 -#define SCF_RELATIVE 8 -#define SCF_WORKDIR 0x10 -#define SCF_ARGS 0x20 -#define SCF_CUSTOMICON 0x40 -#define SCF_UNICODE 0x80 -#define SCF_PRODUCT 0x800 -#define SCF_COMPONENT 0x1000 - #include "pshpack1.h" typedef struct _LINK_HEADER @@ -131,14 +119,6 @@ typedef struct _LOCAL_VOLUME_INFO DWORD dwVolLabelOfs; } LOCAL_VOLUME_INFO; -typedef struct tagLINK_ADVERTISEINFO -{ - DWORD size; - DWORD magic; - CHAR bufA[MAX_PATH]; - WCHAR bufW[MAX_PATH]; -} LINK_ADVERTISEINFO; - typedef struct volume_info_t { DWORD type; @@ -270,7 +250,7 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFile HRESULT r; IStream *stm; - TRACE("(%p, %s)\n",This, debugstr_w(pszFileName)); + TRACE("(%p, %s, %lx)\n",This, debugstr_w(pszFileName), dwMode); r = CreateStreamOnFile(pszFileName, dwMode, &stm); if( SUCCEEDED( r ) ) @@ -280,7 +260,7 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFile IStream_Release( stm ); This->bDirty = FALSE; } - + TRACE("-- returning hr %08lx\n", r); return r; } @@ -638,40 +618,40 @@ static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str ) DWORD size; ULONG count; HRESULT r; - LINK_ADVERTISEINFO buffer; + EXP_DARWIN_LINK buffer; TRACE("%p\n",stm); - r = IStream_Read( stm, &buffer.size, sizeof (DWORD), &count ); + r = IStream_Read( stm, &buffer.dbh.cbSize, sizeof (DWORD), &count ); if( FAILED( r ) ) return r; /* make sure that we read the size of the structure even on error */ size = sizeof buffer - sizeof (DWORD); - if( buffer.size != sizeof buffer ) + if( buffer.dbh.cbSize != sizeof buffer ) { ERR("Ooops. This structure is not as expected...\n"); return E_FAIL; } - r = IStream_Read( stm, &buffer.magic, size, &count ); + r = IStream_Read( stm, &buffer.dbh.dwSignature, size, &count ); if( FAILED( r ) ) return r; if( count != size ) return E_FAIL; - TRACE("magic %08lx string = %s\n", buffer.magic, debugstr_w(buffer.bufW)); + TRACE("magic %08lx string = %s\n", buffer.dbh.dwSignature, debugstr_w(buffer.szwDarwinID)); - if( (buffer.magic&0xffff0000) != 0xa0000000 ) + if( (buffer.dbh.dwSignature&0xffff0000) != 0xa0000000 ) { - ERR("Unknown magic number %08lx in advertised shortcut\n", buffer.magic); + ERR("Unknown magic number %08lx in advertised shortcut\n", buffer.dbh.dwSignature); return E_FAIL; } *str = HeapAlloc( GetProcessHeap(), 0, - (strlenW(buffer.bufW)+1) * sizeof(WCHAR) ); - strcpyW( *str, buffer.bufW ); + (strlenW(buffer.szwDarwinID)+1) * sizeof(WCHAR) ); + strcpyW( *str, buffer.szwDarwinID ); return S_OK; } @@ -680,7 +660,7 @@ static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str ) * IPersistStream_Load (IPersistStream) */ static HRESULT WINAPI IPersistStream_fnLoad( - IPersistStream* iface, + IPersistStream* iface, IStream* stm) { LINK_HEADER hdr; @@ -694,7 +674,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( TRACE("%p %p\n", This, stm); if( !stm ) - return STG_E_INVALIDPOINTER; + return STG_E_INVALIDPOINTER; dwBytesRead = 0; r = IStream_Read(stm, &hdr, sizeof(hdr), &dwBytesRead); @@ -749,7 +729,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( } /* load all the new stuff */ - if( hdr.dwFlags & SCF_PIDL ) + if( hdr.dwFlags & SLDF_HAS_ID_LIST ) { r = ILLoadFromStream( stm, &This->pPidl ); if( FAILED( r ) ) @@ -758,13 +738,13 @@ static HRESULT WINAPI IPersistStream_fnLoad( pdump(This->pPidl); /* load the location information */ - if( hdr.dwFlags & SCF_LOCATION ) + if( hdr.dwFlags & SLDF_HAS_LINK_INFO ) r = Stream_LoadLocation( stm, &This->volume, &This->sPath ); if( FAILED( r ) ) goto end; - unicode = hdr.dwFlags & SCF_UNICODE; - if( hdr.dwFlags & SCF_DESCRIPTION ) + unicode = hdr.dwFlags & SLDF_UNICODE; + if( hdr.dwFlags & SLDF_HAS_NAME ) { r = Stream_LoadString( stm, unicode, &This->sDescription ); TRACE("Description -> %s\n",debugstr_w(This->sDescription)); @@ -772,7 +752,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( if( FAILED( r ) ) goto end; - if( hdr.dwFlags & SCF_RELATIVE ) + if( hdr.dwFlags & SLDF_HAS_RELPATH ) { r = Stream_LoadString( stm, unicode, &This->sPathRel ); TRACE("Relative Path-> %s\n",debugstr_w(This->sPathRel)); @@ -780,7 +760,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( if( FAILED( r ) ) goto end; - if( hdr.dwFlags & SCF_WORKDIR ) + if( hdr.dwFlags & SLDF_HAS_WORKINGDIR ) { r = Stream_LoadString( stm, unicode, &This->sWorkDir ); TRACE("Working Dir -> %s\n",debugstr_w(This->sWorkDir)); @@ -788,7 +768,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( if( FAILED( r ) ) goto end; - if( hdr.dwFlags & SCF_ARGS ) + if( hdr.dwFlags & SLDF_HAS_ARGS ) { r = Stream_LoadString( stm, unicode, &This->sArgs ); TRACE("Working Dir -> %s\n",debugstr_w(This->sArgs)); @@ -796,7 +776,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( if( FAILED( r ) ) goto end; - if( hdr.dwFlags & SCF_CUSTOMICON ) + if( hdr.dwFlags & SLDF_HAS_ICONLOCATION ) { r = Stream_LoadString( stm, unicode, &This->sIcoPath ); TRACE("Icon file -> %s\n",debugstr_w(This->sIcoPath)); @@ -804,7 +784,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( if( FAILED( r ) ) goto end; - if( hdr.dwFlags & SCF_PRODUCT ) + if( hdr.dwFlags & SLDF_HAS_LOGO3ID ) { r = Stream_LoadAdvertiseInfo( stm, &This->sProduct ); TRACE("Product -> %s\n",debugstr_w(This->sProduct)); @@ -812,7 +792,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( if( FAILED( r ) ) goto end; - if( hdr.dwFlags & SCF_COMPONENT ) + if( hdr.dwFlags & SLDF_HAS_DARWINID ) { r = Stream_LoadAdvertiseInfo( stm, &This->sComponent ); TRACE("Component -> %s\n",debugstr_w(This->sComponent)); @@ -922,17 +902,17 @@ static HRESULT Stream_WriteLocationInfo( IStream* stm, LPCWSTR path, static HRESULT Stream_WriteAdvertiseInfo( IStream* stm, LPCWSTR string, DWORD magic ) { ULONG count; - LINK_ADVERTISEINFO buffer; + EXP_DARWIN_LINK buffer; TRACE("%p\n",stm); memset( &buffer, 0, sizeof buffer ); - buffer.size = sizeof buffer; - buffer.magic = magic; - strncpyW( buffer.bufW, string, MAX_PATH ); - WideCharToMultiByte(CP_ACP, 0, string, -1, buffer.bufA, MAX_PATH, NULL, NULL ); + buffer.dbh.cbSize = sizeof buffer; + buffer.dbh.dwSignature = magic; + lstrcpynW( buffer.szwDarwinID, string, MAX_PATH ); + WideCharToMultiByte(CP_ACP, 0, string, -1, buffer.szDarwinID, MAX_PATH, NULL, NULL ); - return IStream_Write( stm, &buffer, buffer.size, &count ); + return IStream_Write( stm, &buffer, buffer.dbh.cbSize, &count ); } /************************************************************************ @@ -978,23 +958,23 @@ static HRESULT WINAPI IPersistStream_fnSave( header.wHotKey = This->wHotKey; header.nIcon = This->iIcoNdx; - header.dwFlags = SCF_UNICODE; /* strings are in unicode */ + header.dwFlags = SLDF_UNICODE; /* strings are in unicode */ if( This->pPidl ) - header.dwFlags |= SCF_PIDL; + header.dwFlags |= SLDF_HAS_ID_LIST; if( This->sPath ) - header.dwFlags |= SCF_LOCATION; + header.dwFlags |= SLDF_HAS_LINK_INFO; if( This->sDescription ) - header.dwFlags |= SCF_DESCRIPTION; + header.dwFlags |= SLDF_HAS_NAME; if( This->sWorkDir ) - header.dwFlags |= SCF_WORKDIR; + header.dwFlags |= SLDF_HAS_WORKINGDIR; if( This->sArgs ) - header.dwFlags |= SCF_ARGS; + header.dwFlags |= SLDF_HAS_ARGS; if( This->sIcoPath ) - header.dwFlags |= SCF_CUSTOMICON; + header.dwFlags |= SLDF_HAS_ICONLOCATION; if( This->sProduct ) - header.dwFlags |= SCF_PRODUCT; + header.dwFlags |= SLDF_HAS_LOGO3ID; if( This->sComponent ) - header.dwFlags |= SCF_COMPONENT; + header.dwFlags |= SLDF_HAS_DARWINID; SystemTimeToFileTime ( &This->time1, &header.Time1 ); SystemTimeToFileTime ( &This->time2, &header.Time2 ); @@ -1040,10 +1020,10 @@ static HRESULT WINAPI IPersistStream_fnSave( r = Stream_WriteString( stm, This->sIcoPath ); if( This->sProduct ) - r = Stream_WriteAdvertiseInfo( stm, This->sProduct, 0xa0000007 ); + r = Stream_WriteAdvertiseInfo( stm, This->sProduct, EXP_SZ_ICON_SIG ); if( This->sComponent ) - r = Stream_WriteAdvertiseInfo( stm, This->sComponent, 0xa0000006 ); + r = Stream_WriteAdvertiseInfo( stm, This->sComponent, EXP_DARWIN_ID_SIG ); /* the last field is a single zero dword */ zero = 0; @@ -1081,10 +1061,8 @@ static IPersistStreamVtbl psvt = /************************************************************************** * IShellLink_Constructor */ -HRESULT WINAPI IShellLink_Constructor ( - IUnknown * pUnkOuter, - REFIID riid, - LPVOID * ppv) +HRESULT WINAPI IShellLink_Constructor( IUnknown *pUnkOuter, + REFIID riid, LPVOID *ppv ) { IShellLinkImpl * sl; @@ -1092,9 +1070,11 @@ HRESULT WINAPI IShellLink_Constructor ( *ppv = NULL; - if(pUnkOuter) return CLASS_E_NOAGGREGATION; - sl = (IShellLinkImpl *) LocalAlloc(GMEM_ZEROINIT,sizeof(IShellLinkImpl)); - if (!sl) return E_OUTOFMEMORY; + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + sl = LocalAlloc(LMEM_ZEROINIT,sizeof(IShellLinkImpl)); + if (!sl) + return E_OUTOFMEMORY; sl->ref = 1; sl->lpVtbl = &slvt; @@ -1182,12 +1162,8 @@ static HRESULT ShellLink_UpdatePath(LPWSTR sPathRel, LPCWSTR path, LPCWSTR sWork /************************************************************************** * IShellLink_ConstructFromFile */ -HRESULT WINAPI IShellLink_ConstructFromFile ( - IUnknown* pUnkOuter, - REFIID riid, - LPCITEMIDLIST pidl, - LPVOID* ppv -) +HRESULT WINAPI IShellLink_ConstructFromFile( IUnknown* pUnkOuter, REFIID riid, + LPCITEMIDLIST pidl, LPVOID* ppv) { IShellLinkW* psl; @@ -1587,43 +1563,11 @@ static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWORD fFlags) { - HRESULT hr = S_OK; - IShellLinkImpl *This = (IShellLinkImpl *)iface; TRACE("(%p)->(hwnd=%p flags=%lx)\n",This, hwnd, fFlags); - /*FIXME: use IResolveShellLink interface */ - - if (!This->sPath && This->pPidl) { - WCHAR buffer[MAX_PATH]; - - hr = SHELL_GetPathFromIDListW(This->pPidl, buffer, MAX_PATH); - - if (SUCCEEDED(hr) && *buffer) { - This->sPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (lstrlenW(buffer)+1)*sizeof(WCHAR)); - if (!This->sPath) - return E_OUTOFMEMORY; - - lstrcpyW(This->sPath, buffer); - - This->bDirty = TRUE; - } else - hr = S_OK; /* don't report an error occurred while just caching information */ - } - - if (!This->sIcoPath && This->sPath) { - This->sIcoPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (lstrlenW(This->sPath)+1)*sizeof(WCHAR)); - if (!This->sIcoPath) - return E_OUTOFMEMORY; - - lstrcpyW(This->sIcoPath, This->sPath); - This->iIcoNdx = 0; - - This->bDirty = TRUE; - } - - return hr; + return IShellLinkW_Resolve( (IShellLinkW*)&(This->lpvtblw), hwnd, fFlags ); } static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile) @@ -2021,7 +1965,7 @@ static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWOR hr = SHELL_GetPathFromIDListW(This->pPidl, buffer, MAX_PATH); if (SUCCEEDED(hr) && *buffer) { - This->sPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (lstrlenW(buffer)+1)*sizeof(WCHAR)); + This->sPath = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(buffer)+1)*sizeof(WCHAR)); if (!This->sPath) return E_OUTOFMEMORY; @@ -2033,7 +1977,7 @@ static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWOR } if (!This->sIcoPath && This->sPath) { - This->sIcoPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (lstrlenW(This->sPath)+1)*sizeof(WCHAR)); + This->sIcoPath = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(This->sPath)+1)*sizeof(WCHAR)); if (!This->sIcoPath) return E_OUTOFMEMORY; diff --git a/reactos/lib/shell32/shellole.c b/reactos/lib/shell32/shellole.c index ea74a9fa088..e2971039571 100644 --- a/reactos/lib/shell32/shellole.c +++ b/reactos/lib/shell32/shellole.c @@ -161,14 +161,14 @@ HRESULT WINAPI SHCoCreateInstance( TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32); - /* now we create a instance */ + /* now we create an instance */ if (bLoadFromShell32) { if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) { ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid)); } } else if (bLoadWithoutCOM) { - /* load a external dll without ole32 */ + /* load an external dll without ole32 */ HANDLE hLibrary; typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv); DllGetClassObjectFunc DllGetClassObject; @@ -189,7 +189,7 @@ HRESULT WINAPI SHCoCreateInstance( } else { - /* load a external dll in the usual way */ + /* load an external dll in the usual way */ hres = CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv); goto end; } @@ -212,7 +212,7 @@ end: } /************************************************************************* - * DllGetClassObject [SHELL32.128] + * DllGetClassObject [SHELL32.@] */ HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) { @@ -317,7 +317,7 @@ static LPVOID WINAPI IShellMalloc_fnAlloc(LPMALLOC iface, DWORD cb) { LPVOID addr; - addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb); + addr = (LPVOID) LocalAlloc(LMEM_ZEROINIT, cb); TRACE("(%p,%ld);\n",addr,cb); return addr; } @@ -331,14 +331,14 @@ static LPVOID WINAPI IShellMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb) if (pv) { if (cb) { - addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, GMEM_ZEROINIT | GMEM_MOVEABLE); + addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, LMEM_ZEROINIT | LMEM_MOVEABLE); } else { LocalFree((HANDLE) pv); addr = NULL; } } else { if (cb) { - addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb); + addr = (LPVOID) LocalAlloc(LMEM_ZEROINIT, cb); } else { addr = NULL; } @@ -492,9 +492,9 @@ HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf) * SHCreateDefClassObject * * NOTES - * helper function for dll's without a own classfactory - * a generic classfactory is returned - * when the CreateInstance of the cf is called the callback is executed + * Helper function for dlls without their own classfactory. + * A generic classfactory is returned. + * When the CreateInstance of the cf is called the callback is executed. */ typedef struct @@ -517,7 +517,7 @@ IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, { IDefClFImpl* lpclf; - lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl)); + lpclf = HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl)); lpclf->ref = 1; lpclf->lpVtbl = &dclfvt; lpclf->lpfnCI = lpfnCI; @@ -645,7 +645,7 @@ HRESULT WINAPI SHCreateDefClassObject( } /************************************************************************* - * DragAcceptFiles [SHELL32.54] + * DragAcceptFiles [SHELL32.@] */ void WINAPI DragAcceptFiles(HWND hWnd, BOOL b) { @@ -661,7 +661,7 @@ void WINAPI DragAcceptFiles(HWND hWnd, BOOL b) } /************************************************************************* - * DragFinish [SHELL32.80] + * DragFinish [SHELL32.@] */ void WINAPI DragFinish(HDROP h) { @@ -670,7 +670,7 @@ void WINAPI DragFinish(HDROP h) } /************************************************************************* - * DragQueryPoint [SHELL32.135] + * DragQueryPoint [SHELL32.@] */ BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p) { @@ -689,8 +689,8 @@ BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p) } /************************************************************************* - * DragQueryFile [SHELL32.81] - * DragQueryFileA [SHELL32.82] + * DragQueryFile [SHELL32.@] + * DragQueryFileA [SHELL32.@] */ UINT WINAPI DragQueryFileA( HDROP hDrop, @@ -712,7 +712,7 @@ UINT WINAPI DragQueryFileA( LPWSTR lpszFileW = NULL; if(lpszFile) { - lpszFileW = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR)); + lpszFileW = HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR)); if(lpszFileW == NULL) { goto end; } @@ -747,7 +747,7 @@ end: } /************************************************************************* - * DragQueryFileW [SHELL32.133] + * DragQueryFileW [SHELL32.@] */ UINT WINAPI DragQueryFileW( HDROP hDrop, @@ -769,7 +769,7 @@ UINT WINAPI DragQueryFileW( LPSTR lpszFileA = NULL; if(lpszwFile) { - lpszFileA = (LPSTR) HeapAlloc(GetProcessHeap(), 0, lLength); + lpszFileA = HeapAlloc(GetProcessHeap(), 0, lLength); if(lpszFileA == NULL) { goto end; } diff --git a/reactos/lib/shell32/shellord.c b/reactos/lib/shell32/shellord.c index 403afe2e855..3f36fd07045 100644 --- a/reactos/lib/shell32/shellord.c +++ b/reactos/lib/shell32/shellord.c @@ -574,7 +574,7 @@ static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData * mruhandle [IN] handle for created MRU list * doc_name [IN] null termed pure doc name * new_lnk_name [IN] null termed path and file name for .lnk file - * buffer [IN/OUT] 2048 byte area to consturct MRU data + * buffer [IN/OUT] 2048 byte area to construct MRU data * len [OUT] ptr to int to receive space used in buffer * * RETURNS @@ -1506,7 +1506,7 @@ HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1) ret = E_INVALIDARG; else { - LPVOID lpdata = 0;/*LocalAlloc(GMEM_ZEROINIT, 0x4E4);*/ + LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/ if (!lpdata) ret = E_OUTOFMEMORY; diff --git a/reactos/lib/shell32/shellpath.c b/reactos/lib/shell32/shellpath.c index 3201c64fb11..72f358937b7 100644 --- a/reactos/lib/shell32/shellpath.c +++ b/reactos/lib/shell32/shellpath.c @@ -1202,17 +1202,22 @@ static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType, (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ)) { + LONG ret; + path[dwPathLen / sizeof(WCHAR)] = '\0'; if (dwType == REG_EXPAND_SZ && path[0] == '%') { WCHAR szTemp[MAX_PATH]; _SHExpandEnvironmentStrings(path, szTemp); - strncpyW(path, szTemp, MAX_PATH); + lstrcpynW(path, szTemp, MAX_PATH); } - RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path, + ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR)); - hr = S_OK; + if (ret != ERROR_SUCCESS) + hr = HRESULT_FROM_WIN32(ret); + else + hr = S_OK; } else hr = E_FAIL; @@ -1267,7 +1272,8 @@ static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath) } else { - FIXME("(%d,%s), LoadString failed, missing translation?\n", folder, debugstr_w(pszPath)); + FIXME("(%d,%s), LoadString failed, missing translation?\n", folder, + debugstr_w(pszPath)); hr = E_FAIL; } } @@ -1487,12 +1493,12 @@ static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName, else { /* Missing or invalid value, set a default */ - strncpyW(szValue, szDefault, MAX_PATH); - szValue[MAX_PATH - 1] = '\0'; + lstrcpynW(szValue, szDefault, MAX_PATH); TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName), - debugstr_w(szValue)); + debugstr_w(szValue)); lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ, - (LPBYTE)szValue, (strlenW(szValue) + 1) * sizeof(WCHAR)); + (LPBYTE)szValue, + (strlenW(szValue) + 1) * sizeof(WCHAR)); if (lRet) hr = HRESULT_FROM_WIN32(lRet); else @@ -1717,21 +1723,21 @@ HRESULT WINAPI SHGetFolderPathA( } /* For each folder in folders, if its value has not been set in the registry, - * call _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the + * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the * folder's type) to get the unexpanded value first. - * This will create the expanded value in the Shell Folders key, and - * return the unexpanded value. - * Write the unexpanded value to User Shell Folders, and query it with - * SHGetFolderPath to force the creation of the directory if it doesn't - * already exist. + * Writes the unexpanded value to User Shell Folders, and queries it with + * SHGetFolderPathW to force the creation of the directory if it doesn't + * already exist. SHGetFolderPathW also returns the expanded value, which + * this then writes to Shell Folders. */ static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, - LPCWSTR szUserShellFolderPath, const UINT folders[], UINT foldersLen) + LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], + UINT foldersLen) { UINT i; WCHAR path[MAX_PATH]; HRESULT hr = S_OK; - HKEY hKey = NULL; + HKEY hUserKey = NULL, hKey = NULL; DWORD dwDisp, dwType, dwPathLen; LONG ret; @@ -1739,13 +1745,20 @@ static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, debugstr_w(szUserShellFolderPath), folders, foldersLen); ret = RegCreateKeyExW(hRootKey, szUserShellFolderPath, 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); + KEY_ALL_ACCESS, NULL, &hUserKey, &dwDisp); if (ret) hr = HRESULT_FROM_WIN32(ret); + else + { + ret = RegCreateKeyExW(hRootKey, szShellFolderPath, 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); + if (ret) + hr = HRESULT_FROM_WIN32(ret); + } for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++) { dwPathLen = MAX_PATH * sizeof(WCHAR); - if (RegQueryValueExW(hKey, CSIDL_Data[folders[i]].szValueName, NULL, + if (RegQueryValueExW(hUserKey, CSIDL_Data[folders[i]].szValueName, NULL, &dwType, (LPBYTE)path, &dwPathLen) || (dwType != REG_SZ && dwType != REG_EXPAND_SZ)) { @@ -1759,17 +1772,26 @@ static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, hr = E_FAIL; if (*path) { - ret = RegSetValueExW(hKey, CSIDL_Data[folders[i]].szValueName, - 0, REG_EXPAND_SZ, (LPBYTE)path, - (strlenW(path) + 1) * sizeof(WCHAR)); + ret = RegSetValueExW(hUserKey, + CSIDL_Data[folders[i]].szValueName, 0, REG_EXPAND_SZ, + (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR)); if (ret) hr = HRESULT_FROM_WIN32(ret); else + { hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE, - hToken, SHGFP_TYPE_DEFAULT, NULL); + hToken, SHGFP_TYPE_DEFAULT, path); + ret = RegSetValueExW(hKey, + CSIDL_Data[folders[i]].szValueName, 0, REG_SZ, + (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR)); + if (ret) + hr = HRESULT_FROM_WIN32(ret); + } } } } + if (hUserKey) + RegCloseKey(hUserKey); if (hKey) RegCloseKey(hKey); @@ -1794,8 +1816,8 @@ static HRESULT _SHRegisterUserShellFolders(BOOL bDefault) CSIDL_COOKIES, CSIDL_HISTORY, }; - WCHAR userShellFolderPath[MAX_PATH]; - LPCWSTR pUserShellFolderPath; + WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH]; + LPCWSTR pUserShellFolderPath, pShellFolderPath; HRESULT hr = S_OK; HKEY hRootKey; HANDLE hToken; @@ -1809,16 +1831,21 @@ static HRESULT _SHRegisterUserShellFolders(BOOL bDefault) PathAddBackslashW(userShellFolderPath); strcatW(userShellFolderPath, szSHUserFolders); pUserShellFolderPath = userShellFolderPath; + strcpyW(shellFolderPath, DefaultW); + PathAddBackslashW(shellFolderPath); + strcatW(shellFolderPath, szSHFolders); + pShellFolderPath = shellFolderPath; } else { hToken = NULL; hRootKey = HKEY_CURRENT_USER; pUserShellFolderPath = szSHUserFolders; + pShellFolderPath = szSHFolders; } hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath, - folders, sizeof(folders) / sizeof(folders[0])); + pShellFolderPath, folders, sizeof(folders) / sizeof(folders[0])); TRACE("returning 0x%08lx\n", hr); return hr; } @@ -1839,7 +1866,7 @@ static HRESULT _SHRegisterCommonShellFolders(void) TRACE("\n"); hr = _SHRegisterFolders(HKEY_LOCAL_MACHINE, NULL, szSHUserFolders, - folders, sizeof(folders) / sizeof(folders[0])); + szSHFolders, folders, sizeof(folders) / sizeof(folders[0])); TRACE("returning 0x%08lx\n", hr); return hr; } diff --git a/reactos/lib/shell32/shfldr_desktop.c b/reactos/lib/shell32/shfldr_desktop.c index 5e8b13d696d..c2c200b474f 100644 --- a/reactos/lib/shell32/shfldr_desktop.c +++ b/reactos/lib/shell32/shfldr_desktop.c @@ -66,8 +66,8 @@ typedef struct { CLSID *pclsid; /* both paths are parsible from the desktop */ - LPSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ + LPWSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ + LPITEMIDLIST pidlRoot; /* absolute pidl */ int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ @@ -78,8 +78,6 @@ typedef struct { #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl) #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) -static struct IShellFolder2Vtbl 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}, @@ -90,45 +88,6 @@ static shvheader DesktopSFHeader[] = { #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; - sf->lpVtbl = &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 * @@ -253,13 +212,11 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, LPWSTR pathPtr; /* build a complete path to create a simple pidl */ - MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szPath, - sizeof(szPath) / sizeof(szPath[0])); + lstrcpynW(szPath, This->sPathTarget, MAX_PATH); pathPtr = PathAddBackslashW(szPath); if (pathPtr) { - lstrcpynW(pathPtr, lpszDisplayName, - sizeof(szPath)/sizeof(szPath[0]) - (pathPtr - szPath)); + lstrcpynW(pathPtr, lpszDisplayName, MAX_PATH - (pathPtr - szPath)); hr = _ILCreateFromPathW(szPath, &pidlTemp); } else @@ -383,11 +340,14 @@ static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; + char szPath[MAX_PATH]; 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); + WideCharToMultiByte( CP_ACP, 0, This->sPathTarget, -1, + szPath, MAX_PATH, NULL, NULL ); + return SHELL32_BindToChild( This->pidlRoot, szPath, pidl, riid, ppvOut ); } /************************************************************************** @@ -520,20 +480,9 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface, if (!ppvOut) return hr; - if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) - { - pObj = (LPUNKNOWN) IDataObject_Constructor( hwndOwner, - This->pidlRoot, apidl, cidl); - hr = S_OK; - } - else if ((IsEqualIID(riid,&IID_IShellLinkW) || - IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); - } - else if (IsEqualIID (riid, &IID_IContextMenu)) + *ppvOut = NULL; + + if (IsEqualIID (riid, &IID_IContextMenu)) { if (cidl > 0) pObj = (LPUNKNOWN) ISvItemCm_Constructor( (IShellFolder *) iface, This->pidlRoot, apidl, cidl); @@ -541,6 +490,12 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface, pObj = (LPUNKNOWN) ISvBgCm_Constructor( (IShellFolder *) iface, TRUE); 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]); @@ -560,6 +515,13 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface, hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj); } + else if ((IsEqualIID(riid,&IID_IShellLinkW) || + IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) + { + pidl = ILCombine (This->pidlRoot, apidl[0]); + hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); + SHFree (pidl); + } else hr = E_NOINTERFACE; @@ -581,30 +543,46 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - CHAR szPath[MAX_PATH]; - GUID const *clsid; HRESULT hr = S_OK; - *szPath = '\0'; - TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet); pdump (pidl); if (!strRet) return E_INVALIDARG; + strRet->uType = STRRET_CSTR; if (_ILIsDesktop (pidl)) { if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)) { - lstrcpyA (szPath, This->sPathTarget); + BOOL defCharUsed; + + WideCharToMultiByte( CP_ACP, 0, This->sPathTarget, -1, + strRet->u.cStr, MAX_PATH, NULL, &defCharUsed ); + if (defCharUsed) + { + strRet->u.pOleStr = SHAlloc((lstrlenW(This->sPathTarget)+1) * + sizeof(WCHAR)); + if (!strRet->u.pOleStr) + hr = E_OUTOFMEMORY; + else + { + strcpyW(strRet->u.pOleStr, This->sPathTarget); + strRet->uType = STRRET_WSTR; + } + } } else - HCR_GetClassNameA(&CLSID_ShellDesktop, szPath, MAX_PATH); + { + HCR_GetClassNameA(&CLSID_ShellDesktop, strRet->u.cStr, MAX_PATH); + } } else if (_ILIsPidlSimple (pidl)) { + GUID const *clsid; + if ((clsid = _ILGetGUIDPointer (pidl))) { if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) @@ -620,7 +598,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, */ if (IsEqualIID (clsid, &CLSID_MyComputer)) { - bWantsForParsing = 1; + bWantsForParsing = TRUE; } else { @@ -654,43 +632,41 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, * Only the folder itself can know it */ hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, - szPath, MAX_PATH); + strRet->u.cStr, + MAX_PATH); } else { /* parsing name like ::{...} */ - lstrcpyA (szPath, "::"); - SHELL32_GUIDToStringA (clsid, &szPath[2]); + lstrcpyA (strRet->u.cStr, "::"); + SHELL32_GUIDToStringA (clsid, &strRet->u.cStr[2]); } } else { /* user friendly name */ - HCR_GetClassNameA (clsid, szPath, MAX_PATH); + HCR_GetClassNameA (clsid, strRet->u.cStr, MAX_PATH); } } else { /* file system folder */ - _ILSimpleGetText (pidl, szPath, MAX_PATH); + _ILSimpleGetText (pidl, strRet->u.cStr, MAX_PATH); if (!_ILIsFolder(pidl)) - SHELL_FS_ProcessDisplayFilename(szPath, dwFlags); + SHELL_FS_ProcessDisplayFilename(strRet->u.cStr, dwFlags); } } else { /* a complex pidl, let the subfolder do the work */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH); + hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, + strRet->u.cStr, 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); + TRACE ("-- (%p)->(%s,0x%08lx)\n", This, + strRet->uType == STRRET_CSTR ? strRet->u.cStr : + debugstr_w(strRet->u.pOleStr), hr); return hr; } @@ -778,7 +754,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface, { IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = E_FAIL; + HRESULT hr = S_OK; TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); @@ -796,6 +772,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface, } /* the data from the pidl */ + psd->str.uType = STRRET_CSTR; switch (iColumn) { case 0: /* name */ @@ -815,8 +792,6 @@ static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface, _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); break; } - hr = S_OK; - psd->str.uType = STRRET_CSTR; return hr; } @@ -853,3 +828,44 @@ static IShellFolder2Vtbl vt_MCFldr_ShellFolder2 = ISF_Desktop_fnGetDetailsOf, ISF_Desktop_fnMapColumnToSCID }; + +/************************************************************************** + * ISF_Desktop_Constructor + */ +HRESULT WINAPI ISF_Desktop_Constructor ( + IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) +{ + IGenericSFImpl *sf; + WCHAR szMyPath[MAX_PATH]; + HRESULT r; + + TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); + + if (!ppv) + return E_POINTER; + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + + if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE )) + return E_UNEXPECTED; + + sf = LocalAlloc( LMEM_ZEROINIT, sizeof (IGenericSFImpl) ); + if (!sf) + return E_OUTOFMEMORY; + + sf->ref = 0; + sf->lpVtbl = &vt_MCFldr_ShellFolder2; + sf->pidlRoot = _ILCreateDesktop(); /* my qualified pidl */ + sf->sPathTarget = SHAlloc( (lstrlenW(szMyPath) + 1)*sizeof(WCHAR) ); + lstrcpyW( sf->sPathTarget, szMyPath ); + + r = IUnknown_QueryInterface( _IUnknown_(sf), riid, ppv ); + if (!SUCCEEDED (r)) + { + IUnknown_Release( _IUnknown_(sf) ); + return r; + } + + TRACE ("--(%p)\n", sf); + return S_OK; +} diff --git a/reactos/lib/shell32/shfldr_fs.c b/reactos/lib/shell32/shfldr_fs.c index 41c6e1d543e..4d0a9b449ae 100644 --- a/reactos/lib/shell32/shfldr_fs.c +++ b/reactos/lib/shell32/shfldr_fs.c @@ -104,7 +104,7 @@ static struct ISFHelperVtbl shvt; #define _ICOM_THIS_From_ISFHelper(class, name) class* This = (class*)(((char*)name)-_ISFHelper_Offset); /* - converts This to a interface pointer + converts This to an interface pointer */ #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) #define _IShellFolder_(This) (IShellFolder*)&(This->lpvtblShellFolder) @@ -233,7 +233,7 @@ IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) return CLASS_E_NOAGGREGATION; - sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl)); + sf = (IGenericSFImpl *) LocalAlloc (LMEM_ZEROINIT, sizeof (IGenericSFImpl)); if (!sf) return E_OUTOFMEMORY; @@ -686,45 +686,46 @@ static const WCHAR HideFileExtW[] = { 'H','i','d','e','F','i','l','e','E','x', static const WCHAR NeverShowExtW[] = { 'N','e','v','e','r','S','h','o','w','E', 'x','t',0 }; +static BOOL hide_extension(LPWSTR szPath) +{ + HKEY hKey; + DWORD dwData; + DWORD dwDataSize = sizeof (DWORD); + BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */ + + if (!RegCreateKeyExW(HKEY_CURRENT_USER, AdvancedW, 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) { + if (!RegQueryValueExW(hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, &dwDataSize)) + doHide = dwData; + RegCloseKey (hKey); + } + + if (!doHide) { + LPWSTR ext = PathFindExtensionW(szPath); + + if (*ext != '\0') { + WCHAR classname[MAX_PATH]; + LONG classlen = sizeof(classname); + + if (!RegQueryValueW(HKEY_CLASSES_ROOT, ext, classname, &classlen)) + if (!RegOpenKeyW(HKEY_CLASSES_ROOT, classname, &hKey)) { + if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, NULL, NULL)) + doHide = TRUE; + RegCloseKey(hKey); + } + } + } + return doHide; +} + void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags) { + WCHAR pathW[MAX_PATH]; + /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */ if (!(dwFlags & SHGDN_FORPARSING) && ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) { - HKEY hKey; - DWORD dwData; - DWORD dwDataSize = sizeof (DWORD); - BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */ - - if (!RegCreateKeyExW (HKEY_CURRENT_USER, AdvancedW, - 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) { - if (!RegQueryValueExW (hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, - &dwDataSize)) - doHide = dwData; - - RegCloseKey (hKey); - } - - if (!doHide) { - LPSTR ext = PathFindExtensionA(szPath); - - if (ext) { - char classname[MAX_PATH]; - LONG classlen = MAX_PATH; - - if (!RegQueryValueA(HKEY_CLASSES_ROOT, ext, classname, - &classlen)) - if (!RegOpenKeyA(HKEY_CLASSES_ROOT, classname, &hKey)) { - if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, - NULL, NULL)) - doHide = TRUE; - - RegCloseKey(hKey); - } - } - } - - if (doHide && szPath[0] != '.') + MultiByteToWideChar(CP_ACP, 0, szPath, -1, pathW, MAX_PATH); + if (hide_extension(pathW) && szPath[0] != '.') PathRemoveExtensionA (szPath); } } @@ -828,22 +829,30 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, debugstr_w (lpName), dwFlags, pPidlOut); /* build source path */ - if (dwFlags & SHGDN_INFOLDER) { - MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH); - ptr = PathAddBackslashW (szSrc); - if (ptr) - _ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc)); - } else { - /* FIXME: Can this work with a simple PIDL? */ - SHGetPathFromIDListW (pidl, szSrc); - } + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH); + ptr = PathAddBackslashW (szSrc); + if (ptr) + _ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc)); /* build destination path */ - MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH); - ptr = PathAddBackslashW (szDest); - if (ptr) - lstrcpynW(ptr, lpName, MAX_PATH - (ptr - szDest)); + if (dwFlags == SHGDN_NORMAL || dwFlags & SHGDN_INFOLDER) { + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH); + ptr = PathAddBackslashW (szDest); + if (ptr) + lstrcpynW(ptr, lpName, MAX_PATH - (ptr - szDest)); + } else + lstrcpynW(szDest, lpName, MAX_PATH); + + if(!(dwFlags & SHGDN_FORPARSING) && hide_extension(szSrc)) { + WCHAR *ext = PathFindExtensionW(szSrc); + if(*ext != '\0') { + INT len = strlenW(szDest); + lstrcpynW(szDest + len, ext, MAX_PATH - len); + } + } + TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest)); + if (MoveFileW (szSrc, szDest)) { HRESULT hr = S_OK; diff --git a/reactos/lib/shell32/shfldr_mycomp.c b/reactos/lib/shell32/shfldr_mycomp.c index ef6a23eb206..4c76ebcadbc 100644 --- a/reactos/lib/shell32/shfldr_mycomp.c +++ b/reactos/lib/shell32/shfldr_mycomp.c @@ -71,7 +71,7 @@ static struct IPersistFolder2Vtbl vt_PersistFolder2; #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset); /* - converts This to a interface pointer + converts This to an interface pointer */ #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) @@ -108,7 +108,7 @@ HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LP if (pUnkOuter) return CLASS_E_NOAGGREGATION; - sf = LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl)); + sf = LocalAlloc (LMEM_ZEROINIT, sizeof (IGenericSFImpl)); if (!sf) return E_OUTOFMEMORY; diff --git a/reactos/lib/shell32/shlexec.c b/reactos/lib/shell32/shlexec.c index 8385b12d886..cf3b4db9aaf 100644 --- a/reactos/lib/shell32/shlexec.c +++ b/reactos/lib/shell32/shlexec.c @@ -180,7 +180,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp default: /* - * Check if this is a env-variable here... + * Check if this is an env-variable here... */ /* Make sure that we have at least one more %.*/ @@ -195,7 +195,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp *tmpB++ = *fmt++; *tmpB++ = 0; - TRACE("Checking %s to be a env-var\n", debugstr_w(tmpBuffer)); + TRACE("Checking %s to be an env-var\n", debugstr_w(tmpBuffer)); envRet = GetEnvironmentVariableW(tmpBuffer, tmpEnvBuff, MAX_PATH); if (envRet == 0 || envRet > MAX_PATH) @@ -1218,7 +1218,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfun LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/; for(s=beg; (space=strchrW(s, ' ')); s=space+1) { int idx = space-sei_tmp.lpFile; - strncpyW(buffer, sei_tmp.lpFile, idx); + memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR)); buffer[idx] = '\0'; /*FIXME This finds directory paths if the targeted file name contains spaces. */ @@ -1296,7 +1296,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfun TRACE("Got URL: %s\n", debugstr_w(lpFile)); /* Looking for ...protocol\shell\lpOperation\command */ - strncpyW(lpstrProtocol, lpFile, iSize); + memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR)); lpstrProtocol[iSize] = '\0'; strcatW(lpstrProtocol, wShell); strcatW(lpstrProtocol, sei_tmp.lpVerb? sei_tmp.lpVerb: wszOpen); @@ -1398,6 +1398,9 @@ BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei) sei->hInstApp = seiW.hInstApp; + if (sei->fMask & SEE_MASK_NOCLOSEPROCESS) + sei->hProcess = seiW.hProcess; + if (wVerb) SHFree(wVerb); if (wFile) SHFree(wFile); if (wParameters) SHFree(wParameters); diff --git a/reactos/lib/shell32/shlfileop.c b/reactos/lib/shell32/shlfileop.c index dfa6fb30863..5e12e815638 100644 --- a/reactos/lib/shell32/shlfileop.c +++ b/reactos/lib/shell32/shlfileop.c @@ -719,6 +719,8 @@ LPWSTR SHFileStrCpyCatW(LPWSTR pTo, LPCWSTR pFrom, LPCWSTR pCatStr) lstrcpyW(&pTo[i_len+1], pCatStr); } pToFile = StrRChrW(pTo,NULL,'\\'); + if (!pToFile) + pToFile = pTo; /* termination of the new string-group */ pTo[(lstrlenW(pTo)) + 1] = '\0'; } @@ -931,9 +933,9 @@ static int shfileops_check_flags(SHFILEOPSTRUCTW nFileOp) if (OFl) { if (OFl & (~(FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION | - FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS))) + FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS | FOF_ALLOWUNDO))) { - TRACE("%s level=%ld lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n", + FIXME("%s level=%ld lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n", debug_shfileops_action(FuncSwitch), level, OFl); return 0x403; /* 1027, we need an extension to shlfileop */ } diff --git a/reactos/lib/shell32/shlfolder.c b/reactos/lib/shell32/shlfolder.c index e6734ebcc60..da5acfbb2bf 100644 --- a/reactos/lib/shell32/shlfolder.c +++ b/reactos/lib/shell32/shlfolder.c @@ -1,4 +1,3 @@ - /* * Shell Folder stuff * @@ -51,19 +50,8 @@ WINE_DEFAULT_DEBUG_CHANNEL (shell); -/*************************************************************************** - * debughelper: print out the return address - * helps especially to track down unbalanced AddRef/Release - */ -#define MEM_DEBUG 0 - -#if MEM_DEBUG -#define _CALL_TRACE TRACE("called from: 0x%08x\n", *( ((UINT*)&iface)-1 )); -#else -#define _CALL_TRACE -#endif - -static const WCHAR wszDotShellClassInfo[] = {'.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0}; +static const WCHAR wszDotShellClassInfo[] = { + '.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0}; /*************************************************************************** * SHELL32_GetCustomFolderAttribute (internal function) @@ -86,26 +74,26 @@ BOOL SHELL32_GetCustomFolderAttribute( LPCITEMIDLIST pidl, LPCWSTR pwszHeading, LPCWSTR pwszAttribute, LPWSTR pwszValue, DWORD cchValue) { -#if 0 /* Hack around not having system attribute on non-Windows file systems */ - DWORD dwAttrib = _ILGetFileAttributes(pidl, NULL, 0); -#else + static const WCHAR wszDesktopIni[] = + {'d','e','s','k','t','o','p','.','i','n','i',0}; + static const WCHAR wszDefault[] = {0}; DWORD dwAttrib = FILE_ATTRIBUTE_SYSTEM; -#endif + + /* Hack around not having system attribute on non-Windows file systems */ + if (0) + dwAttrib = _ILGetFileAttributes(pidl, NULL, 0); + if (dwAttrib & FILE_ATTRIBUTE_SYSTEM) { DWORD ret; WCHAR wszDesktopIniPath[MAX_PATH]; - static const WCHAR wszDesktopIni[] = - {'d','e','s','k','t','o','p','.','i','n','i',0}; - static const WCHAR wszDefault[] = - {0}; + if (!SHGetPathFromIDListW(pidl, wszDesktopIniPath)) return FALSE; PathAppendW(wszDesktopIniPath, wszDesktopIni); ret = GetPrivateProfileStringW(pwszHeading, pwszAttribute, wszDefault, pwszValue, cchValue, wszDesktopIniPath); - if (!ret) return FALSE; - return TRUE; + return ret; } return FALSE; } @@ -316,7 +304,7 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot, * - asks it for the displayname of [subpidl2][subpidl3] * * Is possible the pidl is a simple pidl. In this case it asks the - * subfolder for the displayname of a empty pidl. The subfolder + * subfolder for the displayname of an empty pidl. The subfolder * returns the own displayname eg. "::{guid}". This is used for * virtual folders with the registry key WantsFORPARSING set. */ @@ -408,7 +396,9 @@ HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWO } } else if (_ILGetDataPointer (pidl)) { dwAttributes = _ILGetFileAttributes (pidl, NULL, 0); - *pdwAttributes &= ~SFGAO_FILESYSANCESTOR; + + if ((SFGAO_FILESYSANCESTOR & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) + *pdwAttributes &= ~SFGAO_FILESYSANCESTOR; if ((SFGAO_FOLDER & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) *pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER); diff --git a/reactos/lib/shell32/shlmenu.c b/reactos/lib/shell32/shlmenu.c index 6c2b149cf74..ea245f2a864 100644 --- a/reactos/lib/shell32/shlmenu.c +++ b/reactos/lib/shell32/shlmenu.c @@ -198,7 +198,7 @@ static int FM_InitMenuPopup(HMENU hmenu, LPCITEMIDLIST pAlternatePidl) MENUINFO MenuInfo; HMENU hMenuPopup = CreatePopupMenu(); - lpFmMi = (LPFMINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); + lpFmMi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); lpFmMi->pidl = ILCombine(pidl, pidlTemp); lpFmMi->uEnumFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS; @@ -269,7 +269,7 @@ HMENU WINAPI FileMenu_Create ( TRACE("0x%08lx 0x%08x %p 0x%08x 0x%08x hMenu=%p\n", crBorderColor, nBorderWidth, hBorderBmp, nSelHeight, uFlags, hMenu); - menudata = (LPFMINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); + menudata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); menudata->crBorderColor = crBorderColor; menudata->nBorderWidth = nBorderWidth; menudata->hBorderBmp = hBorderBmp; @@ -647,7 +647,7 @@ LRESULT WINAPI FileMenu_DrawItem( * FileMenu_InitMenuPopup [SHELL32.109] * * NOTES - * The filemenu is a ownerdrawn menu. Call this function responding to + * The filemenu is an ownerdrawn menu. Call this function responding to * WM_INITPOPUPMENU * */ diff --git a/reactos/lib/shell32/shlview.c b/reactos/lib/shell32/shlview.c index 06f30c6c7b1..0634a4ffc8f 100644 --- a/reactos/lib/shell32/shlview.c +++ b/reactos/lib/shell32/shlview.c @@ -172,7 +172,7 @@ typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMa */ IShellView * IShellView_Constructor( IShellFolder * pFolder) { IShellViewImpl * sv; - sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl)); + sv=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl)); sv->ref=1; sv->lpVtbl=&svvt; sv->lpvtblOleCommandTarget=&ctvt; @@ -217,7 +217,7 @@ static HRESULT OnDefaultCommand(IShellViewImpl * This) { TRACE("ICommDlgBrowser::OnDefaultCommand\n"); ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This); - TRACE("--\n"); + TRACE("-- returns %08lx\n", ret); } return ret; } @@ -962,7 +962,7 @@ static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL if (uCommand==FCIDM_SHVIEW_OPEN && IsInCommDlg(This)) { TRACE("-- dlg: OnDefaultCommand\n"); - if (FAILED(OnDefaultCommand(This))) + if (OnDefaultCommand(This) != S_OK) { ShellView_OpenSelectedItems(This); } diff --git a/reactos/lib/shell32/shres.rc b/reactos/lib/shell32/shres.rc index 81ce37786a1..df55c74f63a 100644 --- a/reactos/lib/shell32/shres.rc +++ b/reactos/lib/shell32/shres.rc @@ -36,7 +36,7 @@ BEGIN END /* BINRES document.ico */ -1 ICON document.ico +IDI_SHELL_DOCUMENT ICON document.ico /* { '00 00 01 00 0C 00 10 10 10 00 01 00 04 00 28 01' '00 00 C6 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -3201,7 +3201,7 @@ END /* BINRES folder.ico */ -3 ICON folder.ico +IDI_SHELL_FOLDER ICON folder.ico /* { '00 00 01 00 0C 00 10 10 10 00 01 00 04 00 28 01' '00 00 C6 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -6367,7 +6367,7 @@ END /* BINRES folder_open.ico */ -4 ICON folder_open.ico +IDI_SHELL_FOLDER_OPEN ICON folder_open.ico /*{ '00 00 01 00 0B 00 10 10 10 00 01 00 04 00 28 01' '00 00 B6 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -8473,7 +8473,7 @@ END /* BINRES floppy.ico */ -5 ICON floppy.ico +IDI_SHELL_FLOPPY ICON floppy.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -10055,7 +10055,7 @@ END /* BINRES drive.ico */ -8 ICON drive.ico +IDI_SHELL_DRIVE ICON drive.ico /* { '00 00 01 00 0C 00 10 10 10 00 01 00 04 00 28 01' '00 00 C6 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -13219,7 +13219,7 @@ END } */ /* BINRES netdrive.ico */ -9 ICON netdrive.ico +IDI_SHELL_NETDRIVE ICON netdrive.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -14800,7 +14800,7 @@ END } */ /* BINRES netdrive2.ico */ -10 ICON netdrive2.ico +IDI_SHELL_NETDRIVE2 ICON netdrive2.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -16381,7 +16381,7 @@ END } */ /* BINRES cdrom.ico */ -11 ICON cdrom.ico +IDI_SHELL_CDROM ICON cdrom.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -17962,7 +17962,7 @@ END } */ /* BINRES ramdisk.ico */ -12 ICON ramdisk.ico +IDI_SHELL_RAMDISK ICON ramdisk.ico /* { '00 00 01 00 07 00 20 20 00 00 01 00 04 00 E8 02' '00 00 76 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -19334,7 +19334,7 @@ END /* BINRES mycomputer.ico */ -15 ICON mycomputer.ico +IDI_SHELL_MY_COMPUTER ICON mycomputer.ico /*{ '00 00 01 00 0C 00 10 10 10 00 00 00 00 00 28 01' '00 00 C6 00 00 00 10 10 00 00 00 00 00 00 68 05' @@ -22497,10 +22497,81 @@ END 'FF FF FF FF FF FF' }*/ - +/* BINRES printer.ico */ +IDI_SHELL_PRINTER ICON printer.ico +/* { + '00 00 01 00 02 00 20 20 10 00 00 00 00 00 E8 02' + '00 00 26 00 00 00 10 10 10 00 00 00 00 00 28 01' + '00 00 0E 03 00 00 28 00 00 00 20 00 00 00 40 00' + '00 00 01 00 04 00 00 00 00 00 80 02 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 80 00 00 80 00 00 00 80 80 00 80 00' + '00 00 80 00 80 00 80 80 00 00 C0 C0 C0 00 80 80' + '80 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00' + '00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '08 88 88 88 88 88 88 88 88 80 00 00 00 00 00 00' + '08 88 88 88 88 88 88 88 88 80 00 00 00 00 00 00' + '08 88 88 88 88 8A A8 89 98 80 00 00 00 00 00 00' + '08 88 88 88 88 8A A8 89 98 80 00 00 00 00 00 00' + '08 88 88 88 88 88 88 88 88 80 00 00 00 00 00 00' + '08 88 88 88 88 88 88 88 88 80 00 00 00 00 00 00' + '00 77 77 77 77 77 77 77 77 77 00 00 00 00 00 00' + '00 07 77 77 77 77 77 77 77 77 70 00 00 00 00 00' + '00 00 77 77 77 77 77 77 77 77 77 00 00 00 00 00' + '00 00 07 7F FF FF FF FF FF FF FF 70 00 00 00 00' + '00 00 00 7F FF FF FF FF FF FF FF 77 00 00 00 00' + '00 00 00 0F FF FF FF FF FF FF FF 77 70 00 00 00' + '00 00 00 0F FF 00 00 00 00 0F FF 00 00 00 00 00' + '00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00 00' + '00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00 00' + '00 00 00 00 FF F0 00 00 00 00 FF F0 00 00 00 00' + '00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00 00' + '00 00 00 00 0F FF FF FF FF FF FF FF 00 00 00 00' + '00 00 00 00 0F FF 00 00 00 00 0F FF 00 00 00 00' + '00 00 00 00 0F FF FF FF FF FF FF FF 00 00 00 00' + '00 00 00 00 0F FF FF FF FF FF FF FF 00 00 00 00' + '00 00 00 00 00 FF F0 00 00 00 00 FF F0 00 00 00' + '00 00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00' + '00 00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00' + '00 00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF' + 'FF FF FF FF FF FF FF FF FF FF F8 00 00 FF F8 00' + '00 7F F8 00 00 3F F8 00 00 1F F8 00 00 0F F8 00' + '00 07 FC 00 00 07 FE 00 00 07 FF 00 00 07 FF 80' + '00 07 FF C0 00 07 FF E0 00 07 FF E0 00 3F FF F0' + '00 1F FF F0 00 1F FF F0 00 1F FF F0 00 1F FF F8' + '00 0F FF F8 00 0F FF F8 00 0F FF F8 00 0F FF FC' + '00 07 FF FC 00 07 FF FC 00 07 FF FC 00 07 FF FF' + 'FF FF FF FF FF FF FF FF FF FF FF FF FF FF 28 00' + '00 00 10 00 00 00 20 00 00 00 01 00 04 00 00 00' + '00 00 C0 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80' + '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80' + '00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF' + '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF' + '00 00 FF FF FF 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 88 88 88 88 88 00 00 00 88' + '88 AA 89 98 00 00 00 88 88 88 88 88 00 00 00 77' + '77 77 77 77 70 00 00 07 7F FF FF FF 77 00 00 00' + '7F FF FF FF 77 70 00 00 0F 00 00 0F 00 00 00 00' + '0F FF FF FF F0 00 00 00 00 F0 00 00 F0 00 00 00' + '00 FF FF FF FF 00 00 00 00 0F 00 00 0F 00 00 00' + '00 0F FF FF FF 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 FF FF 00 00 FF FF 00 00 C0 07' + '00 00 C0 03 00 00 C0 01 00 00 C0 01 00 00 E0 01' + '00 00 F0 01 00 00 F8 0F 00 00 F8 07 00 00 FC 07' + '00 00 FC 03 00 00 FE 03 00 00 FE 03 00 00 FF FF' + '00 00 FF FF 00 00' +} */ /* BINRES desktop.ico */ -34 ICON desktop.ico +IDI_SHELL_DESKTOP ICON desktop.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' diff --git a/reactos/lib/shell32/shresdef.h b/reactos/lib/shell32/shresdef.h index d7419cc70f7..061ce697725 100644 --- a/reactos/lib/shell32/shresdef.h +++ b/reactos/lib/shell32/shresdef.h @@ -89,4 +89,30 @@ #define IDD_TITLE 0x3742 #define IDD_TREEVIEW 0x3741 +#define IDI_SHELL_DOCUMENT 1 +#define IDI_SHELL_FOLDER 4 +#define IDI_SHELL_FOLDER_OPEN 5 +#define IDI_SHELL_5_12_FLOPPY 6 +#define IDI_SHELL_3_14_FLOPPY 7 +#define IDI_SHELL_FLOPPY 8 +#define IDI_SHELL_DRIVE 9 +#define IDI_SHELL_NETDRIVE 10 +#define IDI_SHELL_NETDRIVE2 11 +#define IDI_SHELL_CDROM 12 +#define IDI_SHELL_RAMDISK 13 +#define IDI_SHELL_ENTIRE_NETWORK 14 +#define IDI_SHELL_NETWORK 15 +#define IDI_SHELL_MY_COMPUTER 16 +#define IDI_SHELL_PRINTER 17 +#define IDI_SHELL_MY_NETWORK_PLACES 18 +#define IDI_SHELL_COMPUTERS_NEAR_ME 19 +#define IDI_SHELL_SEARCH 23 +#define IDI_SHELL_HELP 24 +#define IDI_SHELL_EMPTY_RECYCLE_BIN 32 +#define IDI_SHELL_FULL_RECYCLE_BIN 33 +#define IDI_SHELL_DESKTOP 35 +#define IDI_SHELL_CONTROL_PANEL 36 +#define IDI_SHELL_PRINTERS_FOLDER 38 +#define IDI_SHELL_FONTS_FOLDER 39 + #endif diff --git a/reactos/lib/shell32/shv_bg_cmenu.c b/reactos/lib/shell32/shv_bg_cmenu.c index a22384de83b..2244626ab83 100644 --- a/reactos/lib/shell32/shv_bg_cmenu.c +++ b/reactos/lib/shell32/shv_bg_cmenu.c @@ -59,7 +59,7 @@ IContextMenu2 *ISvBgCm_Constructor(IShellFolder* pSFParent, BOOL bDesktop) { BgCmImpl* cm; - cm = (BgCmImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(BgCmImpl)); + cm = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(BgCmImpl)); cm->lpVtbl = &cmvt; cm->ref = 1; cm->pSFParent = pSFParent; @@ -378,14 +378,14 @@ static HRESULT WINAPI ISVBgCm_fnInvokeCommand( break; default: - /* if it's a id just pass it to the parent shv */ + /* if it's an id just pass it to the parent shv */ if (hWndSV) SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(LOWORD(lpcmi->lpVerb), 0),0 ); break; } } if (lpSV) - IShellView_Release(lpSV); /* QueryActiveShellView does AddRef*/ + IShellView_Release(lpSV); /* QueryActiveShellView does AddRef */ return NOERROR; } diff --git a/reactos/lib/shell32/shv_item_cmenu.c b/reactos/lib/shell32/shv_item_cmenu.c index 9aedddd735b..2e7c42e34d0 100644 --- a/reactos/lib/shell32/shv_item_cmenu.c +++ b/reactos/lib/shell32/shv_item_cmenu.c @@ -82,7 +82,7 @@ IContextMenu2 *ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl { ItemCmImpl* cm; UINT u; - cm = (ItemCmImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ItemCmImpl)); + cm = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ItemCmImpl)); cm->lpVtbl = &cmvt; cm->ref = 1; cm->pidl = ILClone(pidl); diff --git a/reactos/lib/shell32/systray.c b/reactos/lib/shell32/systray.c index 1568289a4ad..714ef7727b1 100644 --- a/reactos/lib/shell32/systray.c +++ b/reactos/lib/shell32/systray.c @@ -256,8 +256,7 @@ void SYSTRAY_ItemSetTip(SystrayItem *ptrayItem, CHAR* szTip, int modify) { TTTOOLINFOA ti; - strncpy(ptrayItem->notifyIcon.szTip, szTip, sizeof(ptrayItem->notifyIcon.szTip)); - ptrayItem->notifyIcon.szTip[sizeof(ptrayItem->notifyIcon.szTip)-1]=0; + lstrcpynA(ptrayItem->notifyIcon.szTip, szTip, sizeof(ptrayItem->notifyIcon.szTip)); ti.cbSize = sizeof(TTTOOLINFOA); ti.uFlags = 0; diff --git a/reactos/w32api/include/shlguid.h b/reactos/w32api/include/shlguid.h index 8cbbc01021f..56b706ac22a 100644 --- a/reactos/w32api/include/shlguid.h +++ b/reactos/w32api/include/shlguid.h @@ -10,6 +10,7 @@ extern "C" { #define DEFINE_SHLGUID(n,l,w1,w2) DEFINE_GUID(n,l,w1,w2,0xC0,0,0,0,0,0,0,0x46) #define SID_SShellBrowser IID_IShellBrowser extern const GUID CLSID_MyComputer; +extern const GUID CLSID_MyDocuments; extern const GUID CLSID_ShellDesktop; extern const GUID CLSID_ShellLink; extern const GUID CLSID_ControlPanel; diff --git a/reactos/w32api/include/shlobj.h b/reactos/w32api/include/shlobj.h index 5c367ccdfc4..a05909d7db1 100644 --- a/reactos/w32api/include/shlobj.h +++ b/reactos/w32api/include/shlobj.h @@ -395,6 +395,13 @@ extern "C" { #define SHFMT_ERROR 0xFFFFFFFFL #define SHFMT_CANCEL 0xFFFFFFFEL #define SHFMT_NOFORMAT 0xFFFFFFFDL +#define EXP_SZ_LINK_SIG 0xa0000001 +#define NT_CONSOLE_PROPS_SIG 0xa0000002 +#define NT_FE_CONSOLE_PROPS_SIG 0xa0000004 +#define EXP_SPECIAL_FOLDER_SIG 0xa0000005 +#define EXP_DARWIN_ID_SIG 0xa0000006 +#define EXP_LOGO3_ID_SIG 0xa0000007 +#define EXP_SZ_ICON_SIG 0xa0000007 typedef ULONG SFGAOF; typedef DWORD SHGDNF; @@ -760,6 +767,40 @@ typedef enum RESTRICTIONS REST_NOFILEASSOCIATE, /* 0x41000003 */ } RESTRICTIONS; +typedef enum { + SLDF_HAS_ID_LIST = 0x00000001, + SLDF_HAS_LINK_INFO = 0x00000002, + SLDF_HAS_NAME = 0x00000004, + SLDF_HAS_RELPATH = 0x00000008, + SLDF_HAS_WORKINGDIR = 0x00000010, + SLDF_HAS_ARGS = 0x00000020, + SLDF_HAS_ICONLOCATION = 0x00000040, + SLDF_UNICODE = 0x00000080, + SLDF_FORCE_NO_LINKINFO = 0x00000100, + SLDF_HAS_EXP_SZ = 0x00000200, + SLDF_RUN_IN_SEPERATE = 0x00000400, + SLDF_HAS_LOGO3ID = 0x00000800, + SLDF_HAS_DARWINID = 0x00001000, + SLDF_RUNAS_USER = 0x00002000, + SLDF_HAS_EXP_ICON_SZ = 0x00004000, + SLDF_NO_PIDL_ALIAS = 0x00008000, + SLDF_FORCE_UNCNAME = 0x00010000, + SLDF_RUN_WITH_SHIMLAYER = 0x00020000, + SLDF_RESERVED = 0x80000000, +} SHELL_LINK_DATA_FLAGS; + +typedef struct tagDATABLOCKHEADER +{ + DWORD cbSize; + DWORD dwSignature; +} DATABLOCK_HEADER, *LPDATABLOCK_HEADER, *LPDBLIST; + +typedef struct { + DATABLOCK_HEADER dbh; + CHAR szDarwinID[MAX_PATH]; + WCHAR szwDarwinID[MAX_PATH]; +} EXP_DARWIN_LINK, *LPEXP_DARWIN_LINK; + DECLARE_ENUMERATOR_(IEnumIDList,LPITEMIDLIST); typedef IEnumIDList *LPENUMIDLIST;