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