reactos/dll/win32/shell32/wine/shell32_main.h

300 lines
11 KiB
C
Raw Normal View History

/*
* internal Shell32 Library definitions
*
* Copyright 1998 Marcus Meissner
* Copyright 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_SHELL_MAIN_H
#define __WINE_SHELL_MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include "shell32_version.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
/*******************************************
* global SHELL32.DLL variables
*/
extern HMODULE huser32 DECLSPEC_HIDDEN;
extern HINSTANCE shell32_hInstance DECLSPEC_HIDDEN;
extern int (WINAPI* SHELL_StrCmpLogical)(PCWSTR s1, PCWSTR s2);
enum {
REST_SH32_ENABLESHELLEXECUTEHOOKS = 0x00060001, // POLID_EnableShellExecuteHooks
};
DWORD SH32_InternalRestricted(DWORD rest);
/* Iconcache */
#define INVALID_INDEX -1
BOOL SIC_Initialize(void);
void SIC_Destroy(void) DECLSPEC_HIDDEN;
BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int * pIndex) DECLSPEC_HIDDEN;
INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags ) DECLSPEC_HIDDEN;
extern INT ShellLargeIconSize;
extern INT ShellSmallIconSize;
extern INT ShellIconBPP;
BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
/* Classes Root */
HRESULT HCR_GetProgIdKeyOfExtension(PCWSTR szExtension, PHKEY phKey, BOOL AllowFallback);
BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot) DECLSPEC_HIDDEN;
BOOL HCR_GetDefaultVerbW( HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) DECLSPEC_HIDDEN;
BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) DECLSPEC_HIDDEN;
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int* picon_idx);
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len) DECLSPEC_HIDDEN;
[SHELL32] Allow using custom desktop/folders/drives icons (#6421) Implement proper reading the current user's icons from registry. CORE-14758 - Load the icons specified by user in registry in the following keys: "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\DefaultIcon" (virtual namespace folders) "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" (filesystem folders and drives) - Implement two functions HCU/HLM_GetIconW for reading the icons from mentioned HKCU and HKLM keys accordingly. - Use HCR_RegGetIconW for falling back to default icons. This function always loads only default icons, even when the custom ones are specified by user. - Refactor SIC_LoadOverlayIcon to use newly implemented HLM_GetIconW. These changes apply to: - virtual namespace folders and other desktop items (like My Computer, My Documents, Network Places, Recycle Bin, Web Browser (aka Internet Explorer), Control Panel and some of its items); - normal filesystem directories; - all types of drives (fixed disk drives, removable drives, CD-ROMs, RamDisks and network drives). Handle invalid drives, setting blank icon for them, since they cannot be recognized or mounted correctly. Also, load the autorun icons first to avoid overriding them by the icons defined in registry. I've rechecked twice: excluding Start Menu icons, Desktop Workspace icon and some FS folder icons that have their own desktop.ini configuration files (we probably should write the custom icons we load to these configs, as Windows does it, perhaps with WritePrivateProfileStringW), all other icons can be changed now (only ones that can be changed on XP SP3 / 2003 SP2) via built-in system tools (like Desktop icons in desk.cpl) or any 3rd-party tools without modifying system resources. Also all icons for the known file types can be changed, same as before my changes. Regarding Start Menu icons: - changing them should be correctly implemented in explorer instead of shell32, as the former is responsible for the Start Menu and partially for the taskbar; - in order to actually use all of them, we need to implement modern Start Menu first. Useful reference: http://www.winfaq.de/faq_html/Content/tip0000/onlinefaq.php?h=tip0162.htm
2024-02-28 22:20:47 +01:00
#ifdef __REACTOS__
/* Current User */
BOOL HCU_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int* picon_idx) DECLSPEC_HIDDEN;
/* Local Machine */
BOOL HLM_GetIconW(int reg_idx, LPWSTR szDest, DWORD len, int* picon_idx) DECLSPEC_HIDDEN;
#endif
/* ANSI versions of above functions, supposed to go away as soon as they are not used anymore */
BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot) DECLSPEC_HIDDEN;
BOOL HCR_GetIconA(LPCSTR szClass, LPSTR szDest, LPCSTR sName, DWORD len, int* picon_idx);
BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len) DECLSPEC_HIDDEN;
BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD dwAttributes) DECLSPEC_HIDDEN;
/* File associations */
#define SHELL32_AssocGetFolderDescription SHELL32_AssocGetFSDirectoryDescription
HRESULT SHELL32_AssocGetFSDirectoryDescription(PWSTR Buf, UINT cchBuf);
HRESULT SHELL32_AssocGetFileDescription(PCWSTR Name, PWSTR Buf, UINT cchBuf);
DWORD WINAPI ParseFieldA(LPCSTR src, DWORD nField, LPSTR dst, DWORD len) DECLSPEC_HIDDEN;
DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len) DECLSPEC_HIDDEN;
LONG
PathProcessCommandW(
_In_ PCWSTR pszSrc,
_Out_writes_opt_(dwBuffSize) PWSTR pszDest,
_In_ INT cchDest,
_In_ DWORD dwFlags);
/****************************************************************************
* Class constructors
*/
HRESULT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl, PCUITEMID_CHILD_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject **dataObject);
HRESULT IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **enumerator);
LPCLASSFACTORY IClassFactory_Constructor(REFCLSID);
IContextMenu2 * ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *aPidls, UINT uItemCount);
HRESULT WINAPI INewItem_Constructor(IUnknown * pUnkOuter, REFIID riif, LPVOID *ppv);
IContextMenu2 * ISvStaticItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, LPCITEMIDLIST *apidl, UINT cidl, HKEY hKey);
IContextMenu2 * ISvBgCm_Constructor(LPSHELLFOLDER pSFParent, BOOL bDesktop);
HRESULT WINAPI CDefViewDual_Constructor(REFIID riid, LPVOID * ppvOut);
HRESULT WINAPI CShellDispatch_Constructor(REFIID riid, LPVOID * ppvOut);
HRESULT WINAPI IShellLink_ConstructFromPath(WCHAR *path, REFIID riid, LPVOID *ppv);
HRESULT WINAPI IShellLink_ConstructFromFile(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv);
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV);
HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN;
HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN;
/* initialisation for FORMATETC */
#define InitFormatEtc(fe, cf, med) \
{\
(fe).cfFormat=cf;\
(fe).dwAspect=DVASPECT_CONTENT;\
(fe).ptd=NULL;\
(fe).tymed=med;\
(fe).lindex=-1;\
};
#define KeyStateToDropEffect(kst)\
((((kst)&(MK_CONTROL|MK_SHIFT))==(MK_CONTROL|MK_SHIFT)) ? DROPEFFECT_LINK :\
(((kst)&(MK_CONTROL)) ? DROPEFFECT_COPY :\
(((kst)&(MK_SHIFT)) ? DROPEFFECT_MOVE :\
DROPEFFECT_NONE)))
HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
HRESULT SHELL_GetShellExtensionRegCLSID(
HKEY hKey,
LPCWSTR KeyName,
CLSID *pClsId);
/* Change Notification */
void InitChangeNotifications(void) DECLSPEC_HIDDEN;
void FreeChangeNotifications(void) DECLSPEC_HIDDEN;
/* file operation */
#define ASK_DELETE_FILE 1
#define ASK_DELETE_FOLDER 2
#define ASK_DELETE_MULTIPLE_ITEM 3
#define ASK_CREATE_FOLDER 4
#define ASK_OVERWRITE_FILE 5
#define ASK_DELETE_SELECTED 6
#define ASK_TRASH_FILE 7
#define ASK_TRASH_FOLDER 8
#define ASK_TRASH_MULTIPLE_ITEM 9
#define ASK_CANT_TRASH_ITEM 10
#define ASK_OVERWRITE_FOLDER 11
BOOL SHELL_DeleteDirectoryW(HWND hwnd, LPCWSTR pwszDir, BOOL bShowUI);
BOOL SHELL_ConfirmYesNoW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir);
BOOL WINAPI _InsertMenuItemW (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState);
static __inline BOOL SHELL_OsIsUnicode(void)
{
/* if high-bit of version is 0, we are emulating NT */
return !(GetVersion() & 0x80000000);
}
#define __SHFreeAndNil(ptr) \
{\
SHFree(*ptr); \
*ptr = NULL; \
};
static __inline void __SHCloneStrA(char **target, const char *source)
{
*target = (char *)SHAlloc(strlen(source) + 1);
strcpy(*target, source);
}
static __inline void __SHCloneStrWtoA(char **target, const WCHAR *source)
{
int len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
*target = (char *)SHAlloc(len);
WideCharToMultiByte(CP_ACP, 0, source, -1, *target, len, NULL, NULL);
}
static __inline void __SHCloneStrW(WCHAR **target, const WCHAR *source)
{
*target = (WCHAR *)SHAlloc((lstrlenW(source) + 1) * sizeof(WCHAR) );
lstrcpyW(*target, source);
}
static __inline LPWSTR __SHCloneStrAtoW(WCHAR **target, const char *source)
{
int len = MultiByteToWideChar(CP_ACP, 0, source, -1, NULL, 0);
*target = (WCHAR *)SHAlloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, source, -1, *target, len);
return *target;
}
/* handle conversions */
#define HICON_16(h32) (LOWORD(h32))
#define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
#define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
#define HINSTANCE_16(h32) (LOWORD(h32))
extern WCHAR swShell32Name[MAX_PATH] DECLSPEC_HIDDEN;
BOOL UNIXFS_is_rooted_at_desktop(void) DECLSPEC_HIDDEN;
extern const GUID CLSID_UnixFolder DECLSPEC_HIDDEN;
extern const GUID CLSID_UnixDosFolder DECLSPEC_HIDDEN;
/* Default shell folder value registration */
HRESULT SHELL_RegisterShellFolders(void) DECLSPEC_HIDDEN;
/* Detect Shell Links */
BOOL SHELL_IsShortcut(LPCITEMIDLIST) DECLSPEC_HIDDEN;
HPROPSHEETPAGE SH_CreatePropertySheetPage(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle);
HPROPSHEETPAGE SH_CreatePropertySheetPageEx(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam,
LPCWSTR pwszTitle, LPFNPSPCALLBACK Callback);
LPWSTR SH_FormatFileSizeWithBytes(PULARGE_INTEGER lpQwSize, LPWSTR pszBuf, UINT cchBuf);
HRESULT WINAPI DoRegisterServer(void);
HRESULT WINAPI DoUnregisterServer(void);
/* Property system */
static inline HRESULT
SHELL_CreateVariantBufferEx(VARIANT *pVar, UINT cb, VARTYPE vt)
{
SAFEARRAY *pSA = SafeArrayCreateVector(vt, 0, cb);
if (pSA)
{
V_VT(pVar) = VT_ARRAY | vt;
V_ARRAY(pVar) = pSA;
return S_OK;
}
return E_OUTOFMEMORY;
}
static inline HRESULT
SHELL_CreateVariantBuffer(VARIANT *pVar, UINT cb)
{
return SHELL_CreateVariantBufferEx(pVar, cb, VT_UI1);
}
static inline HRESULT
SHELL_InitVariantFromBuffer(VARIANT *pVar, const void *pData, UINT cb)
{
HRESULT hr = SHELL_CreateVariantBuffer(pVar, cb);
if (SUCCEEDED(hr))
CopyMemory(V_ARRAY(pVar)->pvData, pData, cb);
return hr;
}
static inline void*
SHELL_GetSafeArrayDataPtr(const SAFEARRAY *pSA, SIZE_T *pcb)
{
if (pSA->cDims != 1)
return NULL;
LONG lob, upb;
SafeArrayGetLBound((SAFEARRAY*)pSA, 1, &lob);
SafeArrayGetUBound((SAFEARRAY*)pSA, 1, &upb);
*pcb = (SIZE_T)(upb - lob) + 1;
return pSA->pvData;
}
static inline HRESULT
SHELL_VariantToBuffer(VARIANT *pVar, void *pData, SIZE_T cb)
{
if (V_VT(pVar) != (VT_ARRAY | VT_UI1))
return E_INVALIDARG;
SIZE_T cbArr;
void *pArrData = SHELL_GetSafeArrayDataPtr(V_ARRAY(pVar), &cbArr);
if (!pArrData || cbArr < cb)
return E_FAIL;
CopyMemory(pData, pArrData, cb);
return (cbArr > cb) ? S_FALSE : S_OK;
}
static inline HRESULT
SHELL_CreateSHDESCRIPTIONID(VARIANT *pVar, DWORD Id, const CLSID *pCLSID)
{
HRESULT hr = SHELL_CreateVariantBuffer(pVar, sizeof(SHDESCRIPTIONID));
if (SUCCEEDED(hr))
{
SHDESCRIPTIONID *pDID = (SHDESCRIPTIONID*)V_ARRAY(pVar)->pvData;
pDID->dwDescriptionId = Id;
pDID->clsid = *pCLSID;
}
return hr;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __WINE_SHELL_MAIN_H */