merged wine/dlls/shell32 and reactos/lib/shell32
[reactos.git] / reactos / lib / 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22 #ifndef __WINE_SHELL_MAIN_H
23 #define __WINE_SHELL_MAIN_H
24
25 #include <stdarg.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winnls.h"
32 #include "commctrl.h"
33 #include "docobj.h"
34 #include "undocshell.h"
35 #include "shlobj.h"
36 #include "shellapi.h"
37 #include "wine/windef16.h"
38 #include "wine/unicode.h"
39
40 /*******************************************
41 * global SHELL32.DLL variables
42 */
43 extern HMODULE huser32;
44 extern HINSTANCE shell32_hInstance;
45 extern HIMAGELIST ShellSmallIconList;
46 extern HIMAGELIST ShellBigIconList;
47 extern HDPA sic_hdpa;
48
49 /*******************************************
50 * pointer to functions dynamically loaded
51 */
52 extern void (WINAPI *pDLLInitComctl)(LPVOID);
53
54 BOOL WINAPI Shell_GetImageList(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
55
56 /* Iconcache */
57 #define INVALID_INDEX -1
58 BOOL SIC_Initialize(void);
59 void SIC_Destroy(void);
60 BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, UINT * pIndex);
61 INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex );
62
63 /* Classes Root */
64 BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, DWORD len, BOOL bPrependDot);
65 BOOL HCR_GetExecuteCommandW(LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len);
66 BOOL HCR_GetExecuteCommandExW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len );
67 BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr);
68 BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, LPDWORD dwNr);
69 BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len);
70
71 /* ANSI versions of above functions, supposed to go away as soon as they are not used anymore */
72 BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot);
73 BOOL HCR_GetExecuteCommandA(LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len);
74 BOOL HCR_GetExecuteCommandExA( HKEY hkeyClass, LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len );
75 BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr);
76 BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len);
77
78 BOOL HCR_GetFolderAttributes(REFIID riid, LPDWORD szDest);
79
80 INT_PTR CALLBACK AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
81 DWORD WINAPI ParseFieldA(LPCSTR src, DWORD nField, LPSTR dst, DWORD len);
82 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len);
83
84 /****************************************************************************
85 * Class constructors
86 */
87 LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST myPidl, LPCITEMIDLIST * apidl, UINT cidl);
88 LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT, const FORMATETC []);
89
90 LPCLASSFACTORY IClassFactory_Constructor(REFCLSID);
91 IContextMenu2 * ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, LPCITEMIDLIST *aPidls, UINT uItemCount);
92 IContextMenu2 * ISvBgCm_Constructor(LPSHELLFOLDER pSFParent);
93 LPSHELLVIEW IShellView_Constructor(LPSHELLFOLDER);
94
95 HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
96 HRESULT WINAPI IShellLink_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
97 HRESULT WINAPI IShellLink_ConstructFromFile(IUnknown * pUnkOuter, REFIID riid, LPCITEMIDLIST pidl, LPVOID * ppv);
98 HRESULT WINAPI ISF_Desktop_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
99 HRESULT WINAPI ISF_MyComputer_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
100 HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
101 HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV);
102 HRESULT WINAPI IControlPanel_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
103 HRESULT WINAPI CPanel_GetIconLocationA(LPITEMIDLIST pidl, LPSTR szIconFile, UINT cchMax, int* piIndex);
104 HRESULT WINAPI CPanel_GetIconLocationW(LPITEMIDLIST pidl, LPWSTR szIconFile, UINT cchMax, int* piIndex);
105 HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
106 HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
107
108 /* kind of enumidlist */
109 #define EIDL_DESK 0
110 #define EIDL_MYCOMP 1
111 #define EIDL_FILE 2
112 #define EIDL_CPANEL 3
113
114 LPENUMIDLIST IEnumIDList_Constructor(LPCSTR,DWORD,DWORD);
115
116 LPEXTRACTICONA IExtractIconA_Constructor(LPCITEMIDLIST);
117 LPEXTRACTICONW IExtractIconW_Constructor(LPCITEMIDLIST);
118 HRESULT CreateStreamOnFile (LPCWSTR pszFilename, DWORD grfMode, IStream ** ppstm);
119
120 /* FIXME: rename the functions when the shell32.dll has it's own exports namespace */
121 HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
122 HRESULT WINAPI SHELL32_DllCanUnloadNow(void);
123
124
125 /* menu merging */
126 #define MM_ADDSEPARATOR 0x00000001L
127 #define MM_SUBMENUSHAVEIDS 0x00000002L
128 HRESULT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags);
129
130 /* initialisation for FORMATETC */
131 #define InitFormatEtc(fe, cf, med) \
132 {\
133 (fe).cfFormat=cf;\
134 (fe).dwAspect=DVASPECT_CONTENT;\
135 (fe).ptd=NULL;\
136 (fe).tymed=med;\
137 (fe).lindex=-1;\
138 };
139
140 #define KeyStateToDropEffect(kst)\
141 (((kst) & MK_CONTROL) ?\
142 (((kst) & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY):\
143 DROPEFFECT_MOVE)
144
145 /* Systray */
146 BOOL SYSTRAY_Init(void);
147
148 /* OLE32 */
149 extern HINSTANCE hShellOle32;
150
151 extern HRESULT (WINAPI *pOleInitialize)(LPVOID reserved);
152 extern void (WINAPI *pOleUninitialize)(void);
153 extern HRESULT (WINAPI *pRegisterDragDrop)(HWND hwnd, IDropTarget* pDropTarget);
154 extern HRESULT (WINAPI *pRevokeDragDrop)(HWND hwnd);
155 extern HRESULT (WINAPI *pDoDragDrop)(LPDATAOBJECT,LPDROPSOURCE,DWORD,DWORD*);
156 extern void (WINAPI *pReleaseStgMedium)(STGMEDIUM* pmedium);
157 extern HRESULT (WINAPI *pOleSetClipboard)(IDataObject* pDataObj);
158 extern HRESULT (WINAPI *pOleGetClipboard)(IDataObject** ppDataObj);
159 extern HRESULT (WINAPI *pCoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv);
160
161 BOOL GetShellOle(void);
162
163 HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
164 HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
165 HGLOBAL RenderSHELLIDLISTOFFSET (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
166 HGLOBAL RenderFILECONTENTS (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
167 HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
168 HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
169 HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl);
170 HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags);
171
172 /* Change Notification */
173 void InitChangeNotifications(void);
174 void FreeChangeNotifications(void);
175
176 /* file operation */
177 #define ASK_DELETE_FILE 1
178 #define ASK_DELETE_FOLDER 2
179 #define ASK_DELETE_MULTIPLE_ITEM 3
180 #define ASK_CREATE_FOLDER 4
181 #define ASK_OVERWRITE_FILE 5
182
183 BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI);
184 BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI);
185 BOOL SHELL_ConfirmDialog(int nKindOfDialog, LPCSTR szDir);
186
187 /* 16-bit functions */
188 void WINAPI DragAcceptFiles16(HWND16 hWnd, BOOL16 b);
189 UINT16 WINAPI DragQueryFile16(HDROP16 hDrop, WORD wFile, LPSTR lpszFile, WORD wLength);
190 void WINAPI DragFinish16(HDROP16 h);
191 BOOL16 WINAPI DragQueryPoint16(HDROP16 hDrop, POINT16 *p);
192 HINSTANCE16 WINAPI ShellExecute16(HWND16,LPCSTR,LPCSTR,LPCSTR,LPCSTR,INT16);
193 HICON16 WINAPI ExtractIcon16(HINSTANCE16,LPCSTR,UINT16);
194 HICON16 WINAPI ExtractAssociatedIcon16(HINSTANCE16,LPSTR,LPWORD);
195 HICON16 WINAPI ExtractIconEx16 ( LPCSTR, INT16, HICON16 *, HICON16 *, UINT16 );
196 HINSTANCE16 WINAPI FindExecutable16(LPCSTR,LPCSTR,LPSTR);
197 HGLOBAL16 WINAPI InternalExtractIcon16(HINSTANCE16,LPCSTR,UINT16,WORD);
198 BOOL16 WINAPI ShellAbout16(HWND16,LPCSTR,LPCSTR,HICON16);
199 BOOL16 WINAPI AboutDlgProc16(HWND16,UINT16,WPARAM16,LPARAM);
200
201 inline static BOOL SHELL_OsIsUnicode(void)
202 {
203 /* if high-bit of version is 0, we are emulating NT */
204 return !(GetVersion() & 0x80000000);
205 }
206
207 #define __SHFreeAndNil(ptr) \
208 {\
209 SHFree(*ptr); \
210 *ptr = NULL; \
211 };
212 inline static void __SHCloneStrA(char ** target,const char * source)
213 {
214 *target = SHAlloc(strlen(source)+1);
215 strcpy(*target, source);
216 }
217
218 inline static void __SHCloneStrWtoA(char ** target, const WCHAR * source)
219 {
220 int len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
221 *target = SHAlloc(len);
222 WideCharToMultiByte(CP_ACP, 0, source, -1, *target, len, NULL, NULL);
223 }
224
225 inline static void __SHCloneStrW(WCHAR ** target, const WCHAR * source)
226 {
227 *target = SHAlloc( (strlenW(source)+1) * sizeof(WCHAR) );
228 strcpyW(*target, source);
229 }
230
231 inline static WCHAR * __SHCloneStrAtoW(WCHAR ** target, const char * source)
232 {
233 int len = MultiByteToWideChar(CP_ACP, 0, source, -1, NULL, 0);
234 *target = SHAlloc(len*sizeof(WCHAR));
235 MultiByteToWideChar(CP_ACP, 0, source, -1, *target, len);
236 return *target;
237 }
238
239 /* handle conversions */
240 #define HICON_16(h32) (LOWORD(h32))
241 #define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
242 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
243 #define HINSTANCE_16(h32) (LOWORD(h32))
244
245 typedef UINT (*SHELL_ExecuteA1632)(char *lpCmd, void *env, LPSHELLEXECUTEINFOA sei, BOOL shWait);
246 BOOL WINAPI ShellExecuteExA32 (LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execfunc);
247 typedef UINT (*SHELL_ExecuteW32)(WCHAR *lpCmd, void *env, LPSHELLEXECUTEINFOW sei, BOOL shWait);
248 BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc);
249
250 extern WCHAR swShell32Name[MAX_PATH];
251 extern char sShell32Name[MAX_PATH];
252
253 int WINAPI RestartDialog(HWND hwndOwner, LPCSTR lpstrReason, UINT uFlags);
254 int WINAPI RestartDialogEx(HWND hwndOwner, LPCWSTR lpwstrReason, UINT uFlags, UINT uReason);
255
256 #endif