1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW Windows headers
5  *
6  * Authors: Stewart Gordon
7  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
8  * Source: $(DRUNTIMESRC core/sys/windows/_shellapi.d)
9  */
10 module core.sys.windows.shellapi;
11 version (Windows):
12 
13 version (ANSI) {} else version = Unicode;
14 pragma(lib, "shell32");
15 
16 import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.basetyps;
17 
18 enum : UINT {
19     ABE_LEFT,
20     ABE_TOP,
21     ABE_RIGHT,
22     ABE_BOTTOM // = 3
23 }
24 
25 enum : UINT {
26     ABS_AUTOHIDE    = 1,
27     ABS_ALWAYSONTOP
28 }
29 
30 enum ULONG
31     SEE_MASK_CLASSNAME      =        1,
32     SEE_MASK_CLASSKEY       =        3,
33     SEE_MASK_IDLIST         =        4,
34     SEE_MASK_INVOKEIDLIST   =       12,
35     SEE_MASK_ICON           = 0x000010,
36     SEE_MASK_HOTKEY         = 0x000020,
37     SEE_MASK_NOCLOSEPROCESS = 0x000040,
38     SEE_MASK_CONNECTNETDRV  = 0x000080,
39     SEE_MASK_FLAG_DDEWAIT   = 0x000100,
40     SEE_MASK_DOENVSUBST     = 0x000200,
41     SEE_MASK_FLAG_NO_UI     = 0x000400,
42     SEE_MASK_NO_CONSOLE     = 0x008000,
43     SEE_MASK_UNICODE        = 0x010000,
44     SEE_MASK_ASYNCOK        = 0x100000,
45     SEE_MASK_HMONITOR       = 0x200000;
46 
47 enum : DWORD {
48     ABM_NEW,
49     ABM_REMOVE,
50     ABM_QUERYPOS,
51     ABM_SETPOS,
52     ABM_GETSTATE,
53     ABM_GETTASKBARPOS,
54     ABM_ACTIVATE,
55     ABM_GETAUTOHIDEBAR,
56     ABM_SETAUTOHIDEBAR,
57     ABM_WINDOWPOSCHANGED // = 9
58 }
59 
60 static if (_WIN32_WINNT >= 0x501) {
61 enum DWORD ABM_SETSTATE = 10;
62 }
63 
64 enum : UINT {
65     ABN_STATECHANGE,
66     ABN_POSCHANGED,
67     ABN_FULLSCREENAPP,
68     ABN_WINDOWARRANGE
69 }
70 
71 enum : DWORD {
72     NIM_ADD,
73     NIM_MODIFY,
74     NIM_DELETE
75 }
76 
77 static if (_WIN32_IE >= 0x500) {
78 enum NOTIFYICON_VERSION = 3;
79 
80     enum : DWORD {
81         NIM_SETFOCUS = 3,
82         NIM_SETVERSION
83     }
84 }
85 
86 enum UINT
87     NIF_MESSAGE = 1,
88     NIF_ICON    = 2,
89     NIF_TIP     = 4,
90     NIF_STATE   = 8;
91 
92 static if (_WIN32_IE >= 0x500) {
93 enum UINT NIF_INFO = 0x00000010;
94 }
95 
96 static if (_WIN32_IE >= 0x600) {
97 enum UINT NIF_GUID = 0x00000020;
98 }
99 
100 static if (_WIN32_IE >= 0x500) {
101     enum : DWORD {
102         NIIF_NONE,
103         NIIF_INFO,
104         NIIF_WARNING,
105         NIIF_ERROR
106     }
107 }
108 
109 static if (_WIN32_IE >= 0x600) {
110     enum : DWORD {
111         NIIF_ICON_MASK = 15,
112         NIIF_NOSOUND
113     }
114 }
115 
116 enum DWORD
117     NIS_HIDDEN     = 1,
118     NIS_SHAREDICON = 2;
119 
120 enum HINSTANCE
121     SE_ERR_FNF             = cast(HINSTANCE)  2,
122     SE_ERR_PNF             = cast(HINSTANCE)  3,
123     SE_ERR_ACCESSDENIED    = cast(HINSTANCE)  5,
124     SE_ERR_OOM             = cast(HINSTANCE)  8,
125     SE_ERR_DLLNOTFOUND     = cast(HINSTANCE) 32,
126     SE_ERR_SHARE           = cast(HINSTANCE) 26,
127     SE_ERR_ASSOCINCOMPLETE = cast(HINSTANCE) 27,
128     SE_ERR_DDETIMEOUT      = cast(HINSTANCE) 28,
129     SE_ERR_DDEFAIL         = cast(HINSTANCE) 29,
130     SE_ERR_DDEBUSY         = cast(HINSTANCE) 30,
131     SE_ERR_NOASSOC         = cast(HINSTANCE) 31;
132 
133 enum : UINT {
134     FO_MOVE = 1,
135     FO_COPY,
136     FO_DELETE,
137     FO_RENAME
138 }
139 
140 enum FILEOP_FLAGS
141     FOF_MULTIDESTFILES        = 0x0001,
142     FOF_CONFIRMMOUSE          = 0x0002,
143     FOF_SILENT                = 0x0004,
144     FOF_RENAMEONCOLLISION     = 0x0008,
145     FOF_NOCONFIRMATION        = 0x0010,
146     FOF_WANTMAPPINGHANDLE     = 0x0020,
147     FOF_ALLOWUNDO             = 0x0040,
148     FOF_FILESONLY             = 0x0080,
149     FOF_SIMPLEPROGRESS        = 0x0100,
150     FOF_NOCONFIRMMKDIR        = 0x0200,
151     FOF_NOERRORUI             = 0x0400,
152     FOF_NOCOPYSECURITYATTRIBS = 0x0800;
153 
154 // these are not documented on the MSDN site
155 enum {
156     PO_DELETE     = 19,
157     PO_RENAME     = 20,
158     PO_PORTCHANGE = 32,
159     PO_REN_PORT   = 52
160 }
161 
162 enum UINT
163     SHGFI_LARGEICON         = 0x000000,
164     SHGFI_SMALLICON         = 0x000001,
165     SHGFI_OPENICON          = 0x000002,
166     SHGFI_SHELLICONSIZE     = 0x000004,
167     SHGFI_PIDL              = 0x000008,
168     SHGFI_USEFILEATTRIBUTES = 0x000010,
169     SHGFI_ICON              = 0x000100,
170     SHGFI_DISPLAYNAME       = 0x000200,
171     SHGFI_TYPENAME          = 0x000400,
172     SHGFI_ATTRIBUTES        = 0x000800,
173     SHGFI_ICONLOCATION      = 0x001000,
174     SHGFI_EXETYPE           = 0x002000,
175     SHGFI_SYSICONINDEX      = 0x004000,
176     SHGFI_LINKOVERLAY       = 0x008000,
177     SHGFI_SELECTED          = 0x010000,
178     SHGFI_ATTR_SPECIFIED    = 0x020000;
179 
180 static if (_WIN32_IE >= 0x500) {
181 enum uint
182         SHGFI_ADDOVERLAYS   = 0x000020,
183         SHGFI_OVERLAYINDEX  = 0x000040;
184 }
185 
186 enum SHERB_NOCONFIRMATION = 1;
187 enum SHERB_NOPROGRESSUI   = 2;
188 enum SHERB_NOSOUND        = 4;
189 
190 alias WORD FILEOP_FLAGS, PRINTEROP_FLAGS;
191 mixin DECLARE_HANDLE!("HDROP");
192 
193 //align(2): // 1 in Win32, default in Win64
194 
195 struct APPBARDATA {
196     DWORD  cbSize = APPBARDATA.sizeof;
197     HWND   hWnd;
198     UINT   uCallbackMessage;
199     UINT   uEdge;
200     RECT   rc;
201     LPARAM lParam;
202 }
203 alias APPBARDATA* PAPPBARDATA;
204 
205 struct NOTIFYICONDATAA {
206     DWORD cbSize = NOTIFYICONDATAA.sizeof;
207     HWND  hWnd;
208     UINT  uID;
209     UINT  uFlags;
210     UINT  uCallbackMessage;
211     HICON hIcon;
212     static if (_WIN32_IE >= 0x500) {
213         CHAR[128] szTip = 0;
214         DWORD     dwState;
215         DWORD     dwStateMask;
216         CHAR[256] szInfo = 0;
217         union {
218             UINT  uTimeout;
219             UINT  uVersion;
220         }
221         CHAR[64]  szInfoTitle = 0;
222         DWORD     dwInfoFlags;
223     } else {
224         CHAR[64]  szTip = 0;
225     }
226     static if (_WIN32_IE >= 0x600) {
227         GUID      guidItem;
228     }
229 }
230 alias NOTIFYICONDATAA* PNOTIFYICONDATAA;
231 
232 struct NOTIFYICONDATAW {
233     DWORD cbSize = NOTIFYICONDATAW.sizeof;
234     HWND  hWnd;
235     UINT  uID;
236     UINT  uFlags;
237     UINT  uCallbackMessage;
238     HICON hIcon;
239     static if (_WIN32_IE >= 0x500) {
240         WCHAR[128] szTip = 0;
241         DWORD      dwState;
242         DWORD      dwStateMask;
243         WCHAR[256] szInfo = 0;
244         union {
245             UINT   uTimeout;
246             UINT   uVersion;
247         }
248         WCHAR[64]  szInfoTitle = 0;
249         DWORD      dwInfoFlags;
250     } else {
251         WCHAR[64]  szTip = 0;
252     }
253     static if (_WIN32_IE >= 0x600) {
254         GUID guidItem;
255     }
256 }
257 alias NOTIFYICONDATAW* PNOTIFYICONDATAW;
258 
259 struct SHELLEXECUTEINFOA {
260     DWORD     cbSize = SHELLEXECUTEINFOA.sizeof;
261     ULONG     fMask;
262     HWND      hwnd;
263     LPCSTR    lpVerb;
264     LPCSTR    lpFile;
265     LPCSTR    lpParameters;
266     LPCSTR    lpDirectory;
267     int       nShow;
268     HINSTANCE hInstApp;
269     PVOID     lpIDList;
270     LPCSTR    lpClass;
271     HKEY      hkeyClass;
272     DWORD     dwHotKey;
273     HANDLE    hIcon;
274     HANDLE    hProcess;
275 }
276 alias SHELLEXECUTEINFOA* LPSHELLEXECUTEINFOA;
277 
278 struct SHELLEXECUTEINFOW {
279     DWORD     cbSize = SHELLEXECUTEINFOW.sizeof;
280     ULONG     fMask;
281     HWND      hwnd;
282     LPCWSTR   lpVerb;
283     LPCWSTR   lpFile;
284     LPCWSTR   lpParameters;
285     LPCWSTR   lpDirectory;
286     int       nShow;
287     HINSTANCE hInstApp;
288     PVOID     lpIDList;
289     LPCWSTR   lpClass;
290     HKEY      hkeyClass;
291     DWORD     dwHotKey;
292     HANDLE    hIcon;
293     HANDLE    hProcess;
294 }
295 alias SHELLEXECUTEINFOW* LPSHELLEXECUTEINFOW;
296 
297 align(1) struct SHFILEOPSTRUCTA {
298 align(1):
299     HWND         hwnd;
300     UINT         wFunc;
301     version (Win64)
302         WORD     _padding1;
303     LPCSTR       pFrom;
304     LPCSTR       pTo;
305     FILEOP_FLAGS fFlags;
306     version (Win64)
307         DWORD     _padding2;
308     BOOL         fAnyOperationsAborted;
309     PVOID        hNameMappings;
310     LPCSTR       lpszProgressTitle;
311 }
312 alias SHFILEOPSTRUCTA* LPSHFILEOPSTRUCTA;
313 
314 align(1) struct SHFILEOPSTRUCTW {
315 align(1):
316     HWND         hwnd;
317     UINT         wFunc;
318     version (Win64)
319         DWORD     _padding1;
320     LPCWSTR      pFrom;
321     LPCWSTR      pTo;
322     FILEOP_FLAGS fFlags;
323     version (Win64)
324         WORD     _padding2;
325     BOOL         fAnyOperationsAborted;
326     PVOID        hNameMappings;
327     LPCWSTR      lpszProgressTitle;
328 }
329 alias SHFILEOPSTRUCTW* LPSHFILEOPSTRUCTW;
330 
331 struct SHFILEINFOA {
332     HICON          hIcon;
333     int            iIcon;
334     DWORD          dwAttributes;
335     CHAR[MAX_PATH] szDisplayName = 0;
336     CHAR[80]       szTypeName = 0;
337 }
338 
339 struct SHFILEINFOW {
340     HICON           hIcon;
341     int             iIcon;
342     DWORD           dwAttributes;
343     WCHAR[MAX_PATH] szDisplayName = 0;
344     WCHAR[80]       szTypeName = 0;
345 }
346 
347 align(1) struct SHQUERYRBINFO {
348 align(1):
349     DWORD cbSize = SHQUERYRBINFO.sizeof;
350     version (Win64)
351         DWORD _padding;
352     long  i64Size;
353     long  i64NumItems;
354 }
355 alias SHQUERYRBINFO* LPSHQUERYRBINFO;
356 
357 extern (Windows) nothrow @nogc {
358     LPWSTR* CommandLineToArgvW(LPCWSTR, int*);
359     void DragAcceptFiles(HWND, BOOL);
360     void DragFinish(HDROP);
361     UINT DragQueryFileA(HDROP, UINT, LPSTR, UINT);
362     UINT DragQueryFileW(HDROP, UINT, LPWSTR, UINT);
363     BOOL DragQueryPoint(HDROP, LPPOINT);
364     HICON DuplicateIcon(HINSTANCE, HICON);
365     HICON ExtractAssociatedIconA(HINSTANCE, LPCSTR, PWORD);
366     HICON ExtractAssociatedIconW(HINSTANCE, LPCWSTR, PWORD);
367     HICON ExtractIconA(HINSTANCE, LPCSTR, UINT);
368     HICON ExtractIconW(HINSTANCE, LPCWSTR, UINT);
369     UINT ExtractIconExA(LPCSTR, int, HICON*, HICON*, UINT);
370     UINT ExtractIconExW(LPCWSTR, int, HICON*, HICON*, UINT);
371     HINSTANCE FindExecutableA(LPCSTR, LPCSTR, LPSTR);
372     HINSTANCE FindExecutableW(LPCWSTR, LPCWSTR, LPWSTR);
373     UINT_PTR SHAppBarMessage(DWORD, PAPPBARDATA);
374     BOOL Shell_NotifyIconA(DWORD, PNOTIFYICONDATAA);
375     BOOL Shell_NotifyIconW(DWORD, PNOTIFYICONDATAW);
376     int ShellAboutA(HWND, LPCSTR, LPCSTR, HICON);
377     int ShellAboutW(HWND, LPCWSTR, LPCWSTR, HICON);
378     HINSTANCE ShellExecuteA(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT);
379     HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, INT);
380     BOOL ShellExecuteExA(LPSHELLEXECUTEINFOA);
381     BOOL ShellExecuteExW(LPSHELLEXECUTEINFOW);
382     int SHFileOperationA(LPSHFILEOPSTRUCTA);
383     int SHFileOperationW(LPSHFILEOPSTRUCTW);
384     void SHFreeNameMappings(HANDLE);
385     DWORD_PTR SHGetFileInfoA(LPCSTR, DWORD, SHFILEINFOA*, UINT, UINT);
386     DWORD_PTR SHGetFileInfoW(LPCWSTR, DWORD, SHFILEINFOW*, UINT, UINT);
387     HRESULT SHQueryRecycleBinA(LPCSTR,  LPSHQUERYRBINFO);
388     HRESULT SHQueryRecycleBinW(LPCWSTR,  LPSHQUERYRBINFO);
389     HRESULT SHEmptyRecycleBinA(HWND, LPCSTR, DWORD);
390     HRESULT SHEmptyRecycleBinW(HWND, LPCWSTR, DWORD);
391 }
392 
393 version (Unicode) {
394     alias NOTIFYICONDATAW NOTIFYICONDATA;
395     alias SHELLEXECUTEINFOW SHELLEXECUTEINFO;
396     alias SHFILEOPSTRUCTW SHFILEOPSTRUCT;
397     alias SHFILEINFOW SHFILEINFO;
398     alias DragQueryFileW DragQueryFile;
399     alias ExtractAssociatedIconW ExtractAssociatedIcon;
400     alias ExtractIconW ExtractIcon;
401     alias ExtractIconExW ExtractIconEx;
402     alias FindExecutableW FindExecutable;
403     alias Shell_NotifyIconW Shell_NotifyIcon;
404     alias ShellAboutW ShellAbout;
405     alias ShellExecuteW ShellExecute;
406     alias ShellExecuteExW ShellExecuteEx;
407     alias SHFileOperationW SHFileOperation;
408     alias SHGetFileInfoW SHGetFileInfo;
409     alias SHQueryRecycleBinW SHQueryRecycleBin;
410     alias SHEmptyRecycleBinW SHEmptyRecycleBin;
411 } else {
412     alias NOTIFYICONDATAA NOTIFYICONDATA;
413     alias SHELLEXECUTEINFOA SHELLEXECUTEINFO;
414     alias SHFILEOPSTRUCTA SHFILEOPSTRUCT;
415     alias SHFILEINFOA SHFILEINFO;
416     alias DragQueryFileA DragQueryFile;
417     alias ExtractAssociatedIconA ExtractAssociatedIcon;
418     alias ExtractIconA ExtractIcon;
419     alias ExtractIconExA ExtractIconEx;
420     alias FindExecutableA FindExecutable;
421     alias Shell_NotifyIconA Shell_NotifyIcon;
422     alias ShellAboutA ShellAbout;
423     alias ShellExecuteA ShellExecute;
424     alias ShellExecuteExA ShellExecuteEx;
425     alias SHFileOperationA SHFileOperation;
426     alias SHGetFileInfoA SHGetFileInfo;
427     alias SHQueryRecycleBinA SHQueryRecycleBin;
428     alias SHEmptyRecycleBinA SHEmptyRecycleBin;
429 }
430 
431 alias NOTIFYICONDATA* PNOTIFYICONDATA;
432 alias SHELLEXECUTEINFO* LPSHELLEXECUTEINFO;
433 alias SHFILEOPSTRUCT* LPSHFILEOPSTRUCT;