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 win32.shellapi;
12 pragma(lib, "shell32.lib");
13 
14 private import win32.w32api, win32.windef, win32.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 (WINVER >= 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(HANDLE)  2,
120 	SE_ERR_PNF             = cast(HANDLE)  3,
121 	SE_ERR_ACCESSDENIED    = cast(HANDLE)  5,
122 	SE_ERR_OOM             = cast(HANDLE)  8,
123 	SE_ERR_DLLNOTFOUND     = cast(HANDLE) 32,
124 	SE_ERR_SHARE           = cast(HANDLE) 26,
125 	SE_ERR_ASSOCINCOMPLETE = cast(HANDLE) 27,
126 	SE_ERR_DDETIMEOUT      = cast(HANDLE) 28,
127 	SE_ERR_DDEFAIL         = cast(HANDLE) 29,
128 	SE_ERR_DDEBUSY         = cast(HANDLE) 30,
129 	SE_ERR_NOASSOC         = cast(HANDLE) 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 const SHERB_NOCONFIRMATION = 1;
179 const SHERB_NOPROGRESSUI   = 2;
180 const SHERB_NOSOUND        = 4;
181 
182 alias WORD FILEOP_FLAGS, PRINTEROP_FLAGS;
183 alias HANDLE HDROP;
184 
185 align(2):
186 
187 struct APPBARDATA {
188 	DWORD  cbSize = APPBARDATA.sizeof;
189 	HWND   hWnd;
190 	UINT   uCallbackMessage;
191 	UINT   uEdge;
192 	RECT   rc;
193 	LPARAM lParam;
194 }
195 alias APPBARDATA* PAPPBARDATA;
196 
197 struct NOTIFYICONDATAA {
198 	DWORD cbSize = NOTIFYICONDATAA.sizeof;
199 	HWND  hWnd;
200 	UINT  uID;
201 	UINT  uFlags;
202 	UINT  uCallbackMessage;
203 	HICON hIcon;
204 	static if (_WIN32_IE >= 0x500) {
205 		CHAR[128] szTip;
206 		DWORD     dwState;
207 		DWORD     dwStateMask;
208 		CHAR[256] szInfo;
209 		union {
210 			UINT  uTimeout;
211 			UINT  uVersion;
212 		}
213 		CHAR[64]  szInfoTitle;
214 		DWORD     dwInfoFlags;
215 	} else {
216 		CHAR[64]  szTip;
217 	}
218 	static if (_WIN32_IE >= 0x600) {
219 		GUID      guidItem;
220 	}
221 }
222 alias NOTIFYICONDATAA* PNOTIFYICONDATAA;
223 
224 struct NOTIFYICONDATAW {
225 	DWORD cbSize = NOTIFYICONDATAW.sizeof;
226 	HWND  hWnd;
227 	UINT  uID;
228 	UINT  uFlags;
229 	UINT  uCallbackMessage;
230 	HICON hIcon;
231 	static if (_WIN32_IE >= 0x500) {
232 		WCHAR[128] szTip;
233 		DWORD      dwState;
234 		DWORD      dwStateMask;
235 		WCHAR[256] szInfo;
236 		union {
237 			UINT   uTimeout;
238 			UINT   uVersion;
239 		}
240 		WCHAR[64]  szInfoTitle;
241 		DWORD      dwInfoFlags;
242 	} else {
243 		WCHAR[64]  szTip;
244 	}
245 	static if (_WIN32_IE >= 0x600) {
246 		GUID guidItem;
247 	}
248 }
249 alias NOTIFYICONDATAW* PNOTIFYICONDATAW;
250 
251 struct SHELLEXECUTEINFOA {
252 	DWORD     cbSize = SHELLEXECUTEINFOA.sizeof;
253 	ULONG     fMask;
254 	HWND      hwnd;
255 	LPCSTR    lpVerb;
256 	LPCSTR    lpFile;
257 	LPCSTR    lpParameters;
258 	LPCSTR    lpDirectory;
259 	int       nShow;
260 	HINSTANCE hInstApp;
261 	PVOID     lpIDList;
262 	LPCSTR    lpClass;
263 	HKEY      hkeyClass;
264 	DWORD     dwHotKey;
265 	HANDLE    hIcon;
266 	HANDLE    hProcess;
267 }
268 alias SHELLEXECUTEINFOA* LPSHELLEXECUTEINFOA;
269 
270 struct SHELLEXECUTEINFOW {
271 	DWORD     cbSize = SHELLEXECUTEINFOW.sizeof;
272 	ULONG     fMask;
273 	HWND      hwnd;
274 	LPCWSTR   lpVerb;
275 	LPCWSTR   lpFile;
276 	LPCWSTR   lpParameters;
277 	LPCWSTR   lpDirectory;
278 	int       nShow;
279 	HINSTANCE hInstApp;
280 	PVOID     lpIDList;
281 	LPCWSTR   lpClass;
282 	HKEY      hkeyClass;
283 	DWORD     dwHotKey;
284 	HANDLE    hIcon;
285 	HANDLE    hProcess;
286 }
287 alias SHELLEXECUTEINFOW* LPSHELLEXECUTEINFOW;
288 
289 struct SHFILEOPSTRUCTA {
290 	HWND         hwnd;
291 	UINT         wFunc;
292 	LPCSTR       pFrom;
293 	LPCSTR       pTo;
294 	FILEOP_FLAGS fFlags;
295 	BOOL         fAnyOperationsAborted;
296 	PVOID        hNameMappings;
297 	LPCSTR       lpszProgressTitle;
298 }
299 alias SHFILEOPSTRUCTA* LPSHFILEOPSTRUCTA;
300 
301 struct SHFILEOPSTRUCTW {
302 	HWND         hwnd;
303 	UINT         wFunc;
304 	LPCWSTR      pFrom;
305 	LPCWSTR      pTo;
306 	FILEOP_FLAGS fFlags;
307 	BOOL         fAnyOperationsAborted;
308 	PVOID        hNameMappings;
309 	LPCWSTR      lpszProgressTitle;
310 }
311 alias SHFILEOPSTRUCTW* LPSHFILEOPSTRUCTW;
312 
313 struct SHFILEINFOA {
314 	HICON          hIcon;
315 	int            iIcon;
316 	DWORD          dwAttributes;
317 	CHAR[MAX_PATH] szDisplayName;
318 	CHAR[80]       szTypeName;
319 }
320 
321 struct SHFILEINFOW {
322 	HICON           hIcon;
323 	int             iIcon;
324 	DWORD           dwAttributes;
325 	WCHAR[MAX_PATH] szDisplayName;
326 	WCHAR[80]       szTypeName;
327 }
328 
329 struct SHQUERYRBINFO {
330 	DWORD cbSize = SHQUERYRBINFO.sizeof;
331 	long  i64Size;
332 	long  i64NumItems;
333 }
334 alias SHQUERYRBINFO* LPSHQUERYRBINFO;
335 
336 extern (Windows) {
337 	LPWSTR* CommandLineToArgvW(LPCWSTR, int*);
338 	void DragAcceptFiles(HWND, BOOL);
339 	void DragFinish(HDROP);
340 	UINT DragQueryFileA(HDROP, UINT, LPSTR, UINT);
341 	UINT DragQueryFileW(HDROP, UINT, LPWSTR, UINT);
342 	BOOL DragQueryPoint(HDROP, LPPOINT);
343 	HICON DuplicateIcon(HINSTANCE, HICON);
344 	HICON ExtractAssociatedIconA(HINSTANCE, LPCSTR, PWORD);
345 	HICON ExtractAssociatedIconW(HINSTANCE, LPCWSTR, PWORD);
346 	HICON ExtractIconA(HINSTANCE, LPCSTR, UINT);
347 	HICON ExtractIconW(HINSTANCE, LPCWSTR, UINT);
348 	UINT ExtractIconExA(LPCSTR, int, HICON*, HICON*, UINT);
349 	UINT ExtractIconExW(LPCWSTR, int, HICON*, HICON*, UINT);
350 	HINSTANCE FindExecutableA(LPCSTR, LPCSTR, LPSTR);
351 	HINSTANCE FindExecutableW(LPCWSTR, LPCWSTR, LPWSTR);
352 	UINT SHAppBarMessage(DWORD, PAPPBARDATA);
353 	BOOL Shell_NotifyIconA(DWORD, PNOTIFYICONDATAA);
354 	BOOL Shell_NotifyIconW(DWORD, PNOTIFYICONDATAW);
355 	int ShellAboutA(HWND, LPCSTR, LPCSTR, HICON);
356 	int ShellAboutW(HWND, LPCWSTR, LPCWSTR, HICON);
357 	HINSTANCE ShellExecuteA(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT);
358 	HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, INT);
359 	BOOL ShellExecuteExA(LPSHELLEXECUTEINFOA);
360 	BOOL ShellExecuteExW(LPSHELLEXECUTEINFOW);
361 	int SHFileOperationA(LPSHFILEOPSTRUCTA);
362 	int SHFileOperationW(LPSHFILEOPSTRUCTW);
363 	void SHFreeNameMappings(HANDLE);
364 	DWORD SHGetFileInfoA(LPCSTR, DWORD, SHFILEINFOA*, UINT, UINT);
365 	DWORD SHGetFileInfoW(LPCWSTR, DWORD, SHFILEINFOW*, UINT, UINT);
366 	HRESULT SHQueryRecycleBinA(LPCSTR,  LPSHQUERYRBINFO);
367 	HRESULT SHQueryRecycleBinW(LPCWSTR,  LPSHQUERYRBINFO);
368 	HRESULT SHEmptyRecycleBinA(HWND, LPCSTR, DWORD);
369 	HRESULT SHEmptyRecycleBinW(HWND, LPCWSTR, DWORD);
370 }
371 
372 version (Unicode) {
373 	alias NOTIFYICONDATAW NOTIFYICONDATA;
374 	alias SHELLEXECUTEINFOW SHELLEXECUTEINFO;
375 	alias SHFILEOPSTRUCTW SHFILEOPSTRUCT;
376 	alias SHFILEINFOW SHFILEINFO;
377 	alias DragQueryFileW DragQueryFile;
378 	alias ExtractAssociatedIconW ExtractAssociatedIcon;
379 	alias ExtractIconW ExtractIcon;
380 	alias ExtractIconExW ExtractIconEx;
381 	alias FindExecutableW FindExecutable;
382 	alias Shell_NotifyIconW Shell_NotifyIcon;
383 	alias ShellAboutW ShellAbout;
384 	alias ShellExecuteW ShellExecute;
385 	alias ShellExecuteExW ShellExecuteEx;
386 	alias SHFileOperationW SHFileOperation;
387 	alias SHGetFileInfoW SHGetFileInfo;
388 	alias SHQueryRecycleBinW SHQueryRecycleBin;
389 	alias SHEmptyRecycleBinW SHEmptyRecycleBin;
390 } else {
391 	alias NOTIFYICONDATAA NOTIFYICONDATA;
392 	alias SHELLEXECUTEINFOA SHELLEXECUTEINFO;
393 	alias SHFILEOPSTRUCTA SHFILEOPSTRUCT;
394 	alias SHFILEINFOA SHFILEINFO;
395 	alias DragQueryFileA DragQueryFile;
396 	alias ExtractAssociatedIconA ExtractAssociatedIcon;
397 	alias ExtractIconA ExtractIcon;
398 	alias ExtractIconExA ExtractIconEx;
399 	alias FindExecutableA FindExecutable;
400 	alias Shell_NotifyIconA Shell_NotifyIcon;
401 	alias ShellAboutA ShellAbout;
402 	alias ShellExecuteA ShellExecute;
403 	alias ShellExecuteExA ShellExecuteEx;
404 	alias SHFileOperationA SHFileOperation;
405 	alias SHGetFileInfoA SHGetFileInfo;
406 	alias SHQueryRecycleBinA SHQueryRecycleBin;
407 	alias SHEmptyRecycleBinA SHEmptyRecycleBin;
408 }
409 
410 alias NOTIFYICONDATA* PNOTIFYICONDATA;
411 alias SHELLEXECUTEINFO* LPSHELLEXECUTEINFO;
412 alias SHFILEOPSTRUCT* LPSHFILEOPSTRUCT;