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