xref: /reactos/dll/win32/shell32/wine/shell32_main.h (revision 113b3d62)
1 /*
2  * 	internal Shell32 Library definitions
3  *
4  * Copyright 1998 Marcus Meissner
5  * Copyright 1998 Juergen Schmied (jsch)  *  <juergen.schmied@metronet.de>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 
22 #ifndef __WINE_SHELL_MAIN_H
23 #define __WINE_SHELL_MAIN_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "shell32_version.h"
30 
31 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
32 
33 /*******************************************
34 *  global SHELL32.DLL variables
35 */
36 extern HMODULE	huser32 DECLSPEC_HIDDEN;
37 extern HINSTANCE shell32_hInstance DECLSPEC_HIDDEN;
38 
39 BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
40 
41 /* Iconcache */
42 #define INVALID_INDEX -1
43 BOOL SIC_Initialize(void);
44 void SIC_Destroy(void) DECLSPEC_HIDDEN;
45 BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int * pIndex) DECLSPEC_HIDDEN;
46 INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags ) DECLSPEC_HIDDEN;
47 
48 /* Classes Root */
49 BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot) DECLSPEC_HIDDEN;
50 BOOL HCR_GetDefaultVerbW( HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) DECLSPEC_HIDDEN;
51 BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) DECLSPEC_HIDDEN;
52 BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int* picon_idx);
53 BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len) DECLSPEC_HIDDEN;
54 
55 #ifdef __REACTOS__
56 /* Current User */
57 BOOL HCU_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int* picon_idx) DECLSPEC_HIDDEN;
58 
59 /* Local Machine */
60 BOOL HLM_GetIconW(int reg_idx, LPWSTR szDest, DWORD len, int* picon_idx) DECLSPEC_HIDDEN;
61 #endif
62 
63 /* ANSI versions of above functions, supposed to go away as soon as they are not used anymore */
64 BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot) DECLSPEC_HIDDEN;
65 BOOL HCR_GetIconA(LPCSTR szClass, LPSTR szDest, LPCSTR sName, DWORD len, int* picon_idx);
66 BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len) DECLSPEC_HIDDEN;
67 
68 BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD dwAttributes) DECLSPEC_HIDDEN;
69 
70 DWORD WINAPI ParseFieldA(LPCSTR src, DWORD nField, LPSTR dst, DWORD len) DECLSPEC_HIDDEN;
71 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len) DECLSPEC_HIDDEN;
72 
73 /****************************************************************************
74  * Class constructors
75  */
76 HRESULT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl, PCUITEMID_CHILD_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject **dataObject);
77 HRESULT IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **enumerator);
78 
79 LPCLASSFACTORY	IClassFactory_Constructor(REFCLSID);
80 IContextMenu2 *	ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *aPidls, UINT uItemCount);
81 HRESULT WINAPI INewItem_Constructor(IUnknown * pUnkOuter, REFIID riif, LPVOID *ppv);
82 IContextMenu2 * ISvStaticItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, LPCITEMIDLIST *apidl, UINT cidl, HKEY hKey);
83 IContextMenu2 *	ISvBgCm_Constructor(LPSHELLFOLDER pSFParent, BOOL bDesktop);
84 HRESULT WINAPI CDefViewDual_Constructor(REFIID riid, LPVOID * ppvOut);
85 HRESULT WINAPI CShellDispatch_Constructor(REFIID riid, LPVOID * ppvOut);
86 
87 HRESULT WINAPI IShellLink_ConstructFromPath(WCHAR *path, REFIID riid, LPVOID *ppv);
88 HRESULT WINAPI IShellLink_ConstructFromFile(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv);
89 HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV);
90 HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN;
91 HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN;
92 
93 HRESULT CRegFolder_CreateInstance(const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName, REFIID riid, void **ppv);
94 
95 /* initialisation for FORMATETC */
96 #define InitFormatEtc(fe, cf, med) \
97 	{\
98 	(fe).cfFormat=cf;\
99 	(fe).dwAspect=DVASPECT_CONTENT;\
100 	(fe).ptd=NULL;\
101 	(fe).tymed=med;\
102 	(fe).lindex=-1;\
103 	};
104 
105 #define KeyStateToDropEffect(kst)\
106     ((((kst)&(MK_CONTROL|MK_SHIFT))==(MK_CONTROL|MK_SHIFT)) ? DROPEFFECT_LINK :\
107     (((kst)&(MK_CONTROL)) ? DROPEFFECT_COPY :\
108     (((kst)&(MK_SHIFT)) ? DROPEFFECT_MOVE :\
109     DROPEFFECT_NONE)))
110 
111 
112 HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
113 HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
114 HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
115 HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
116 
117 /* Change Notification */
118 void InitChangeNotifications(void) DECLSPEC_HIDDEN;
119 void FreeChangeNotifications(void) DECLSPEC_HIDDEN;
120 
121 /* file operation */
122 #define ASK_DELETE_FILE           1
123 #define ASK_DELETE_FOLDER         2
124 #define ASK_DELETE_MULTIPLE_ITEM  3
125 #define ASK_CREATE_FOLDER         4
126 #define ASK_OVERWRITE_FILE        5
127 #define ASK_DELETE_SELECTED       6
128 #define ASK_TRASH_FILE            7
129 #define ASK_TRASH_FOLDER          8
130 #define ASK_TRASH_MULTIPLE_ITEM   9
131 #define ASK_CANT_TRASH_ITEM      10
132 #define ASK_OVERWRITE_FOLDER     11
133 
134 BOOL SHELL_DeleteDirectoryW(HWND hwnd, LPCWSTR pwszDir, BOOL bShowUI);
135 BOOL SHELL_ConfirmYesNoW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir);
136 
137 void WINAPI _InsertMenuItemW (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
138 			UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState);
139 
140 static __inline BOOL SHELL_OsIsUnicode(void)
141 {
142     /* if high-bit of version is 0, we are emulating NT */
143     return !(GetVersion() & 0x80000000);
144 }
145 
146 #define __SHFreeAndNil(ptr) \
147 	{\
148 	  SHFree(*ptr); \
149 	  *ptr = NULL; \
150 	};
151 static __inline void __SHCloneStrA(char **target, const char *source)
152 {
153 	*target = (char *)SHAlloc(strlen(source) + 1);
154 	strcpy(*target, source);
155 }
156 
157 static __inline void __SHCloneStrWtoA(char **target, const WCHAR *source)
158 {
159 	int len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
160 	*target = (char *)SHAlloc(len);
161 	WideCharToMultiByte(CP_ACP, 0, source, -1, *target, len, NULL, NULL);
162 }
163 
164 static __inline void __SHCloneStrW(WCHAR **target, const WCHAR *source)
165 {
166 	*target = (WCHAR *)SHAlloc((lstrlenW(source) + 1) * sizeof(WCHAR) );
167 	lstrcpyW(*target, source);
168 }
169 
170 static __inline LPWSTR __SHCloneStrAtoW(WCHAR **target, const char *source)
171 {
172 	int len = MultiByteToWideChar(CP_ACP, 0, source, -1, NULL, 0);
173 	*target = (WCHAR *)SHAlloc(len * sizeof(WCHAR));
174 	MultiByteToWideChar(CP_ACP, 0, source, -1, *target, len);
175 	return *target;
176 }
177 
178 /* handle conversions */
179 #define HICON_16(h32)		(LOWORD(h32))
180 #define HICON_32(h16)		((HICON)(ULONG_PTR)(h16))
181 #define HINSTANCE_32(h16)	((HINSTANCE)(ULONG_PTR)(h16))
182 #define HINSTANCE_16(h32)	(LOWORD(h32))
183 
184 extern WCHAR swShell32Name[MAX_PATH] DECLSPEC_HIDDEN;
185 
186 BOOL UNIXFS_is_rooted_at_desktop(void) DECLSPEC_HIDDEN;
187 extern const GUID CLSID_UnixFolder DECLSPEC_HIDDEN;
188 extern const GUID CLSID_UnixDosFolder DECLSPEC_HIDDEN;
189 
190 /* Default shell folder value registration */
191 HRESULT SHELL_RegisterShellFolders(void) DECLSPEC_HIDDEN;
192 
193 /* Detect Shell Links */
194 BOOL SHELL_IsShortcut(LPCITEMIDLIST) DECLSPEC_HIDDEN;
195 
196 INT_PTR CALLBACK SH_FileGeneralDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
197 INT_PTR CALLBACK SH_FileVersionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
198 HPROPSHEETPAGE SH_CreatePropertySheetPage(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle);
199 BOOL SH_ShowDriveProperties(WCHAR *drive, IDataObject *pDataObj);
200 BOOL SH_ShowRecycleBinProperties(WCHAR sDrive);
201 BOOL SH_ShowPropertiesDialog(LPCWSTR pwszPath, IDataObject *pDataObj);
202 LPWSTR SH_FormatFileSizeWithBytes(PULARGE_INTEGER lpQwSize, LPWSTR pszBuf, UINT cchBuf);
203 
204 HRESULT WINAPI DoRegisterServer(void);
205 HRESULT WINAPI DoUnregisterServer(void);
206 
207 #ifdef __cplusplus
208 } /* extern "C" */
209 #endif
210 
211 #endif /* __WINE_SHELL_MAIN_H */
212