1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW API for MS-Windows 4.0
5  *
6  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
7  * Source: $(DRUNTIMESRC src/core/sys/windows/_shlobj.d)
8  */
9 module core.sys.windows.shlobj;
version(Windows)10 version (Windows):
11 
12 version (ANSI) {} else version = Unicode;
13 pragma(lib, "shell32");
14 
15 // TODO: fix bitfields
16 // TODO: CMIC_VALID_SEE_FLAGS
17 // SHGetFolderPath in shfolder.dll on W9x, NT4, also in shell32.dll on W2K
18 
19 import core.sys.windows.commctrl, core.sys.windows.ole2, core.sys.windows.shlguid, core.sys.windows.shellapi;
20 private import core.sys.windows.prsht, core.sys.windows.unknwn, core.sys.windows.w32api, core.sys.windows.winbase,
21   core.sys.windows.winnt, core.sys.windows.winuser, core.sys.windows.wtypes, core.sys.windows.objfwd, core.sys.windows.objidl;
22 private import core.sys.windows.winnetwk; // for NETRESOURCE
23 private import core.sys.windows.oaidl : VARIANT;
24 
25 
26 // FIXME: clean up Windows version support
27 
28 align(1):
29 
30 enum BIF_RETURNONLYFSDIRS = 1;
31 enum BIF_DONTGOBELOWDOMAIN = 2;
32 enum BIF_STATUSTEXT = 4;
33 enum BIF_RETURNFSANCESTORS = 8;
34 enum BIF_EDITBOX = 16;
35 enum BIF_VALIDATE = 32;
36 enum BIF_NEWDIALOGSTYLE = 64;
37 enum BIF_BROWSEINCLUDEURLS = 128;
38 enum BIF_USENEWUI =  BIF_EDITBOX | BIF_NEWDIALOGSTYLE;
39 enum BIF_BROWSEFORCOMPUTER = 0x1000;
40 enum BIF_BROWSEFORPRINTER = 0x2000;
41 enum BIF_BROWSEINCLUDEFILES = 0x4000;
42 enum BIF_SHAREABLE = 0x8000;
43 enum BFFM_INITIALIZED = 1;
44 enum BFFM_SELCHANGED = 2;
45 enum BFFM_VALIDATEFAILEDA = 3;
46 enum BFFM_VALIDATEFAILEDW = 4;
47 enum BFFM_SETSTATUSTEXTA = WM_USER + 100;
48 enum BFFM_ENABLEOK = WM_USER + 101;
49 enum BFFM_SETSELECTIONA = WM_USER + 102;
50 enum BFFM_SETSELECTIONW = WM_USER + 103;
51 enum BFFM_SETSTATUSTEXTW = WM_USER + 104;
52 enum BFFM_SETOKTEXT = WM_USER + 105;
53 enum BFFM_SETEXPANDED = WM_USER + 106;
54 
version(Unicode)55 version (Unicode) {
56     alias BFFM_SETSTATUSTEXTW BFFM_SETSTATUSTEXT;
57     alias BFFM_SETSELECTIONW BFFM_SETSELECTION;
58     alias BFFM_VALIDATEFAILEDW BFFM_VALIDATEFAILED;
59 } else {
60     alias BFFM_SETSTATUSTEXTA BFFM_SETSTATUSTEXT;
61     alias BFFM_SETSELECTIONA BFFM_SETSELECTION;
62     alias BFFM_VALIDATEFAILEDA BFFM_VALIDATEFAILED;
63 }
64 
65 enum DVASPECT_SHORTNAME = 2;
66 
67 enum SHARD {
68     SHARD_PIDL            = 1,
69     SHARD_PATHA,
70     SHARD_PATHW,
71     SHARD_APPIDINFO,
72     SHARD_APPIDINFOIDLIST,
73     SHARD_LINK,
74     SHARD_APPIDINFOLINK,
75     SHARD_SHELLITEM,   // = 8
76     SHARD_PATH = (_WIN32_UNICODE ? SHARD_PATHW : SHARD_PATHA)
77 }
78 
79 enum SHCNE_RENAMEITEM = 1;
80 enum SHCNE_CREATE = 2;
81 enum SHCNE_DELETE = 4;
82 enum SHCNE_MKDIR = 8;
83 enum SHCNE_RMDIR = 16;
84 enum SHCNE_MEDIAINSERTED = 32;
85 enum SHCNE_MEDIAREMOVED = 64;
86 enum SHCNE_DRIVEREMOVED = 128;
87 enum SHCNE_DRIVEADD = 256;
88 enum SHCNE_NETSHARE = 512;
89 enum SHCNE_NETUNSHARE = 1024;
90 enum SHCNE_ATTRIBUTES = 2048;
91 enum SHCNE_UPDATEDIR = 4096;
92 enum SHCNE_UPDATEITEM = 8192;
93 enum SHCNE_SERVERDISCONNECT = 16384;
94 enum SHCNE_UPDATEIMAGE = 32768;
95 enum SHCNE_DRIVEADDGUI = 65536;
96 enum SHCNE_RENAMEFOLDER = 0x20000;
97 enum SHCNE_FREESPACE = 0x40000;
98 enum SHCNE_ASSOCCHANGED = 0x8000000;
99 enum SHCNE_DISKEVENTS = 0x2381F;
100 enum SHCNE_GLOBALEVENTS = 0xC0581E0;
101 enum SHCNE_ALLEVENTS = 0x7FFFFFFF;
102 enum SHCNE_INTERRUPT = 0x80000000;
103 
104 enum SHCNF_IDLIST = 0;
105 enum SHCNF_PATHA = 1;
106 enum SHCNF_PRINTERA = 2;
107 enum SHCNF_DWORD = 3;
108 enum SHCNF_PATHW = 5;
109 enum SHCNF_PRINTERW = 6;
110 enum SHCNF_TYPE = 0xFF;
111 enum SHCNF_FLUSH = 0x1000;
112 enum SHCNF_FLUSHNOWAIT = 0x2000;
113 
version(Unicode)114 version (Unicode) {
115     alias SHCNF_PATHW SHCNF_PATH;
116     alias SHCNF_PRINTERW SHCNF_PRINTER;
117 } else {
118     alias SHCNF_PATHA SHCNF_PATH;
119     alias SHCNF_PRINTERA SHCNF_PRINTER;
120 }
121 
122 enum SFGAOF : DWORD {
123     SFGAO_CANCOPY         = DROPEFFECT.DROPEFFECT_COPY,
124     SFGAO_CANMOVE         = DROPEFFECT.DROPEFFECT_MOVE,
125     SFGAO_CANLINK         = DROPEFFECT.DROPEFFECT_LINK,
126     SFGAO_CANRENAME       = 0x00000010L,
127     SFGAO_CANDELETE       = 0x00000020L,
128     SFGAO_HASPROPSHEET    = 0x00000040L,
129     SFGAO_DROPTARGET      = 0x00000100L,
130     SFGAO_CAPABILITYMASK  = 0x00000177L,
131     SFGAO_ISSLOW          = 0x00004000L,
132     SFGAO_GHOSTED         = 0x00008000L,
133     SFGAO_LINK            = 0x00010000L,
134     SFGAO_SHARE           = 0x00020000L,
135     SFGAO_READONLY        = 0x00040000L,
136     SFGAO_HIDDEN          = 0x00080000L,
137     SFGAO_DISPLAYATTRMASK = (SFGAO_ISSLOW | SFGAO_GHOSTED | SFGAO_LINK
138                             | SFGAO_SHARE | SFGAO_READONLY | SFGAO_HIDDEN),
139     SFGAO_FILESYSANCESTOR = 0x10000000L,
140     SFGAO_FOLDER          = 0x20000000L,
141     SFGAO_FILESYSTEM      = 0x40000000L,
142     SFGAO_HASSUBFOLDER    = 0x80000000L,
143     SFGAO_CONTENTSMASK    = 0x80000000L,
144     SFGAO_VALIDATE        = 0x01000000L,
145     SFGAO_REMOVABLE       = 0x02000000L,
146     SFGAO_COMPRESSED      = 0x04000000L
147 }
148 enum STRRET_WSTR = 0;
149 enum STRRET_OFFSET = 1;
150 enum STRRET_CSTR = 2;
151 
152 enum {
153     SHGDFIL_FINDDATA = 1,
154     SHGDFIL_NETRESOURCE,
155     SHGDFIL_DESCRIPTIONID
156 }
157 
158 enum {
159     SHDID_ROOT_REGITEM = 1,
160     SHDID_FS_FILE,
161     SHDID_FS_DIRECTORY,
162     SHDID_FS_OTHER,
163     SHDID_COMPUTER_DRIVE35,
164     SHDID_COMPUTER_DRIVE525,
165     SHDID_COMPUTER_REMOVABLE,
166     SHDID_COMPUTER_FIXED,
167     SHDID_COMPUTER_NETDRIVE,
168     SHDID_COMPUTER_CDROM,
169     SHDID_COMPUTER_RAMDISK,
170     SHDID_COMPUTER_OTHER,
171     SHDID_NET_DOMAIN,
172     SHDID_NET_SERVER,
173     SHDID_NET_SHARE,
174     SHDID_NET_RESTOFNET,
175     SHDID_NET_OTHER
176 }
177 
178 const TCHAR[] REGSTR_PATH_EXPLORER = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer";
179 const TCHAR[] REGSTR_PATH_SPECIAL_FOLDERS=REGSTR_PATH_EXPLORER ~ "\\Shell Folders";
180 
181 enum {
182     CSIDL_DESKTOP            =  0,
183     CSIDL_INTERNET,
184     CSIDL_PROGRAMS,
185     CSIDL_CONTROLS,
186     CSIDL_PRINTERS,
187     CSIDL_PERSONAL,
188     CSIDL_FAVORITES,
189     CSIDL_STARTUP,
190     CSIDL_RECENT,
191     CSIDL_SENDTO,
192     CSIDL_BITBUCKET,
193     CSIDL_STARTMENU,      // = 11
194     CSIDL_MYMUSIC            = 13,
195     CSIDL_MYVIDEO,        // = 14
196     CSIDL_DESKTOPDIRECTORY   = 16,
197     CSIDL_DRIVES,
198     CSIDL_NETWORK,
199     CSIDL_NETHOOD,
200     CSIDL_FONTS,
201     CSIDL_TEMPLATES,
202     CSIDL_COMMON_STARTMENU,
203     CSIDL_COMMON_PROGRAMS,
204     CSIDL_COMMON_STARTUP,
205     CSIDL_COMMON_DESKTOPDIRECTORY,
206     CSIDL_APPDATA,
207     CSIDL_PRINTHOOD,
208     CSIDL_LOCAL_APPDATA,
209     CSIDL_ALTSTARTUP,
210     CSIDL_COMMON_ALTSTARTUP,
211     CSIDL_COMMON_FAVORITES,
212     CSIDL_INTERNET_CACHE,
213     CSIDL_COOKIES,
214     CSIDL_HISTORY,
215     CSIDL_COMMON_APPDATA,
216     CSIDL_WINDOWS,
217     CSIDL_SYSTEM,
218     CSIDL_PROGRAM_FILES,
219     CSIDL_MYPICTURES,
220     CSIDL_PROFILE,
221     CSIDL_SYSTEMX86,
222     CSIDL_PROGRAM_FILESX86,
223     CSIDL_PROGRAM_FILES_COMMON,
224     CSIDL_PROGRAM_FILES_COMMONX86,
225     CSIDL_COMMON_TEMPLATES,
226     CSIDL_COMMON_DOCUMENTS,
227     CSIDL_COMMON_ADMINTOOLS,
228     CSIDL_ADMINTOOLS,
229     CSIDL_CONNECTIONS,  // = 49
230     CSIDL_COMMON_MUSIC     = 53,
231     CSIDL_COMMON_PICTURES,
232     CSIDL_COMMON_VIDEO,
233     CSIDL_RESOURCES,
234     CSIDL_RESOURCES_LOCALIZED,
235     CSIDL_COMMON_OEM_LINKS,
236     CSIDL_CDBURN_AREA,  // = 59
237     CSIDL_COMPUTERSNEARME  = 61,
238     CSIDL_FLAG_DONT_VERIFY = 0x4000,
239     CSIDL_FLAG_CREATE      = 0x8000,
240     CSIDL_FLAG_MASK        = 0xFF00
241 }
242 
243 const TCHAR[]
244     CFSTR_SHELLIDLIST       = "Shell IDList Array",
245     CFSTR_SHELLIDLISTOFFSET = "Shell Object Offsets",
246     CFSTR_NETRESOURCES      = "Net Resource",
247     CFSTR_FILECONTENTS      = "FileContents",
248     CFSTR_FILENAMEA         = "FileName",
249     CFSTR_FILENAMEMAPA      = "FileNameMap",
250     CFSTR_FILEDESCRIPTORA   = "FileGroupDescriptor",
251     CFSTR_INETURLA          = "UniformResourceLocator",
252     CFSTR_SHELLURL          = CFSTR_INETURLA,
253     CFSTR_FILENAMEW         = "FileNameW",
254     CFSTR_FILENAMEMAPW      = "FileNameMapW",
255     CFSTR_FILEDESCRIPTORW   = "FileGroupDescriptorW",
256     CFSTR_INETURLW          = "UniformResourceLocatorW";
257 
version(Unicode)258 version (Unicode) {
259     alias CFSTR_FILENAMEW CFSTR_FILENAME;
260     alias CFSTR_FILENAMEMAPW CFSTR_FILENAMEMAP;
261     alias CFSTR_FILEDESCRIPTORW CFSTR_FILEDESCRIPTOR;
262     alias CFSTR_INETURLW CFSTR_INETURL;
263 } else {
264     alias CFSTR_FILENAMEA CFSTR_FILENAME;
265     alias CFSTR_FILENAMEMAPA CFSTR_FILENAMEMAP;
266     alias CFSTR_FILEDESCRIPTORA CFSTR_FILEDESCRIPTOR;
267     alias CFSTR_INETURLA CFSTR_INETURL;
268 }
269 const TCHAR[]
270     CFSTR_PRINTERGROUP        = "PrinterFriendlyName",
271     CFSTR_INDRAGLOOP          = "InShellDragLoop",
272     CFSTR_PASTESUCCEEDED      = "Paste Succeeded",
273     CFSTR_PERFORMEDDROPEFFECT = "Performed DropEffect",
274     CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect";
275 
276 enum CMF_NORMAL=0;
277 enum CMF_DEFAULTONLY=1;
278 enum CMF_VERBSONLY=2;
279 enum CMF_EXPLORE=4;
280 enum CMF_NOVERBS=8;
281 enum CMF_CANRENAME=16;
282 enum CMF_NODEFAULT=32;
283 enum CMF_INCLUDESTATIC=64;
284 enum CMF_RESERVED=0xffff0000;
285 enum GCS_VERBA=0;
286 enum GCS_HELPTEXTA=1;
287 enum GCS_VALIDATEA=2;
288 enum GCS_VERBW=4;
289 enum GCS_HELPTEXTW=5;
290 enum GCS_VALIDATEW=6;
291 enum GCS_UNICODE=4;
292 
version(Unicode)293 version (Unicode) {
294     alias GCS_VERBW GCS_VERB;
295     alias GCS_HELPTEXTW GCS_HELPTEXT;
296     alias GCS_VALIDATEW GCS_VALIDATE;
297 } else {
298     alias GCS_VERBA GCS_VERB;
299     alias GCS_HELPTEXTA GCS_HELPTEXT;
300     alias GCS_VALIDATEA GCS_VALIDATE;
301 }
302 
303 const TCHAR[]
304     CMDSTR_NEWFOLDER   = "NewFolder",
305     CMDSTR_VIEWLIST    = "ViewList",
306     CMDSTR_VIEWDETAILS = "ViewDetails";
307 
308 enum CMIC_MASK_HOTKEY     = SEE_MASK_HOTKEY;
309 enum CMIC_MASK_ICON       = SEE_MASK_ICON;
310 enum CMIC_MASK_FLAG_NO_UI = SEE_MASK_FLAG_NO_UI;
311 enum CMIC_MASK_MODAL      = 0x80000000;
312 // TODO: This isn't defined anywhere in MinGW.
313 //const CMIC_VALID_SEE_FLAGS=SEE_VALID_CMIC_FLAGS;
314 
315 enum GIL_OPENICON = 1;
316 enum GIL_FORSHELL = 2;
317 enum GIL_SIMULATEDOC = 1;
318 enum GIL_PERINSTANCE = 2;
319 enum GIL_PERCLASS = 4;
320 enum GIL_NOTFILENAME = 8;
321 enum GIL_DONTCACHE = 16;
322 
323 enum FVSIF_RECT = 1;
324 enum FVSIF_PINNED = 2;
325 enum FVSIF_NEWFAILED = 0x8000000;
326 enum FVSIF_NEWFILE = 0x80000000;
327 enum FVSIF_CANVIEWIT = 0x40000000;
328 
329 enum CDBOSC_SETFOCUS = 0;
330 enum CDBOSC_KILLFOCUS = 1;
331 enum CDBOSC_SELCHANGE = 2;
332 enum CDBOSC_RENAME = 3;
333 
334 enum FCIDM_SHVIEWFIRST = 0;
335 enum FCIDM_SHVIEWLAST = 0x7fff;
336 enum FCIDM_BROWSERFIRST = 0xa000;
337 enum FCIDM_BROWSERLAST = 0xbf00;
338 enum FCIDM_GLOBALFIRST = 0x8000;
339 enum FCIDM_GLOBALLAST = 0x9fff;
340 enum FCIDM_MENU_FILE = FCIDM_GLOBALFIRST;
341 enum FCIDM_MENU_EDIT = FCIDM_GLOBALFIRST+0x0040;
342 enum FCIDM_MENU_VIEW = FCIDM_GLOBALFIRST+0x0080;
343 enum FCIDM_MENU_VIEW_SEP_OPTIONS = FCIDM_GLOBALFIRST+0x0081;
344 enum FCIDM_MENU_TOOLS = FCIDM_GLOBALFIRST+0x00c0;
345 enum FCIDM_MENU_TOOLS_SEP_GOTO = FCIDM_GLOBALFIRST+0x00c1;
346 enum FCIDM_MENU_HELP = FCIDM_GLOBALFIRST+0x0100;
347 enum FCIDM_MENU_FIND = FCIDM_GLOBALFIRST+0x0140;
348 enum FCIDM_MENU_EXPLORE = FCIDM_GLOBALFIRST+0x0150;
349 enum FCIDM_MENU_FAVORITES = FCIDM_GLOBALFIRST+0x0170;
350 enum FCIDM_TOOLBAR = FCIDM_BROWSERFIRST;
351 enum FCIDM_STATUS = FCIDM_BROWSERFIRST+1;
352 
353 enum SBSP_DEFBROWSER = 0;
354 enum SBSP_SAMEBROWSER = 1;
355 enum SBSP_NEWBROWSER = 2;
356 enum SBSP_DEFMODE = 0;
357 enum SBSP_OPENMODE = 16;
358 enum SBSP_EXPLOREMODE = 32;
359 enum SBSP_ABSOLUTE = 0;
360 enum SBSP_RELATIVE = 0x1000;
361 enum SBSP_PARENT = 0x2000;
362 enum SBSP_INITIATEDBYHLINKFRAME = 0x80000000;
363 enum SBSP_REDIRECT = 0x40000000;
364 
365 enum {
366     FCW_STATUS=1,
367     FCW_TOOLBAR,
368     FCW_TREE
369 }
370 
371 enum FCT_MERGE=1;
372 enum FCT_CONFIGABLE=2;
373 enum FCT_ADDTOEND=4;
374 
375 enum SVSI_DESELECT=0;
376 enum SVSI_SELECT=1;
377 enum SVSI_EDIT=3;
378 enum SVSI_DESELECTOTHERS=4;
379 enum SVSI_ENSUREVISIBLE=8;
380 enum SVSI_FOCUSED=16;
381 
382 enum SVGIO_BACKGROUND=0;
383 enum SVGIO_SELECTION=1;
384 enum SVGIO_ALLVIEW=2;
385 
386 enum UINT SV2GV_CURRENTVIEW=-1;
387 enum UINT SV2GV_DEFAULTVIEW=-2;
388 
389 alias DWORD SHGDNF;
390 
391 struct CIDA {
392     UINT    cidl;
393     UINT[1] aoffset;
394 }
395 alias CIDA* LPIDA;
396 
397 struct SHITEMID {
398     USHORT  cb;
399     BYTE[1] abID;
400 }
401 alias SHITEMID*        LPSHITEMID;
402 alias const(SHITEMID)* LPCSHITEMID;
403 
404 struct ITEMIDLIST {
405     SHITEMID mkid;
406 }
407 alias ITEMIDLIST*        LPITEMIDLIST;
408 alias const(ITEMIDLIST)* LPCITEMIDLIST;
409 
410 extern (Windows) alias int function(HWND, UINT, LPARAM, LPARAM) BFFCALLBACK;
411 
412 align (8) {
413 struct BROWSEINFOA {
414     HWND          hwndOwner;
415     LPCITEMIDLIST pidlRoot;
416     LPSTR         pszDisplayName;
417     LPCSTR        lpszTitle;
418     UINT          ulFlags;
419     BFFCALLBACK   lpfn;
420     LPARAM        lParam;
421     int           iImage;
422 }
423 alias BROWSEINFOA* PBROWSEINFOA, LPBROWSEINFOA;
424 
425 struct BROWSEINFOW {
426     HWND          hwndOwner;
427     LPCITEMIDLIST pidlRoot;
428     LPWSTR        pszDisplayName;
429     LPCWSTR       lpszTitle;
430     UINT          ulFlags;
431     BFFCALLBACK   lpfn;
432     LPARAM        lParam;
433     int           iImage;
434 }
435 alias BROWSEINFOW* PBROWSEINFOW, LPBROWSEINFOW;
436 } // align (8)
437 
438 struct CMINVOKECOMMANDINFO {
439     DWORD cbSize = this.sizeof;
440     DWORD fMask;
441     HWND hwnd;
442     LPCSTR lpVerb;
443     LPCSTR lpParameters;
444     LPCSTR lpDirectory;
445     int nShow;
446     DWORD dwHotKey;
447     HANDLE hIcon;
448 }
449 alias CMINVOKECOMMANDINFO* LPCMINVOKECOMMANDINFO;
450 
451 struct DROPFILES {
452     DWORD pFiles;
453     POINT pt;
454     BOOL fNC;
455     BOOL fWide;
456 }
457 alias DROPFILES* LPDROPFILES;
458 
459 enum SHGNO {
460     SHGDN_NORMAL             = 0,
461     SHGDN_INFOLDER,
462     SHGDN_FOREDITING         = 0x1000,
463     SHGDN_INCLUDE_NONFILESYS = 0x2000,
464     SHGDN_FORADDRESSBAR      = 0x4000,
465     SHGDN_FORPARSING         = 0x8000
466 }
467 
468 enum SHCONTF {
469     SHCONTF_FOLDERS            = 32,
470     SHCONTF_NONFOLDERS         = 64,
471     SHCONTF_INCLUDEHIDDEN      = 128,
472     SHCONTF_INIT_ON_FIRST_NEXT = 256,
473     SHCONTF_NETPRINTERSRCH     = 512,
474     SHCONTF_SHAREABLE          = 1024,
475     SHCONTF_STORAGE            = 2048
476 }
477 
478 align(8) struct STRRET {
479     UINT uType;
480     union {
481         LPWSTR pOleStr;
482         UINT uOffset;
483         char[MAX_PATH] cStr;
484     }
485 }
486 alias STRRET* LPSTRRET;
487 
488 enum FD_FLAGS {
489     FD_CLSID      = 1,
490     FD_SIZEPOINT  = 2,
491     FD_ATTRIBUTES = 4,
492     FD_CREATETIME = 8,
493     FD_ACCESSTIME = 16,
494     FD_WRITESTIME = 32,
495     FD_FILESIZE   = 64,
496     FD_LINKUI     = 0x8000
497 }
498 
499 struct FILEDESCRIPTORA {
500     DWORD dwFlags;
501     CLSID clsid;
502     SIZEL sizel;
503     POINTL pointl;
504     DWORD dwFileAttributes;
505     FILETIME ftCreationTime;
506     FILETIME ftLastAccessTime;
507     FILETIME ftLastWriteTime;
508     DWORD nFileSizeHigh;
509     DWORD nFileSizeLow;
510     CHAR[MAX_PATH] cFileName = 0;
511 }
512 alias FILEDESCRIPTORA* LPFILEDESCRIPTORA;
513 
514 struct FILEDESCRIPTORW {
515     DWORD dwFlags;
516     CLSID clsid;
517     SIZEL sizel;
518     POINTL pointl;
519     DWORD dwFileAttributes;
520     FILETIME ftCreationTime;
521     FILETIME ftLastAccessTime;
522     FILETIME ftLastWriteTime;
523     DWORD nFileSizeHigh;
524     DWORD nFileSizeLow;
525     WCHAR[MAX_PATH] cFileName = 0;
526 }
527 alias FILEDESCRIPTORW* LPFILEDESCRIPTORW;
528 
529 struct FILEGROUPDESCRIPTORA {
530     UINT cItems;
531     FILEDESCRIPTORA[1] fgd;
532 }
533 alias FILEGROUPDESCRIPTORA* LPFILEGROUPDESCRIPTORA;
534 
535 struct FILEGROUPDESCRIPTORW {
536     UINT cItems;
537     FILEDESCRIPTORW[1] fgd;
538 }
539 alias FILEGROUPDESCRIPTORW* LPFILEGROUPDESCRIPTORW;
540 
541 enum SLR_FLAGS {
542     SLR_NO_UI      = 1,
543     SLR_ANY_MATCH  = 2,
544     SLR_UPDATE     = 4,
545     SLR_NOUPDATE   = 8,
546     SLR_NOSEARCH   = 16,
547     SLR_NOTRACK    = 32,
548     SLR_NOLINKINFO = 64,
549     SLR_INVOKE_MSI = 128
550 }
551 
552 enum SLGP_FLAGS {
553     SLGP_SHORTPATH=1,
554     SLGP_UNCPRIORITY=2,
555     SLGP_RAWPATH=4
556 }
557 
558 alias PBYTE LPVIEWSETTINGS;
559 
560 enum FOLDERFLAGS {
561     FWF_AUTOARRANGE         = 1,
562     FWF_ABBREVIATEDNAMES    = 2,
563     FWF_SNAPTOGRID          = 4,
564     FWF_OWNERDATA           = 8,
565     FWF_BESTFITWINDOW       = 16,
566     FWF_DESKTOP             = 32,
567     FWF_SINGLESEL           = 64,
568     FWF_NOSUBFOLDERS        = 128,
569     FWF_TRANSPARENT         = 256,
570     FWF_NOCLIENTEDGE        = 512,
571     FWF_NOSCROLL            = 0x400,
572     FWF_ALIGNLEFT           = 0x800,
573     FWF_SINGLECLICKACTIVATE = 0x8000
574 }
575 
576 enum FOLDERVIEWMODE {
577     FVM_ICON      = 1,
578     FVM_SMALLICON,
579     FVM_LIST,
580     FVM_DETAILS
581 }
582 
583 struct FOLDERSETTINGS {
584     UINT ViewMode;
585     UINT fFlags;
586 }
587 alias FOLDERSETTINGS*        LPFOLDERSETTINGS;
588 alias const(FOLDERSETTINGS)* LPCFOLDERSETTINGS;
589 
590 struct FVSHOWINFO {
591     DWORD cbSize = this.sizeof;
592     HWND hwndOwner;
593     int iShow;
594     DWORD dwFlags;
595     RECT rect;
596     LPUNKNOWN punkRel;
597     OLECHAR[MAX_PATH] strNewFile = 0;
598 }
599 alias FVSHOWINFO* LPFVSHOWINFO;
600 
601 struct NRESARRAY {
602     UINT cItems;
603     NETRESOURCE[1] nr;
604 }
605 alias NRESARRAY* LPNRESARRAY;
606 
607 enum {
608     SBSC_HIDE,
609     SBSC_SHOW,
610     SBSC_TOGGLE,
611     SBSC_QUERY
612 }
613 
614 enum {
615     SBCMDID_ENABLESHOWTREE,
616     SBCMDID_SHOWCONTROL,
617     SBCMDID_CANCELNAVIGATION,
618     SBCMDID_MAYSAVECHANGES,
619     SBCMDID_SETHLINKFRAME,
620     SBCMDID_ENABLESTOP,
621     SBCMDID_OPTIONS
622 }
623 enum SVUIA_STATUS {
624     SVUIA_DEACTIVATE,
625     SVUIA_ACTIVATE_NOFOCUS,
626     SVUIA_ACTIVATE_FOCUS,
627     SVUIA_INPLACEACTIVATE
628 }
629 
630 static if (_WIN32_IE >= 0x500) {
631 
632     struct EXTRASEARCH
633      {
634         GUID guidSearch;
635         WCHAR[80] wszFriendlyName = 0;
636         WCHAR[2084] wszUrl = 0;
637     }
638     alias EXTRASEARCH* LPEXTRASEARCH;
639 
640     alias DWORD SHCOLSTATEF;
641 
642     struct SHCOLUMNID {
643         GUID fmtid;
644         DWORD pid;
645     }
646     alias SHCOLUMNID*        LPSHCOLUMNID;
647     alias const(SHCOLUMNID)* LPCSHCOLUMNID;
648 
649     struct SHELLDETAILS {
650         int fmt;
651         int cxChar;
652         STRRET str;
653     }
654     alias SHELLDETAILS* LPSHELLDETAILS;
655 
656     struct PERSIST_FOLDER_TARGET_INFO
657      {
658         LPITEMIDLIST pidlTargetFolder;
659         WCHAR[MAX_PATH] szTargetParsingName = 0;
660         WCHAR[MAX_PATH] szNetworkProvider = 0;
661         DWORD dwAttributes;
662         int csidl;
663     }
664 
665     enum SHGFP_TYPE {
666         SHGFP_TYPE_CURRENT = 0,
667         SHGFP_TYPE_DEFAULT = 1,
668     }
669 
670 }
671 
672 interface IEnumIDList : IUnknown {
673     HRESULT Next(ULONG, LPITEMIDLIST*, ULONG*);
674     HRESULT Skip(ULONG);
675     HRESULT Reset();
676     HRESULT Clone(IEnumIDList*);
677 }
678 alias IEnumIDList LPENUMIDLIST;
679 
680 interface IObjMgr : IUnknown {
681     HRESULT Append(IUnknown);
682     HRESULT Remove(IUnknown);
683 }
684 
685 interface IContextMenu : IUnknown {
686     HRESULT QueryContextMenu(HMENU, UINT, UINT, UINT, UINT);
687     HRESULT InvokeCommand(LPCMINVOKECOMMANDINFO);
688     HRESULT GetCommandString(UINT_PTR, UINT, PUINT, LPSTR, UINT);
689 }
690 alias IContextMenu LPCONTEXTMENU;
691 
692 interface IContextMenu2 : IContextMenu {
693     HRESULT HandleMenuMsg(UINT, WPARAM, LPARAM);
694 };
695 alias IContextMenu2 LPCONTEXTMENU2;
696 
697 static if (_WIN32_IE >= 0x500) {
698     align(8) {
699         struct SHCOLUMNINIT {
700             ULONG dwFlags;
701             ULONG dwReserved;
702             WCHAR[MAX_PATH] wszFolder = 0;
703         }
704         alias SHCOLUMNINIT*        LPSHCOLUMNINIT;
705         alias const(SHCOLUMNINIT)* LPCSHCOLUMNINIT;
706 
707         struct SHCOLUMNDATA {
708             ULONG dwFlags;
709             DWORD dwFileAttributes;
710             ULONG dwReserved;
711             WCHAR *pwszExt = null;
712             WCHAR[MAX_PATH] wszFile = 0;
713         }
714         alias SHCOLUMNDATA*        LPSHCOLUMNDATA;
715         alias const(SHCOLUMNDATA)* LPCSHCOLUMNDATA;
716     }
717 
718 enum MAX_COLUMN_NAME_LEN = 80;
719 enum MAX_COLUMN_DESC_LEN = 128;
720 
721     align(1) struct SHCOLUMNINFO {
722         align(1):
723         SHCOLUMNID scid;
724         VARTYPE vt;
725         DWORD fmt;
726         UINT cChars;
727         DWORD csFlags;
728         WCHAR[MAX_COLUMN_NAME_LEN] wszTitle = 0;
729         WCHAR[MAX_COLUMN_DESC_LEN] wszDescription = 0;
730     }
731     alias SHCOLUMNINFO*        LPSHCOLUMNINFO;
732     alias const(SHCOLUMNINFO)* LPCSHCOLUMNINFO;
733 
734     enum SHCOLSTATE {
735         SHCOLSTATE_TYPE_STR      = 0x00000001,
736         SHCOLSTATE_TYPE_INT      = 0x00000002,
737         SHCOLSTATE_TYPE_DATE     = 0x00000003,
738         SHCOLSTATE_TYPEMASK      = 0x0000000f,
739         SHCOLSTATE_ONBYDEFAULT   = 0x00000010,
740         SHCOLSTATE_SLOW          = 0x00000020,
741         SHCOLSTATE_EXTENDED      = 0x00000040,
742         SHCOLSTATE_SECONDARYUI   = 0x00000080,
743         SHCOLSTATE_HIDDEN        = 0x00000100,
744         SHCOLSTATE_PREFER_VARCMP = 0x00000200
745     }
746 
747     interface IColumnProvider : IUnknown {
748         HRESULT Initialize(LPCSHCOLUMNINIT);
749         HRESULT GetColumnInfo(DWORD, SHCOLUMNINFO*);
750         HRESULT GetItemData(LPCSHCOLUMNID, LPCSHCOLUMNDATA, VARIANT*);
751     }
752 }/* _WIN32_IE >= 0x500 */
753 
754 interface IQueryInfo : IUnknown {
755     HRESULT GetInfoTip(DWORD, WCHAR**);
756     HRESULT GetInfoFlags(DWORD*);
757 }
758 
759 interface IShellExtInit : IUnknown {
760     HRESULT Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY);
761 }
762 alias IShellExtInit LPSHELLEXTINIT;
763 
764 interface IShellPropSheetExt : IUnknown {
765     HRESULT AddPages(LPFNADDPROPSHEETPAGE, LPARAM);
766     HRESULT ReplacePage(UINT, LPFNADDPROPSHEETPAGE, LPARAM);
767 }
768 alias IShellPropSheetExt LPSHELLPROPSHEETEXT;
769 
770 interface IExtractIconA : IUnknown {
771     HRESULT GetIconLocation(UINT, LPSTR, UINT, int*, PUINT);
772     HRESULT Extract(LPCSTR, UINT, HICON*, HICON*, UINT);
773 };
774 alias IExtractIconA LPEXTRACTICONA;
775 
776 interface IExtractIconW : IUnknown {
777     HRESULT GetIconLocation(UINT, LPWSTR, UINT, int*, PUINT);
778     HRESULT Extract(LPCWSTR, UINT, HICON*, HICON*, UINT);
779 }
780 alias IExtractIconW LPEXTRACTICONW;
781 
782 version (Unicode) {
783     alias IExtractIconW IExtractIcon;
784     alias LPEXTRACTICONW LPEXTRACTICON;
785 } else {
786     alias IExtractIconA IExtractIcon;
787     alias LPEXTRACTICONA LPEXTRACTICON;
788 }
789 
790 interface IShellLinkA : IUnknown {
791     HRESULT GetPath(LPSTR, int, WIN32_FIND_DATAA*, DWORD);
792     HRESULT GetIDList(LPITEMIDLIST*);
793     HRESULT SetIDList(LPCITEMIDLIST);
794     HRESULT GetDescription(LPSTR, int);
795     HRESULT SetDescription(LPCSTR);
796     HRESULT GetWorkingDirectory(LPSTR, int);
797     HRESULT SetWorkingDirectory(LPCSTR);
798     HRESULT GetArguments(LPSTR, int);
799     HRESULT SetArguments(LPCSTR);
800     HRESULT GetHotkey(PWORD);
801     HRESULT SetHotkey(WORD);
802     HRESULT GetShowCmd(int*);
803     HRESULT SetShowCmd(int);
804     HRESULT GetIconLocation(LPSTR, int, int*);
805     HRESULT SetIconLocation(LPCSTR, int);
806     HRESULT SetRelativePath(LPCSTR , DWORD);
807     HRESULT Resolve(HWND, DWORD);
808     HRESULT SetPath(LPCSTR);
809 }
810 
811 interface IShellLinkW : IUnknown {
812     HRESULT GetPath(LPWSTR, int, WIN32_FIND_DATAW*, DWORD);
813     HRESULT GetIDList(LPITEMIDLIST*);
814     HRESULT SetIDList(LPCITEMIDLIST);
815     HRESULT GetDescription(LPWSTR, int);
816     HRESULT SetDescription(LPCWSTR);
817     HRESULT GetWorkingDirectory(LPWSTR, int);
818     HRESULT SetWorkingDirectory(LPCWSTR);
819     HRESULT GetArguments(LPWSTR, int);
820     HRESULT SetArguments(LPCWSTR);
821     HRESULT GetHotkey(PWORD);
822     HRESULT SetHotkey(WORD);
823     HRESULT GetShowCmd(int*);
824     HRESULT SetShowCmd(int);
825     HRESULT GetIconLocation(LPWSTR, int, int*);
826     HRESULT SetIconLocation(LPCWSTR, int);
827     HRESULT SetRelativePath(LPCWSTR , DWORD);
828     HRESULT Resolve(HWND, DWORD);
829     HRESULT SetPath(LPCWSTR);
830 }
831 
832 
833 interface IShellFolder : IUnknown {
834     HRESULT ParseDisplayName(HWND, LPBC, LPOLESTR, PULONG, LPITEMIDLIST*, PULONG);
835     HRESULT EnumObjects(HWND, DWORD, LPENUMIDLIST*);
836     HRESULT BindToObject(LPCITEMIDLIST, LPBC, REFIID, PVOID*);
837     HRESULT BindToStorage(LPCITEMIDLIST, LPBC, REFIID, PVOID*);
838     HRESULT CompareIDs(LPARAM, LPCITEMIDLIST, LPCITEMIDLIST);
839     HRESULT CreateViewObject(HWND, REFIID, PVOID*);
840     HRESULT GetAttributesOf(UINT, LPCITEMIDLIST*, PULONG);
841     HRESULT GetUIObjectOf(HWND, UINT, LPCITEMIDLIST*, REFIID, PUINT, PVOID*);
842     HRESULT GetDisplayNameOf(LPCITEMIDLIST, DWORD, LPSTRRET);
843     HRESULT SetNameOf(HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST*);
844 }
845 alias IShellFolder LPSHELLFOLDER;
846 
847 static if (_WIN32_IE >= 0x500) {
848 
849 interface IEnumExtraSearch: IUnknown {
850     HRESULT Next(ULONG, LPEXTRASEARCH*, ULONG*);
851     HRESULT Skip(ULONG);
852     HRESULT Reset();
853     HRESULT Clone(IEnumExtraSearch*);
854 }
855 alias IEnumExtraSearch LPENUMEXTRASEARCH;
856 
857 interface IShellFolder2 : IShellFolder {
858     HRESULT ParseDisplayName(HWND, LPBC, LPOLESTR, PULONG, LPITEMIDLIST*, PULONG);
859     HRESULT EnumObjects(HWND, DWORD, LPENUMIDLIST*);
860     HRESULT BindToObject(LPCITEMIDLIST, LPBC, REFIID, PVOID*);
861     HRESULT BindToStorage(LPCITEMIDLIST, LPBC, REFIID, PVOID*);
862     HRESULT CompareIDs(LPARAM, LPCITEMIDLIST, LPCITEMIDLIST);
863     HRESULT CreateViewObject(HWND, REFIID, PVOID*);
864     HRESULT GetAttributesOf(UINT, LPCITEMIDLIST*, PULONG);
865     HRESULT GetUIObjectOf(HWND, UINT, LPCITEMIDLIST*, REFIID, PUINT, PVOID*);
866     HRESULT GetDisplayNameOf(LPCITEMIDLIST, DWORD, LPSTRRET);
867     HRESULT SetNameOf(HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST*);
868     HRESULT GetDefaultSearchGUID(GUID*);
869     HRESULT EnumSearches(IEnumExtraSearch*);
870     HRESULT GetDefaultColumn(DWORD, ULONG*, ULONG*);
871     HRESULT GetDefaultColumnState(UINT, SHCOLSTATEF*);
872     HRESULT GetDetailsEx(LPCITEMIDLIST, const(SHCOLUMNID)*, VARIANT*);
873     HRESULT GetDetailsOf(LPCITEMIDLIST, UINT, SHELLDETAILS*);
874     HRESULT MapColumnToSCID(UINT, SHCOLUMNID*);
875 }
876 alias IShellFolder2 LPSHELLFOLDER2;
877 
878 } /* _WIN32_IE >= 0x500 */
879 
880 interface ICopyHook : IUnknown {
881     UINT CopyCallback(HWND, UINT, UINT, LPCSTR, DWORD, LPCSTR, DWORD);
882 }
883 alias ICopyHook LPCOPYHOOK;
884 
885 interface IFileViewerSite : IUnknown {
886     HRESULT SetPinnedWindow(HWND);
887     HRESULT GetPinnedWindow(HWND*);
888 }
889 alias IFileViewerSite LPFILEVIEWERSITE;
890 
891 interface IFileViewer : IUnknown {
892     HRESULT ShowInitialize(LPFILEVIEWERSITE);
893     HRESULT Show(LPFVSHOWINFO);
894     HRESULT PrintTo(LPSTR, BOOL);
895 }
896 alias IFileViewer LPFILEVIEWER;
897 
898 interface IFileSystemBindData : IUnknown {
899     HRESULT SetFindData(const(WIN32_FIND_DATAW)*);
900     HRESULT GetFindData(WIN32_FIND_DATAW*);
901 }
902 
903 interface IPersistFolder : IPersist {
904     HRESULT GetClassID(CLSID*);
905     HRESULT Initialize(LPCITEMIDLIST);
906 }
907 alias IPersistFolder LPPERSISTFOLDER;
908 
909 static if (_WIN32_IE >= 0x400 || _WIN32_WINNT >= 0x500) {
910 
911 interface IPersistFolder2 : IPersistFolder {
912     HRESULT GetClassID(CLSID*);
913     HRESULT Initialize(LPCITEMIDLIST);
914     HRESULT GetCurFolder(LPITEMIDLIST*);
915 }
916 alias IPersistFolder2 LPPERSISTFOLDER2;
917 
918 }/* _WIN32_IE >= 0x400 || _WIN32_WINNT >= 0x500 */
919 
920 static if (_WIN32_IE >= 0x500) {
921 
922 interface IPersistFolder3 : IPersistFolder2 {
923     HRESULT GetClassID(CLSID*);
924     HRESULT Initialize(LPCITEMIDLIST);
925     HRESULT GetCurFolder(LPITEMIDLIST*);
926     HRESULT InitializeEx(IBindCtx, LPCITEMIDLIST, const(PERSIST_FOLDER_TARGET_INFO)*);
927     HRESULT GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO*);
928 }
929 alias IPersistFolder3 LPPERSISTFOLDER3;
930 
931 } /* _WIN32_IE >= 0x500 */
932 
933 alias IShellBrowser LPSHELLBROWSER;
934 alias IShellView LPSHELLVIEW;
935 
936 interface IShellBrowser : IOleWindow {
937     HRESULT GetWindow(HWND*);
938     HRESULT ContextSensitiveHelp(BOOL);
939     HRESULT InsertMenusSB(HMENU, LPOLEMENUGROUPWIDTHS);
940     HRESULT SetMenuSB(HMENU, HOLEMENU, HWND);
941     HRESULT RemoveMenusSB(HMENU);
942     HRESULT SetStatusTextSB(LPCOLESTR);
943     HRESULT EnableModelessSB(BOOL);
944     HRESULT TranslateAcceleratorSB(LPMSG, WORD);
945     HRESULT BrowseObject(LPCITEMIDLIST, UINT);
946     HRESULT GetViewStateStream(DWORD, LPSTREAM*);
947     HRESULT GetControlWindow(UINT, HWND*);
948     HRESULT SendControlMsg(UINT, UINT, WPARAM, LPARAM, LRESULT*);
949     HRESULT QueryActiveShellView(LPSHELLVIEW*);
950     HRESULT OnViewWindowActive(LPSHELLVIEW);
951     HRESULT SetToolbarItems(LPTBBUTTON, UINT, UINT);
952 }
953 
954 interface IShellView : IOleWindow {
955     HRESULT GetWindow(HWND*);
956     HRESULT ContextSensitiveHelp(BOOL);
957     HRESULT TranslateAccelerator(LPMSG);
958 //[No] #ifdef _FIX_ENABLEMODELESS_CONFLICT
959 //[No]  STDMETHOD(EnableModelessSV)(THIS_ BOOL) PURE;
960 //[Yes] #else
961     HRESULT EnableModeless(BOOL);
962 //[Yes] #endif
963     HRESULT UIActivate(UINT);
964     HRESULT Refresh();
965     HRESULT CreateViewWindow(IShellView, LPCFOLDERSETTINGS, LPSHELLBROWSER, RECT*, HWND*);
966     HRESULT DestroyViewWindow();
967     HRESULT GetCurrentInfo(LPFOLDERSETTINGS);
968     HRESULT AddPropertySheetPages(DWORD, LPFNADDPROPSHEETPAGE, LPARAM);
969     HRESULT SaveViewState();
970     HRESULT SelectItem(LPCITEMIDLIST, UINT);
971     HRESULT GetItemObject(UINT, REFIID, PVOID*);
972 }
973 
974 interface ICommDlgBrowser : IUnknown {
975     HRESULT OnDefaultCommand(IShellView);
976     HRESULT OnStateChange(IShellView, ULONG);
977     HRESULT IncludeObject(IShellView, LPCITEMIDLIST);
978 }
979 alias ICommDlgBrowser LPCOMMDLGBROWSER;
980 
981 alias GUID SHELLVIEWID;
982 
983 struct SV2CVW2_PARAMS {
984     DWORD cbSize = this.sizeof;
985     IShellView psvPrev;
986     FOLDERSETTINGS  *pfs;
987     IShellBrowser psbOwner;
988     RECT *prcView;
989 const(SHELLVIEWID)* pvid;
990     HWND hwndView;
991 }
992 alias SV2CVW2_PARAMS* LPSV2CVW2_PARAMS;
993 
994 interface IShellView2 : IShellView {
995     HRESULT GetWindow(HWND*);
996     HRESULT ContextSensitiveHelp(BOOL);
997     HRESULT TranslateAccelerator(LPMSG);
998 //[No] #ifdef _FIX_ENABLEMODELESS_CONFLICT
999 //[No]  STDMETHOD(EnableModelessSV)(THIS_ BOOL) PURE;
1000 //[Yes] #else
1001     HRESULT EnableModeless(BOOL);
1002 //[Yes] #endif
1003     HRESULT UIActivate(UINT);
1004     HRESULT Refresh();
1005     HRESULT CreateViewWindow(IShellView, LPCFOLDERSETTINGS, LPSHELLBROWSER, RECT*, HWND*);
1006     HRESULT DestroyViewWindow();
1007     HRESULT GetCurrentInfo(LPFOLDERSETTINGS);
1008     HRESULT AddPropertySheetPages(DWORD, LPFNADDPROPSHEETPAGE, LPARAM);
1009     HRESULT SaveViewState();
1010     HRESULT SelectItem(LPCITEMIDLIST, UINT);
1011     HRESULT GetItemObject(UINT, REFIID, PVOID*);
1012     HRESULT GetView(SHELLVIEWID*, ULONG);
1013     HRESULT CreateViewWindow2(LPSV2CVW2_PARAMS);
1014 }
1015 
1016 interface IShellExecuteHookA : IUnknown {
1017     HRESULT Execute(LPSHELLEXECUTEINFOA);
1018 }
1019 
1020 interface IShellExecuteHookW : IUnknown {
1021     HRESULT Execute(LPSHELLEXECUTEINFOW);
1022 }
1023 
1024 interface IShellIcon : IUnknown {
1025     HRESULT GetIconOf(LPCITEMIDLIST, UINT, PINT);
1026 }
1027 alias IShellIcon LPSHELLICON;
1028 
1029 struct SHELLFLAGSTATE {
1030     short _bf;
1031 /*
1032     BOOL fShowAllObjects : 1;
1033     BOOL fShowExtensions : 1;
1034     BOOL fNoConfirmRecycle : 1;
1035     BOOL fShowSysFiles : 1;
1036     BOOL fShowCompColor : 1;
1037     BOOL fDoubleClickInWebView : 1;
1038     BOOL fDesktopHTML : 1;
1039     BOOL fWin95Classic : 1;
1040     BOOL fDontPrettyPath : 1;
1041     BOOL fShowAttribCol : 1;
1042     BOOL fMapNetDrvBtn : 1;
1043     BOOL fShowInfoTip : 1;
1044     BOOL fHideIcons : 1;
1045     UINT fRestFlags : 3;
1046 */
1047     @property bool fShowAllObjects()       { return cast(bool) (_bf & 0x0001); }
1048     @property bool fShowExtensions()       { return cast(bool) (_bf & 0x0002); }
1049     @property bool fNoConfirmRecycle()     { return cast(bool) (_bf & 0x0004); }
1050     @property bool fShowSysFiles()         { return cast(bool) (_bf & 0x0008); }
1051     @property bool fShowCompColor()        { return cast(bool) (_bf & 0x0010); }
1052     @property bool fDoubleClickInWebView() { return cast(bool) (_bf & 0x0020); }
1053     @property bool fDesktopHTML()          { return cast(bool) (_bf & 0x0040); }
1054     @property bool fWin95Classic()         { return cast(bool) (_bf & 0x0080); }
1055     @property bool fDontPrettyPath()       { return cast(bool) (_bf & 0x0100); }
1056     @property bool fShowAttribCol()        { return cast(bool) (_bf & 0x0200); }
1057     @property bool fMapNetDrvBtn()         { return cast(bool) (_bf & 0x0400); }
1058     @property bool fShowInfoTip()          { return cast(bool) (_bf & 0x0800); }
1059     @property bool fHideIcons()            { return cast(bool) (_bf & 0x1000); }
1060     @property ubyte fRestFlags()           { return cast(ubyte) (_bf >> 13); }
1061 
1062     @property bool fShowAllObjects(bool f)       { _bf = cast(ushort) ((_bf & ~0xFFFE) | f);        return f; }
1063     @property bool fShowExtensions(bool f)       { _bf = cast(ushort) ((_bf & ~0xFFFD) | (f <<  1)); return f; }
1064     @property bool fNoConfirmRecycle(bool f)     { _bf = cast(ushort) ((_bf & ~0xFFFB) | (f <<  2)); return f; }
1065     @property bool fShowSysFiles(bool f)         { _bf = cast(ushort) ((_bf & ~0xFFF8) | (f <<  3)); return f; }
1066     @property bool fShowCompColor(bool f)        { _bf = cast(ushort) ((_bf & ~0xFFEF) | (f <<  4)); return f; }
1067     @property bool fDoubleClickInWebView(bool f) { _bf = cast(ushort) ((_bf & ~0xFFDF) | (f <<  5)); return f; }
1068     @property bool fDesktopHTML(bool f)          { _bf = cast(ushort) ((_bf & ~0xFFBF) | (f <<  6)); return f; }
1069     @property bool fWin95Classic(bool f)         { _bf = cast(ushort) ((_bf & ~0xFF8F) | (f <<  7)); return f; }
1070     @property bool fDontPrettyPath(bool f)       { _bf = cast(ushort) ((_bf & ~0xFEFF) | (f <<  8)); return f; }
1071     @property bool fShowAttribCol(bool f)        { _bf = cast(ushort) ((_bf & ~0xFDFF) | (f <<  9)); return f; }
1072     @property bool fMapNetDrvBtn(bool f)         { _bf = cast(ushort) ((_bf & ~0xFBFF) | (f << 10)); return f; }
1073     @property bool fShowInfoTip(bool f)          { _bf = cast(ushort) ((_bf & ~0xF8FF) | (f << 11)); return f; }
1074     @property bool fHideIcons(bool f)            { _bf = cast(ushort) ((_bf & ~0xEFFF) | (f << 12)); return f; }
1075     @property ubyte fRestFlags(ubyte f)          { _bf = cast(ushort) ((_bf & ~0x1FFF) | (f << 13)); return cast(ubyte) (f & 7); }
1076 }
1077 alias SHELLFLAGSTATE* LPSHELLFLAGSTATE;
1078 
1079 enum SSF_SHOWALLOBJECTS = 0x1;
1080 enum SSF_SHOWEXTENSIONS = 0x2;
1081 enum SSF_SHOWCOMPCOLOR = 0x8;
1082 enum SSF_SHOWSYSFILES = 0x20;
1083 enum SSF_DOUBLECLICKINWEBVIEW = 0x80;
1084 enum SSF_SHOWATTRIBCOL = 0x100;
1085 enum SSF_DESKTOPHTML = 0x200;
1086 enum SSF_WIN95CLASSIC = 0x400;
1087 enum SSF_DONTPRETTYPATH = 0x800;
1088 enum SSF_MAPNETDRVBUTTON = 0x1000;
1089 enum SSF_SHOWINFOTIP = 0x2000;
1090 enum SSF_HIDEICONS = 0x4000;
1091 enum SSF_NOCONFIRMRECYCLE = 0x8000;
1092 
1093 interface IShellIconOverlayIdentifier : IUnknown {
1094     HRESULT IsMemberOf(LPCWSTR, DWORD);
1095     HRESULT GetOverlayInfo(LPWSTR, int, int*, DWORD*);
1096     HRESULT GetPriority(int*);
1097 }
1098 
1099 enum ISIOI_ICONFILE  = 0x00000001;
1100 enum ISIOI_ICONINDEX = 0x00000002;
1101 
1102 static if (_WIN32_WINNT >= 0x500) {
1103     struct SHELLSTATE {
1104         uint _bf1;
1105         DWORD dwWin95Unused;
1106         UINT uWin95Unused;
1107         LONG lParamSort;
1108         int iSortDirection;
1109         UINT _version;
1110         UINT uNotUsed;
1111         uint _bf2;
1112     /*
1113         BOOL fShowAllObjects : 1;
1114         BOOL fShowExtensions : 1;
1115         BOOL fNoConfirmRecycle : 1;
1116         BOOL fShowSysFiles : 1;
1117         BOOL fShowCompColor : 1;
1118         BOOL fDoubleClickInWebView : 1;
1119         BOOL fDesktopHTML : 1;
1120         BOOL fWin95Classic : 1;
1121         BOOL fDontPrettyPath : 1;
1122         BOOL fShowAttribCol : 1;
1123         BOOL fMapNetDrvBtn : 1;
1124         BOOL fShowInfoTip : 1;
1125         BOOL fHideIcons : 1;
1126         BOOL fWebView : 1;
1127         BOOL fFilter : 1;
1128         BOOL fShowSuperHidden : 1;
1129         BOOL fNoNetCrawling : 1;
1130     */
1131         @property bool fShowAllObjects()       { return cast(bool) (_bf1 & 0x00000001); }
1132         @property bool fShowExtensions()       { return cast(bool) (_bf1 & 0x00000002); }
1133         @property bool fNoConfirmRecycle()     { return cast(bool) (_bf1 & 0x00000004); }
1134         @property bool fShowSysFiles()         { return cast(bool) (_bf1 & 0x00000008); }
1135         @property bool fShowCompColor()        { return cast(bool) (_bf1 & 0x00000010); }
1136         @property bool fDoubleClickInWebView() { return cast(bool) (_bf1 & 0x00000020); }
1137         @property bool fDesktopHTML()          { return cast(bool) (_bf1 & 0x00000040); }
1138         @property bool fWin95Classic()         { return cast(bool) (_bf1 & 0x00000080); }
1139         @property bool fDontPrettyPath()       { return cast(bool) (_bf1 & 0x00000100); }
1140         @property bool fShowAttribCol()        { return cast(bool) (_bf1 & 0x00000200); }
1141         @property bool fMapNetDrvBtn()         { return cast(bool) (_bf1 & 0x00000400); }
1142         @property bool fShowInfoTip()          { return cast(bool) (_bf1 & 0x00000800); }
1143         @property bool fHideIcons()            { return cast(bool) (_bf1 & 0x00001000); }
1144         @property bool fWebView()              { return cast(bool) (_bf1 & 0x00002000); }
1145         @property bool fFilter()               { return cast(bool) (_bf1 & 0x00004000); }
1146         @property bool fShowSuperHidden()      { return cast(bool) (_bf1 & 0x00008000); }
1147         @property bool fNoNetCrawling()        { return cast(bool) (_bf1 & 0x00010000); }
1148 
1149         @property bool fShowAllObjects(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFE) | f);         return f; }
1150         @property bool fShowExtensions(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFD) | (f <<  1)); return f; }
1151         @property bool fNoConfirmRecycle(bool f)     { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFB) | (f <<  2)); return f; }
1152         @property bool fShowSysFiles(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFF8) | (f <<  3)); return f; }
1153         @property bool fShowCompColor(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFEF) | (f <<  4)); return f; }
1154         @property bool fDoubleClickInWebView(bool f) { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFDF) | (f <<  5)); return f; }
1155         @property bool fDesktopHTML(bool f)          { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFBF) | (f <<  6)); return f; }
1156         @property bool fWin95Classic(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFF8F) | (f <<  7)); return f; }
1157         @property bool fDontPrettyPath(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFEFF) | (f <<  8)); return f; }
1158         @property bool fShowAttribCol(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFDFF) | (f <<  9)); return f; }
1159         @property bool fMapNetDrvBtn(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFBFF) | (f << 10)); return f; }
1160         @property bool fShowInfoTip(bool f)          { _bf1 = cast(uint) ((_bf1 & ~0xFFFFF8FF) | (f << 11)); return f; }
1161         @property bool fHideIcons(bool f)            { _bf1 = cast(uint) ((_bf1 & ~0xFFFFEFFF) | (f << 12)); return f; }
1162         @property bool fWebView(bool f)              { _bf1 = cast(uint) ((_bf1 & ~0xFFFFDFFF) | (f << 13)); return f; }
1163         @property bool fFilter(bool f)               { _bf1 = cast(uint) ((_bf1 & ~0xFFFFBFFF) | (f << 14)); return f; }
1164         @property bool fShowSuperHidden(bool f)      { _bf1 = cast(uint) ((_bf1 & ~0xFFFF8FFF) | (f << 15)); return f; }
1165         @property bool fNoNetCrawling(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFEFFFF) | (f << 16)); return f; }
1166     /*
1167         BOOL fSepProcess : 1;
1168         BOOL fStartPanelOn : 1;
1169         BOOL fShowStartPage : 1;
1170         UINT fSpareFlags : 13;
1171     */
1172         @property bool fSepProcess()           { return cast(bool) (_bf2 & 0x00000001); }
1173         @property bool fStartPanelOn()         { return cast(bool) (_bf2 & 0x00000002); }
1174         @property bool fShowStartPage()        { return cast(bool) (_bf2 & 0x00000004); }
1175         @property ushort fSpareFlags()         { return cast(ushort) ((_bf2 & 0x0000FFF8) >> 3); }
1176 
1177         @property bool fSepProcess(bool f)     { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFE) | f);        return f; }
1178         @property bool fStartPanelOn(bool f)   { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFD) | (f << 1)); return f; }
1179         @property bool fShowStartPage(bool f)  { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFB) | (f << 2)); return f; }
1180         @property ushort fSpareFlags(ushort f) {
1181             _bf2 = cast(ushort) ((_bf2 & ~0xFFFF0007) | ((f & 0x1FFF) << 3));
1182             return cast(ushort) (f & 0x1FFF);
1183         }
1184     }
1185     alias SHELLSTATE* LPSHELLSTATE;
1186 }
1187 
1188 static if (_WIN32_IE >= 0x500) {
1189     align(8) {
1190         struct SHDRAGIMAGE {
1191             SIZE sizeDragImage;
1192             POINT ptOffset;
1193             HBITMAP hbmpDragImage;
1194             COLORREF crColorKey;
1195         }
1196         alias SHDRAGIMAGE* LPSHDRAGIMAGE;
1197     }
1198 
1199     interface IDragSourceHelper : IUnknown {
1200         HRESULT InitializeFromBitmap(LPSHDRAGIMAGE pshdi, IDataObject pDataObject);
1201         HRESULT InitializeFromWindow(HWND hwnd, POINT* ppt, IDataObject pDataObject);
1202     }
1203 
1204     interface IDropTargetHelper : IUnknown {
1205         HRESULT DragEnter(HWND hwndTarget, IDataObject pDataObject, POINT* ppt, DWORD dwEffect);
1206         HRESULT DragLeave();
1207         HRESULT DragOver(POINT* ppt, DWORD dwEffect);
1208         HRESULT Drop(IDataObject pDataObject, POINT* ppt, DWORD dwEffect);
1209         HRESULT Show(BOOL fShow);
1210     }
1211 }
1212 
1213 extern (Windows):
1214 void SHAddToRecentDocs(UINT, PCVOID);
1215 LPITEMIDLIST SHBrowseForFolderA(PBROWSEINFOA);
1216 LPITEMIDLIST SHBrowseForFolderW(PBROWSEINFOW);
1217 void SHChangeNotify(LONG, UINT, PCVOID, PCVOID);
1218 HRESULT SHGetDataFromIDListA(LPSHELLFOLDER, LPCITEMIDLIST, int, PVOID, int);
1219 HRESULT SHGetDataFromIDListW(LPSHELLFOLDER, LPCITEMIDLIST, int, PVOID, int);
1220 HRESULT SHGetDesktopFolder(LPSHELLFOLDER*);
1221 HRESULT SHGetInstanceExplorer(IUnknown*);
1222 HRESULT SHGetMalloc(LPMALLOC*);
1223 BOOL SHGetPathFromIDListA(LPCITEMIDLIST, LPSTR);
1224 BOOL SHGetPathFromIDListW(LPCITEMIDLIST, LPWSTR);
1225 HRESULT SHGetSpecialFolderLocation(HWND, int, LPITEMIDLIST*);
1226 HRESULT SHLoadInProc(REFCLSID);
1227 
1228 static if (_WIN32_IE >= 0x400) {
1229     BOOL SHGetSpecialFolderPathA(HWND, LPSTR, int, BOOL);
1230     BOOL SHGetSpecialFolderPathW(HWND, LPWSTR, int, BOOL);
1231 }
1232 
1233 /* SHGetFolderPath in shfolder.dll on W9x, NT4, also in shell32.dll on W2K */
1234 HRESULT SHGetFolderPathA(HWND, int, HANDLE, DWORD, LPSTR);
1235 HRESULT SHGetFolderPathW(HWND, int, HANDLE, DWORD, LPWSTR);
1236 
1237 static if (_WIN32_WINNT >= 0x500) {
1238     INT SHGetIconOverlayIndexW(LPCWSTR pszIconPath, int iIconIndex);
1239     INT SHGetIconOverlayIndexA(LPCSTR pszIconPath, int iIconIndex);
1240     HRESULT SHGetFolderLocation(HWND, int, HANDLE, DWORD, LPITEMIDLIST*);
1241     INT SHCreateDirectoryExA(HWND, LPCSTR, LPSECURITY_ATTRIBUTES);
1242     INT SHCreateDirectoryExW(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES);
1243     HRESULT SHBindToParent(LPCITEMIDLIST, REFIID, VOID**, LPCITEMIDLIST*);
1244 }
1245 
1246 static if (_WIN32_WINNT >= 0x501) {
1247     enum {
1248         PRF_VERIFYEXISTS         = 0x0001,
1249         PRF_TRYPROGRAMEXTENSIONS = (0x0002 | PRF_VERIFYEXISTS),
1250         PRF_FIRSTDIRDEF          = 0x0004,
1251         PRF_DONTFINDLNK          = 0x0008,
1252         IDO_SHGIOI_SHARE         = 0x0FFFFFFF,
1253         IDO_SHGIOI_LINK          = 0x0FFFFFFE,
1254         IDO_SHGIOI_SLOWFILE      = 0x0FFFFFFD,
1255         IDO_SHGIOI_DEFAULT       = 0x0FFFFFFC
1256     }
1257 
1258     struct SHDESCRIPTIONID {
1259         DWORD dwDescriptionId;
1260         CLSID clsid;
1261     }
1262     alias SHDESCRIPTIONID* LPSHDESCRIPTIONID;
1263 
1264     BOOL PathResolve(LPWSTR, LPCWSTR*, UINT);
1265     HRESULT SHGetFolderPathAndSubDirA(HWND, int, HANDLE, DWORD, LPCSTR, LPSTR);
1266     HRESULT SHGetFolderPathAndSubDirW(HWND, int, HANDLE, DWORD, LPCWSTR, LPWSTR);
1267     HRESULT SHParseDisplayName(LPCWSTR, IBindCtx, LPITEMIDLIST, SFGAOF, SFGAOF*);
1268 }
1269 
1270 void SHGetSettings(LPSHELLFLAGSTATE, DWORD);
1271 
1272 static if (_WIN32_WINNT >= 0x500) {
1273     void SHGetSetSettings(LPSHELLSTATE, DWORD, BOOL);
1274     BOOL ILIsEqual(LPCITEMIDLIST, LPCITEMIDLIST);
1275     BOOL ILIsParent(LPCITEMIDLIST, LPCITEMIDLIST, BOOL);
1276     BOOL ILRemoveLastID(LPITEMIDLIST);
1277     HRESULT ILLoadFromStream(IStream, LPITEMIDLIST*);
1278     HRESULT ILSaveToStream(IStream, LPCITEMIDLIST);
1279     LPITEMIDLIST ILAppendID(LPITEMIDLIST, LPCSHITEMID, BOOL);
1280     LPITEMIDLIST ILClone(LPCITEMIDLIST);
1281     LPITEMIDLIST ILCloneFirst(LPCITEMIDLIST);
1282     LPITEMIDLIST ILCombine(LPCITEMIDLIST, LPCITEMIDLIST);
1283     LPITEMIDLIST ILFindChild(LPCITEMIDLIST, LPCITEMIDLIST);
1284     LPITEMIDLIST ILFindLastID(LPCITEMIDLIST);
1285     LPITEMIDLIST ILGetNext(LPCITEMIDLIST);
1286     UINT ILGetSize(LPCITEMIDLIST);
1287     void ILFree(LPITEMIDLIST);
1288 
1289     HRESULT SHCoCreateInstance(LPCWSTR, REFCLSID, IUnknown, REFIID, void**);
1290 }
1291 
1292 version (Unicode) {
1293     alias IShellExecuteHookW IShellExecuteHook;
1294     alias IShellLinkW IShellLink;
1295     alias BROWSEINFOW BROWSEINFO;
1296     alias SHBrowseForFolderW SHBrowseForFolder;
1297     alias SHGetDataFromIDListW SHGetDataFromIDList;
1298     alias SHGetPathFromIDListW SHGetPathFromIDList;
1299     static if (_WIN32_IE >= 0x400) {
1300         alias SHGetSpecialFolderPathW SHGetSpecialFolderPath;
1301     }
1302     alias SHGetFolderPathW SHGetFolderPath;
1303     static if (_WIN32_WINNT >= 0x500) {
1304         alias SHGetIconOverlayIndexW SHGetIconOverlayIndex;
1305         alias SHCreateDirectoryExW SHCreateDirectoryEx;
1306     }
1307     static if (_WIN32_WINNT >= 0x501) {
1308         alias SHGetFolderPathAndSubDirW SHGetFolderPathAndSubDir;
1309     }
1310     alias FILEDESCRIPTORW FILEDESCRIPTOR;
1311     alias LPFILEDESCRIPTORW LPFILEDESCRIPTOR;
1312     alias FILEGROUPDESCRIPTORW FILEGROUPDESCRIPTOR;
1313     alias LPFILEGROUPDESCRIPTORW LPFILEGROUPDESCRIPTOR;
1314 
1315 } else {
1316     alias IShellExecuteHookA IShellExecuteHook;
1317     alias IShellLinkA IShellLink;
1318     alias BROWSEINFOA BROWSEINFO;
1319     alias SHBrowseForFolderA SHBrowseForFolder;
1320     alias SHGetDataFromIDListA SHGetDataFromIDList;
1321     alias SHGetPathFromIDListA SHGetPathFromIDList;
1322     static if (_WIN32_IE >= 0x400) {
1323         alias SHGetSpecialFolderPathA SHGetSpecialFolderPath;
1324     }
1325     alias SHGetFolderPathA SHGetFolderPath;
1326     static if (_WIN32_WINNT >= 0x500) {
1327         alias SHGetIconOverlayIndexA SHGetIconOverlayIndex;
1328         alias SHCreateDirectoryExA SHCreateDirectoryEx;
1329     }
1330     static if (_WIN32_WINNT >= 0x501) {
1331         alias SHGetFolderPathAndSubDirA SHGetFolderPathAndSubDir;
1332     }
1333     alias FILEDESCRIPTORA FILEDESCRIPTOR;
1334     alias LPFILEDESCRIPTORA LPFILEDESCRIPTOR;
1335     alias FILEGROUPDESCRIPTORA FILEGROUPDESCRIPTOR;
1336     alias LPFILEGROUPDESCRIPTORA LPFILEGROUPDESCRIPTOR;
1337 }
1338 alias BROWSEINFO* PBROWSEINFO, LPBROWSEINFO;
1339 
1340 static if (_WIN32_WINNT >= 0x501) {
1341     interface IFolderView : IUnknown {
1342        HRESULT GetAutoArrange();
1343        HRESULT GetCurrentViewMode(UINT);
1344        HRESULT GetDefaultSpacing(POINT*);
1345        HRESULT GetFocusedItem(int*);
1346        HRESULT GetFolder(REFIID, PVOID*);
1347        HRESULT GetItemPosition(LPCITEMIDLIST, POINT*);
1348        HRESULT GetSelectionMarkedItem(int*);
1349        HRESULT GetSpacing(POINT*);
1350        HRESULT Item(int, LPITEMIDLIST*);
1351        HRESULT ItemCount(UINT, int*);
1352        HRESULT Items(UINT, REFIID, PVOID*);
1353        HRESULT SelectAndPositionItems(UINT, LPCITEMIDLIST*, POINT*, DWORD);
1354        HRESULT SelectItem(int, DWORD);
1355        HRESULT SetCurrentViewMode(UINT);
1356     }
1357     alias IFolderView LPFOLDERVIEW;
1358 }
1359