[USB]
[reactos.git] / reactos / dll / win32 / shell32 / shell32_main.h
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 #include <stdarg.h>
26 #include <shlobj.h>
27
28 /*
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winnls.h"
34 #include "commctrl.h"
35 #include "objbase.h"
36 #include "docobj.h"
37 #include "undocshell.h"
38 #include "shlobj.h"
39 #include "shellapi.h"
40 #include "wine/windef16.h"
41 */
42 #include "wine/unicode.h"
43
44
45 /*******************************************
46 * global SHELL32.DLL variables
47 */
48 extern HMODULE huser32;
49 extern HINSTANCE shell32_hInstance;
50 extern HIMAGELIST ShellSmallIconList;
51 extern HIMAGELIST ShellBigIconList;
52
53 extern "C" BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
54
55 /* Iconcache */
56 #define INVALID_INDEX -1
57 BOOL SIC_Initialize(void);
58 void SIC_Destroy(void);
59 BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int * pIndex);
60 INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags );
61
62 /* Classes Root */
63 BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot);
64 BOOL HCR_GetDefaultVerbW( HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len );
65 BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len );
66 BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_idx);
67 BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, int* picon_idx);
68 BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len);
69
70 /* ANSI versions of above functions, supposed to go away as soon as they are not used anymore */
71 BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot);
72 BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx);
73 BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len);
74
75 BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD dwAttributes);
76
77 INT_PTR CALLBACK AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
78 DWORD WINAPI ParseFieldA(LPCSTR src, DWORD nField, LPSTR dst, DWORD len);
79 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len);
80
81 /****************************************************************************
82 * Class constructors
83 */
84 HRESULT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl, LPCITEMIDLIST * apidl, UINT cidl, IDataObject **dataObject);
85 HRESULT IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **enumerator);
86
87 LPCLASSFACTORY IClassFactory_Constructor(REFCLSID);
88 IContextMenu2 * ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *aPidls, UINT uItemCount);
89 HRESULT WINAPI INewItem_Constructor(IUnknown * pUnkOuter, REFIID riif, LPVOID *ppv);
90 IContextMenu2 * ISvStaticItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, LPCITEMIDLIST *apidl, UINT cidl, HKEY hKey);
91 IContextMenu2 * ISvBgCm_Constructor(LPSHELLFOLDER pSFParent, BOOL bDesktop);
92 HRESULT WINAPI IShellView_Constructor(IShellFolder *pFolder, IShellView **newView);
93
94 HRESULT WINAPI IShellLink_ConstructFromFile(IUnknown * pUnkOuter, REFIID riid, LPCITEMIDLIST pidl, LPVOID * ppv);
95 HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV);
96 extern HRESULT CPanel_GetIconLocationW(LPCITEMIDLIST, LPWSTR, UINT, int*);
97 HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
98 HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
99
100 LPEXTRACTICONA IExtractIconA_Constructor(LPCITEMIDLIST);
101 LPEXTRACTICONW IExtractIconW_Constructor(LPCITEMIDLIST);
102
103 /* initialisation for FORMATETC */
104 #define InitFormatEtc(fe, cf, med) \
105 {\
106 (fe).cfFormat=cf;\
107 (fe).dwAspect=DVASPECT_CONTENT;\
108 (fe).ptd=NULL;\
109 (fe).tymed=med;\
110 (fe).lindex=-1;\
111 };
112
113 #define KeyStateToDropEffect(kst)\
114 ((((kst)&(MK_CONTROL|MK_SHIFT))==(MK_CONTROL|MK_SHIFT)) ? DROPEFFECT_LINK :\
115 (((kst)&(MK_CONTROL|MK_SHIFT)) ? DROPEFFECT_COPY :\
116 DROPEFFECT_MOVE))
117
118
119 HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
120 HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
121 HGLOBAL RenderSHELLIDLISTOFFSET (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
122 HGLOBAL RenderFILECONTENTS (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
123 HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
124 HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
125 HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
126 HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags);
127
128 /* Change Notification */
129 void InitChangeNotifications(void);
130 void FreeChangeNotifications(void);
131 void InitIconOverlays(void);
132
133 /* file operation */
134 #define ASK_DELETE_FILE 1
135 #define ASK_DELETE_FOLDER 2
136 #define ASK_DELETE_MULTIPLE_ITEM 3
137 #define ASK_CREATE_FOLDER 4
138 #define ASK_OVERWRITE_FILE 5
139 #define ASK_DELETE_SELECTED 6
140 #define ASK_TRASH_FILE 7
141 #define ASK_TRASH_FOLDER 8
142 #define ASK_TRASH_MULTIPLE_ITEM 9
143 #define ASK_CANT_TRASH_ITEM 10
144 #define ASK_OVERWRITE_FOLDER 11
145
146 BOOL SHELL_DeleteDirectoryW(HWND hwnd, LPCWSTR pwszDir, BOOL bShowUI);
147 BOOL SHELL_ConfirmYesNoW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir);
148
149 void WINAPI _InsertMenuItemW (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
150 UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState);
151
152 static BOOL __inline SHELL_OsIsUnicode(void)
153 {
154 /* if high-bit of version is 0, we are emulating NT */
155 return !(GetVersion() & 0x80000000);
156 }
157
158 #define __SHFreeAndNil(ptr) \
159 {\
160 SHFree(*ptr); \
161 *ptr = NULL; \
162 };
163 static void __inline __SHCloneStrA(char **target, const char *source)
164 {
165 *target = (char *)SHAlloc(strlen(source) + 1);
166 strcpy(*target, source);
167 }
168
169 static void __inline __SHCloneStrWtoA(char **target, const WCHAR *source)
170 {
171 int len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
172 *target = (char *)SHAlloc(len);
173 WideCharToMultiByte(CP_ACP, 0, source, -1, *target, len, NULL, NULL);
174 }
175
176 static void __inline __SHCloneStrW(WCHAR **target, const WCHAR *source)
177 {
178 *target = (WCHAR *)SHAlloc((lstrlenW(source) + 1) * sizeof(WCHAR) );
179 lstrcpyW(*target, source);
180 }
181
182 static LPWSTR __inline __SHCloneStrAtoW(WCHAR **target, const char *source)
183 {
184 int len = MultiByteToWideChar(CP_ACP, 0, source, -1, NULL, 0);
185 *target = (WCHAR *)SHAlloc(len * sizeof(WCHAR));
186 MultiByteToWideChar(CP_ACP, 0, source, -1, *target, len);
187 return *target;
188 }
189
190 /* handle conversions */
191 #define HICON_16(h32) (LOWORD(h32))
192 #define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
193 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
194 #define HINSTANCE_16(h32) (LOWORD(h32))
195
196 typedef UINT_PTR (*SHELL_ExecuteW32)(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
197 const SHELLEXECUTEINFOW *sei, LPSHELLEXECUTEINFOW sei_out);
198
199 BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc);
200
201 extern WCHAR swShell32Name[MAX_PATH];
202
203 BOOL UNIXFS_is_rooted_at_desktop(void);
204 extern const GUID CLSID_UnixFolder;
205 extern const GUID CLSID_UnixDosFolder;
206
207 /* Default shell folder value registration */
208 EXTERN_C HRESULT SHELL_RegisterShellFolders(void);
209
210 /* Detect Shell Links */
211 BOOL SHELL_IsShortcut(LPCITEMIDLIST);
212
213 INT_PTR CALLBACK SH_FileGeneralDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
214 INT_PTR CALLBACK SH_FileVersionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
215 HPROPSHEETPAGE SH_CreatePropertySheetPage(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle);
216 BOOL SH_ShowDriveProperties(WCHAR *drive, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl);
217 BOOL SH_ShowRecycleBinProperties(WCHAR sDrive);
218 BOOL SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl);
219 BOOL SH_ShowFolderProperties(LPWSTR pwszFolder, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl);
220 LPWSTR SH_FormatFileSizeWithBytes(PULARGE_INTEGER lpQwSize, LPWSTR pszBuf, UINT cchBuf);
221
222 EXTERN_C HRESULT WINAPI DoRegisterServer(void);
223 EXTERN_C HRESULT WINAPI DoUnregisterServer(void);
224
225 #endif