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 core/sys/windows/_shlobj.d)
8  */
9 module core.sys.windows.shlobj;
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 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 import core.sys.windows.winnetwk; // for NETRESOURCE
23 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 
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 
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 
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 
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 GetDefaultSearchGUID(GUID*);
859     HRESULT EnumSearches(IEnumExtraSearch*);
860     HRESULT GetDefaultColumn(DWORD, ULONG*, ULONG*);
861     HRESULT GetDefaultColumnState(UINT, SHCOLSTATEF*);
862     HRESULT GetDetailsEx(LPCITEMIDLIST, const(SHCOLUMNID)*, VARIANT*);
863     HRESULT GetDetailsOf(LPCITEMIDLIST, UINT, SHELLDETAILS*);
864     HRESULT MapColumnToSCID(UINT, SHCOLUMNID*);
865 }
866 alias IShellFolder2 LPSHELLFOLDER2;
867 
868 } /* _WIN32_IE >= 0x500 */
869 
870 interface ICopyHook : IUnknown {
871     UINT CopyCallback(HWND, UINT, UINT, LPCSTR, DWORD, LPCSTR, DWORD);
872 }
873 alias ICopyHook LPCOPYHOOK;
874 
875 interface IFileViewerSite : IUnknown {
876     HRESULT SetPinnedWindow(HWND);
877     HRESULT GetPinnedWindow(HWND*);
878 }
879 alias IFileViewerSite LPFILEVIEWERSITE;
880 
881 interface IFileViewer : IUnknown {
882     HRESULT ShowInitialize(LPFILEVIEWERSITE);
883     HRESULT Show(LPFVSHOWINFO);
884     HRESULT PrintTo(LPSTR, BOOL);
885 }
886 alias IFileViewer LPFILEVIEWER;
887 
888 interface IFileSystemBindData : IUnknown {
889     HRESULT SetFindData(const(WIN32_FIND_DATAW)*);
890     HRESULT GetFindData(WIN32_FIND_DATAW*);
891 }
892 
893 interface IPersistFolder : IPersist {
894     HRESULT GetClassID(CLSID*);
895     HRESULT Initialize(LPCITEMIDLIST);
896 }
897 alias IPersistFolder LPPERSISTFOLDER;
898 
899 static if (_WIN32_IE >= 0x400 || _WIN32_WINNT >= 0x500) {
900 
901 interface IPersistFolder2 : IPersistFolder {
902     HRESULT GetClassID(CLSID*);
903     HRESULT Initialize(LPCITEMIDLIST);
904     HRESULT GetCurFolder(LPITEMIDLIST*);
905 }
906 alias IPersistFolder2 LPPERSISTFOLDER2;
907 
908 }/* _WIN32_IE >= 0x400 || _WIN32_WINNT >= 0x500 */
909 
910 static if (_WIN32_IE >= 0x500) {
911 
912 interface IPersistFolder3 : IPersistFolder2 {
913     HRESULT GetClassID(CLSID*);
914     HRESULT Initialize(LPCITEMIDLIST);
915     HRESULT GetCurFolder(LPITEMIDLIST*);
916     HRESULT InitializeEx(IBindCtx, LPCITEMIDLIST, const(PERSIST_FOLDER_TARGET_INFO)*);
917     HRESULT GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO*);
918 }
919 alias IPersistFolder3 LPPERSISTFOLDER3;
920 
921 } /* _WIN32_IE >= 0x500 */
922 
923 alias IShellBrowser LPSHELLBROWSER;
924 alias IShellView LPSHELLVIEW;
925 
926 interface IShellBrowser : IOleWindow {
927     HRESULT GetWindow(HWND*);
928     HRESULT ContextSensitiveHelp(BOOL);
929     HRESULT InsertMenusSB(HMENU, LPOLEMENUGROUPWIDTHS);
930     HRESULT SetMenuSB(HMENU, HOLEMENU, HWND);
931     HRESULT RemoveMenusSB(HMENU);
932     HRESULT SetStatusTextSB(LPCOLESTR);
933     HRESULT EnableModelessSB(BOOL);
934     HRESULT TranslateAcceleratorSB(LPMSG, WORD);
935     HRESULT BrowseObject(LPCITEMIDLIST, UINT);
936     HRESULT GetViewStateStream(DWORD, LPSTREAM*);
937     HRESULT GetControlWindow(UINT, HWND*);
938     HRESULT SendControlMsg(UINT, UINT, WPARAM, LPARAM, LRESULT*);
939     HRESULT QueryActiveShellView(LPSHELLVIEW*);
940     HRESULT OnViewWindowActive(LPSHELLVIEW);
941     HRESULT SetToolbarItems(LPTBBUTTON, UINT, UINT);
942 }
943 
944 interface IShellView : IOleWindow {
945     HRESULT GetWindow(HWND*);
946     HRESULT ContextSensitiveHelp(BOOL);
947     HRESULT TranslateAccelerator(LPMSG);
948 //[No] #ifdef _FIX_ENABLEMODELESS_CONFLICT
949 //[No]  STDMETHOD(EnableModelessSV)(THIS_ BOOL) PURE;
950 //[Yes] #else
951     HRESULT EnableModeless(BOOL);
952 //[Yes] #endif
953     HRESULT UIActivate(UINT);
954     HRESULT Refresh();
955     HRESULT CreateViewWindow(IShellView, LPCFOLDERSETTINGS, LPSHELLBROWSER, RECT*, HWND*);
956     HRESULT DestroyViewWindow();
957     HRESULT GetCurrentInfo(LPFOLDERSETTINGS);
958     HRESULT AddPropertySheetPages(DWORD, LPFNADDPROPSHEETPAGE, LPARAM);
959     HRESULT SaveViewState();
960     HRESULT SelectItem(LPCITEMIDLIST, UINT);
961     HRESULT GetItemObject(UINT, REFIID, PVOID*);
962 }
963 
964 interface ICommDlgBrowser : IUnknown {
965     HRESULT OnDefaultCommand(IShellView);
966     HRESULT OnStateChange(IShellView, ULONG);
967     HRESULT IncludeObject(IShellView, LPCITEMIDLIST);
968 }
969 alias ICommDlgBrowser LPCOMMDLGBROWSER;
970 
971 alias GUID SHELLVIEWID;
972 
973 struct SV2CVW2_PARAMS {
974     DWORD cbSize = this.sizeof;
975     IShellView psvPrev;
976     FOLDERSETTINGS  *pfs;
977     IShellBrowser psbOwner;
978     RECT *prcView;
979 const(SHELLVIEWID)* pvid;
980     HWND hwndView;
981 }
982 alias SV2CVW2_PARAMS* LPSV2CVW2_PARAMS;
983 
984 interface IShellView2 : IShellView {
985     HRESULT GetWindow(HWND*);
986     HRESULT ContextSensitiveHelp(BOOL);
987     HRESULT TranslateAccelerator(LPMSG);
988 //[No] #ifdef _FIX_ENABLEMODELESS_CONFLICT
989 //[No]  STDMETHOD(EnableModelessSV)(THIS_ BOOL) PURE;
990 //[Yes] #else
991     HRESULT EnableModeless(BOOL);
992 //[Yes] #endif
993     HRESULT UIActivate(UINT);
994     HRESULT Refresh();
995     HRESULT CreateViewWindow(IShellView, LPCFOLDERSETTINGS, LPSHELLBROWSER, RECT*, HWND*);
996     HRESULT DestroyViewWindow();
997     HRESULT GetCurrentInfo(LPFOLDERSETTINGS);
998     HRESULT AddPropertySheetPages(DWORD, LPFNADDPROPSHEETPAGE, LPARAM);
999     HRESULT SaveViewState();
1000     HRESULT SelectItem(LPCITEMIDLIST, UINT);
1001     HRESULT GetItemObject(UINT, REFIID, PVOID*);
1002     HRESULT GetView(SHELLVIEWID*, ULONG);
1003     HRESULT CreateViewWindow2(LPSV2CVW2_PARAMS);
1004 }
1005 
1006 interface IShellExecuteHookA : IUnknown {
1007     HRESULT Execute(LPSHELLEXECUTEINFOA);
1008 }
1009 
1010 interface IShellExecuteHookW : IUnknown {
1011     HRESULT Execute(LPSHELLEXECUTEINFOW);
1012 }
1013 
1014 interface IShellIcon : IUnknown {
1015     HRESULT GetIconOf(LPCITEMIDLIST, UINT, PINT);
1016 }
1017 alias IShellIcon LPSHELLICON;
1018 
1019 struct SHELLFLAGSTATE {
1020     short _bf;
1021 /*
1022     BOOL fShowAllObjects : 1;
1023     BOOL fShowExtensions : 1;
1024     BOOL fNoConfirmRecycle : 1;
1025     BOOL fShowSysFiles : 1;
1026     BOOL fShowCompColor : 1;
1027     BOOL fDoubleClickInWebView : 1;
1028     BOOL fDesktopHTML : 1;
1029     BOOL fWin95Classic : 1;
1030     BOOL fDontPrettyPath : 1;
1031     BOOL fShowAttribCol : 1;
1032     BOOL fMapNetDrvBtn : 1;
1033     BOOL fShowInfoTip : 1;
1034     BOOL fHideIcons : 1;
1035     UINT fRestFlags : 3;
1036 */
1037     @property bool fShowAllObjects()       { return cast(bool) (_bf & 0x0001); }
1038     @property bool fShowExtensions()       { return cast(bool) (_bf & 0x0002); }
1039     @property bool fNoConfirmRecycle()     { return cast(bool) (_bf & 0x0004); }
1040     @property bool fShowSysFiles()         { return cast(bool) (_bf & 0x0008); }
1041     @property bool fShowCompColor()        { return cast(bool) (_bf & 0x0010); }
1042     @property bool fDoubleClickInWebView() { return cast(bool) (_bf & 0x0020); }
1043     @property bool fDesktopHTML()          { return cast(bool) (_bf & 0x0040); }
1044     @property bool fWin95Classic()         { return cast(bool) (_bf & 0x0080); }
1045     @property bool fDontPrettyPath()       { return cast(bool) (_bf & 0x0100); }
1046     @property bool fShowAttribCol()        { return cast(bool) (_bf & 0x0200); }
1047     @property bool fMapNetDrvBtn()         { return cast(bool) (_bf & 0x0400); }
1048     @property bool fShowInfoTip()          { return cast(bool) (_bf & 0x0800); }
1049     @property bool fHideIcons()            { return cast(bool) (_bf & 0x1000); }
1050     @property ubyte fRestFlags()           { return cast(ubyte) (_bf >> 13); }
1051 
1052     @property bool fShowAllObjects(bool f)       { _bf = cast(ushort) ((_bf & ~0xFFFE) | f);        return f; }
1053     @property bool fShowExtensions(bool f)       { _bf = cast(ushort) ((_bf & ~0xFFFD) | (f <<  1)); return f; }
1054     @property bool fNoConfirmRecycle(bool f)     { _bf = cast(ushort) ((_bf & ~0xFFFB) | (f <<  2)); return f; }
1055     @property bool fShowSysFiles(bool f)         { _bf = cast(ushort) ((_bf & ~0xFFF8) | (f <<  3)); return f; }
1056     @property bool fShowCompColor(bool f)        { _bf = cast(ushort) ((_bf & ~0xFFEF) | (f <<  4)); return f; }
1057     @property bool fDoubleClickInWebView(bool f) { _bf = cast(ushort) ((_bf & ~0xFFDF) | (f <<  5)); return f; }
1058     @property bool fDesktopHTML(bool f)          { _bf = cast(ushort) ((_bf & ~0xFFBF) | (f <<  6)); return f; }
1059     @property bool fWin95Classic(bool f)         { _bf = cast(ushort) ((_bf & ~0xFF8F) | (f <<  7)); return f; }
1060     @property bool fDontPrettyPath(bool f)       { _bf = cast(ushort) ((_bf & ~0xFEFF) | (f <<  8)); return f; }
1061     @property bool fShowAttribCol(bool f)        { _bf = cast(ushort) ((_bf & ~0xFDFF) | (f <<  9)); return f; }
1062     @property bool fMapNetDrvBtn(bool f)         { _bf = cast(ushort) ((_bf & ~0xFBFF) | (f << 10)); return f; }
1063     @property bool fShowInfoTip(bool f)          { _bf = cast(ushort) ((_bf & ~0xF8FF) | (f << 11)); return f; }
1064     @property bool fHideIcons(bool f)            { _bf = cast(ushort) ((_bf & ~0xEFFF) | (f << 12)); return f; }
1065     @property ubyte fRestFlags(ubyte f)          { _bf = cast(ushort) ((_bf & ~0x1FFF) | (f << 13)); return cast(ubyte) (f & 7); }
1066 }
1067 alias SHELLFLAGSTATE* LPSHELLFLAGSTATE;
1068 
1069 enum SSF_SHOWALLOBJECTS = 0x1;
1070 enum SSF_SHOWEXTENSIONS = 0x2;
1071 enum SSF_SHOWCOMPCOLOR = 0x8;
1072 enum SSF_SHOWSYSFILES = 0x20;
1073 enum SSF_DOUBLECLICKINWEBVIEW = 0x80;
1074 enum SSF_SHOWATTRIBCOL = 0x100;
1075 enum SSF_DESKTOPHTML = 0x200;
1076 enum SSF_WIN95CLASSIC = 0x400;
1077 enum SSF_DONTPRETTYPATH = 0x800;
1078 enum SSF_MAPNETDRVBUTTON = 0x1000;
1079 enum SSF_SHOWINFOTIP = 0x2000;
1080 enum SSF_HIDEICONS = 0x4000;
1081 enum SSF_NOCONFIRMRECYCLE = 0x8000;
1082 
1083 interface IShellIconOverlayIdentifier : IUnknown {
1084     HRESULT IsMemberOf(LPCWSTR, DWORD);
1085     HRESULT GetOverlayInfo(LPWSTR, int, int*, DWORD*);
1086     HRESULT GetPriority(int*);
1087 }
1088 
1089 enum ISIOI_ICONFILE  = 0x00000001;
1090 enum ISIOI_ICONINDEX = 0x00000002;
1091 
1092 static if (_WIN32_WINNT >= 0x500) {
1093     struct SHELLSTATE {
1094         uint _bf1;
1095         DWORD dwWin95Unused;
1096         UINT uWin95Unused;
1097         LONG lParamSort;
1098         int iSortDirection;
1099         UINT _version;
1100         UINT uNotUsed;
1101         uint _bf2;
1102     /*
1103         BOOL fShowAllObjects : 1;
1104         BOOL fShowExtensions : 1;
1105         BOOL fNoConfirmRecycle : 1;
1106         BOOL fShowSysFiles : 1;
1107         BOOL fShowCompColor : 1;
1108         BOOL fDoubleClickInWebView : 1;
1109         BOOL fDesktopHTML : 1;
1110         BOOL fWin95Classic : 1;
1111         BOOL fDontPrettyPath : 1;
1112         BOOL fShowAttribCol : 1;
1113         BOOL fMapNetDrvBtn : 1;
1114         BOOL fShowInfoTip : 1;
1115         BOOL fHideIcons : 1;
1116         BOOL fWebView : 1;
1117         BOOL fFilter : 1;
1118         BOOL fShowSuperHidden : 1;
1119         BOOL fNoNetCrawling : 1;
1120     */
1121         @property bool fShowAllObjects()       { return cast(bool) (_bf1 & 0x00000001); }
1122         @property bool fShowExtensions()       { return cast(bool) (_bf1 & 0x00000002); }
1123         @property bool fNoConfirmRecycle()     { return cast(bool) (_bf1 & 0x00000004); }
1124         @property bool fShowSysFiles()         { return cast(bool) (_bf1 & 0x00000008); }
1125         @property bool fShowCompColor()        { return cast(bool) (_bf1 & 0x00000010); }
1126         @property bool fDoubleClickInWebView() { return cast(bool) (_bf1 & 0x00000020); }
1127         @property bool fDesktopHTML()          { return cast(bool) (_bf1 & 0x00000040); }
1128         @property bool fWin95Classic()         { return cast(bool) (_bf1 & 0x00000080); }
1129         @property bool fDontPrettyPath()       { return cast(bool) (_bf1 & 0x00000100); }
1130         @property bool fShowAttribCol()        { return cast(bool) (_bf1 & 0x00000200); }
1131         @property bool fMapNetDrvBtn()         { return cast(bool) (_bf1 & 0x00000400); }
1132         @property bool fShowInfoTip()          { return cast(bool) (_bf1 & 0x00000800); }
1133         @property bool fHideIcons()            { return cast(bool) (_bf1 & 0x00001000); }
1134         @property bool fWebView()              { return cast(bool) (_bf1 & 0x00002000); }
1135         @property bool fFilter()               { return cast(bool) (_bf1 & 0x00004000); }
1136         @property bool fShowSuperHidden()      { return cast(bool) (_bf1 & 0x00008000); }
1137         @property bool fNoNetCrawling()        { return cast(bool) (_bf1 & 0x00010000); }
1138 
1139         @property bool fShowAllObjects(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFE) | f);         return f; }
1140         @property bool fShowExtensions(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFD) | (f <<  1)); return f; }
1141         @property bool fNoConfirmRecycle(bool f)     { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFB) | (f <<  2)); return f; }
1142         @property bool fShowSysFiles(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFF8) | (f <<  3)); return f; }
1143         @property bool fShowCompColor(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFEF) | (f <<  4)); return f; }
1144         @property bool fDoubleClickInWebView(bool f) { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFDF) | (f <<  5)); return f; }
1145         @property bool fDesktopHTML(bool f)          { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFBF) | (f <<  6)); return f; }
1146         @property bool fWin95Classic(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFF8F) | (f <<  7)); return f; }
1147         @property bool fDontPrettyPath(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFEFF) | (f <<  8)); return f; }
1148         @property bool fShowAttribCol(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFDFF) | (f <<  9)); return f; }
1149         @property bool fMapNetDrvBtn(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFBFF) | (f << 10)); return f; }
1150         @property bool fShowInfoTip(bool f)          { _bf1 = cast(uint) ((_bf1 & ~0xFFFFF8FF) | (f << 11)); return f; }
1151         @property bool fHideIcons(bool f)            { _bf1 = cast(uint) ((_bf1 & ~0xFFFFEFFF) | (f << 12)); return f; }
1152         @property bool fWebView(bool f)              { _bf1 = cast(uint) ((_bf1 & ~0xFFFFDFFF) | (f << 13)); return f; }
1153         @property bool fFilter(bool f)               { _bf1 = cast(uint) ((_bf1 & ~0xFFFFBFFF) | (f << 14)); return f; }
1154         @property bool fShowSuperHidden(bool f)      { _bf1 = cast(uint) ((_bf1 & ~0xFFFF8FFF) | (f << 15)); return f; }
1155         @property bool fNoNetCrawling(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFEFFFF) | (f << 16)); return f; }
1156     /*
1157         BOOL fSepProcess : 1;
1158         BOOL fStartPanelOn : 1;
1159         BOOL fShowStartPage : 1;
1160         UINT fSpareFlags : 13;
1161     */
1162         @property bool fSepProcess()           { return cast(bool) (_bf2 & 0x00000001); }
1163         @property bool fStartPanelOn()         { return cast(bool) (_bf2 & 0x00000002); }
1164         @property bool fShowStartPage()        { return cast(bool) (_bf2 & 0x00000004); }
1165         @property ushort fSpareFlags()         { return cast(ushort) ((_bf2 & 0x0000FFF8) >> 3); }
1166 
1167         @property bool fSepProcess(bool f)     { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFE) | f);        return f; }
1168         @property bool fStartPanelOn(bool f)   { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFD) | (f << 1)); return f; }
1169         @property bool fShowStartPage(bool f)  { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFB) | (f << 2)); return f; }
1170         @property ushort fSpareFlags(ushort f) {
1171             _bf2 = cast(ushort) ((_bf2 & ~0xFFFF0007) | ((f & 0x1FFF) << 3));
1172             return cast(ushort) (f & 0x1FFF);
1173         }
1174     }
1175     alias SHELLSTATE* LPSHELLSTATE;
1176 }
1177 
1178 static if (_WIN32_IE >= 0x500) {
1179     align(8) {
1180         struct SHDRAGIMAGE {
1181             SIZE sizeDragImage;
1182             POINT ptOffset;
1183             HBITMAP hbmpDragImage;
1184             COLORREF crColorKey;
1185         }
1186         alias SHDRAGIMAGE* LPSHDRAGIMAGE;
1187     }
1188 
1189     interface IDragSourceHelper : IUnknown {
1190         HRESULT InitializeFromBitmap(LPSHDRAGIMAGE pshdi, IDataObject pDataObject);
1191         HRESULT InitializeFromWindow(HWND hwnd, POINT* ppt, IDataObject pDataObject);
1192     }
1193 
1194     interface IDropTargetHelper : IUnknown {
1195         HRESULT DragEnter(HWND hwndTarget, IDataObject pDataObject, POINT* ppt, DWORD dwEffect);
1196         HRESULT DragLeave();
1197         HRESULT DragOver(POINT* ppt, DWORD dwEffect);
1198         HRESULT Drop(IDataObject pDataObject, POINT* ppt, DWORD dwEffect);
1199         HRESULT Show(BOOL fShow);
1200     }
1201 }
1202 
1203 extern (Windows):
1204 void SHAddToRecentDocs(UINT, PCVOID);
1205 LPITEMIDLIST SHBrowseForFolderA(PBROWSEINFOA);
1206 LPITEMIDLIST SHBrowseForFolderW(PBROWSEINFOW);
1207 void SHChangeNotify(LONG, UINT, PCVOID, PCVOID);
1208 HRESULT SHGetDataFromIDListA(LPSHELLFOLDER, LPCITEMIDLIST, int, PVOID, int);
1209 HRESULT SHGetDataFromIDListW(LPSHELLFOLDER, LPCITEMIDLIST, int, PVOID, int);
1210 HRESULT SHGetDesktopFolder(LPSHELLFOLDER*);
1211 HRESULT SHGetInstanceExplorer(IUnknown*);
1212 HRESULT SHGetMalloc(LPMALLOC*);
1213 BOOL SHGetPathFromIDListA(LPCITEMIDLIST, LPSTR);
1214 BOOL SHGetPathFromIDListW(LPCITEMIDLIST, LPWSTR);
1215 HRESULT SHGetSpecialFolderLocation(HWND, int, LPITEMIDLIST*);
1216 HRESULT SHLoadInProc(REFCLSID);
1217 
1218 static if (_WIN32_IE >= 0x400) {
1219     BOOL SHGetSpecialFolderPathA(HWND, LPSTR, int, BOOL);
1220     BOOL SHGetSpecialFolderPathW(HWND, LPWSTR, int, BOOL);
1221 }
1222 
1223 /* SHGetFolderPath in shfolder.dll on W9x, NT4, also in shell32.dll on W2K */
1224 HRESULT SHGetFolderPathA(HWND, int, HANDLE, DWORD, LPSTR);
1225 HRESULT SHGetFolderPathW(HWND, int, HANDLE, DWORD, LPWSTR);
1226 
1227 static if (_WIN32_WINNT >= 0x500) {
1228     INT SHGetIconOverlayIndexW(LPCWSTR pszIconPath, int iIconIndex);
1229     INT SHGetIconOverlayIndexA(LPCSTR pszIconPath, int iIconIndex);
1230     HRESULT SHGetFolderLocation(HWND, int, HANDLE, DWORD, LPITEMIDLIST*);
1231     INT SHCreateDirectoryExA(HWND, LPCSTR, LPSECURITY_ATTRIBUTES);
1232     INT SHCreateDirectoryExW(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES);
1233     HRESULT SHBindToParent(LPCITEMIDLIST, REFIID, VOID**, LPCITEMIDLIST*);
1234 }
1235 
1236 static if (_WIN32_WINNT >= 0x501) {
1237     enum {
1238         PRF_VERIFYEXISTS         = 0x0001,
1239         PRF_TRYPROGRAMEXTENSIONS = (0x0002 | PRF_VERIFYEXISTS),
1240         PRF_FIRSTDIRDEF          = 0x0004,
1241         PRF_DONTFINDLNK          = 0x0008,
1242         IDO_SHGIOI_SHARE         = 0x0FFFFFFF,
1243         IDO_SHGIOI_LINK          = 0x0FFFFFFE,
1244         IDO_SHGIOI_SLOWFILE      = 0x0FFFFFFD,
1245         IDO_SHGIOI_DEFAULT       = 0x0FFFFFFC
1246     }
1247 
1248     struct SHDESCRIPTIONID {
1249         DWORD dwDescriptionId;
1250         CLSID clsid;
1251     }
1252     alias SHDESCRIPTIONID* LPSHDESCRIPTIONID;
1253 
1254     BOOL PathResolve(LPWSTR, LPCWSTR*, UINT);
1255     HRESULT SHGetFolderPathAndSubDirA(HWND, int, HANDLE, DWORD, LPCSTR, LPSTR);
1256     HRESULT SHGetFolderPathAndSubDirW(HWND, int, HANDLE, DWORD, LPCWSTR, LPWSTR);
1257     HRESULT SHParseDisplayName(LPCWSTR, IBindCtx, LPITEMIDLIST, SFGAOF, SFGAOF*);
1258 }
1259 
1260 void SHGetSettings(LPSHELLFLAGSTATE, DWORD);
1261 
1262 static if (_WIN32_WINNT >= 0x500) {
1263     void SHGetSetSettings(LPSHELLSTATE, DWORD, BOOL);
1264     BOOL ILIsEqual(LPCITEMIDLIST, LPCITEMIDLIST);
1265     BOOL ILIsParent(LPCITEMIDLIST, LPCITEMIDLIST, BOOL);
1266     BOOL ILRemoveLastID(LPITEMIDLIST);
1267     HRESULT ILLoadFromStream(IStream, LPITEMIDLIST*);
1268     HRESULT ILSaveToStream(IStream, LPCITEMIDLIST);
1269     LPITEMIDLIST ILAppendID(LPITEMIDLIST, LPCSHITEMID, BOOL);
1270     LPITEMIDLIST ILClone(LPCITEMIDLIST);
1271     LPITEMIDLIST ILCloneFirst(LPCITEMIDLIST);
1272     LPITEMIDLIST ILCombine(LPCITEMIDLIST, LPCITEMIDLIST);
1273     LPITEMIDLIST ILFindChild(LPCITEMIDLIST, LPCITEMIDLIST);
1274     LPITEMIDLIST ILFindLastID(LPCITEMIDLIST);
1275     LPITEMIDLIST ILGetNext(LPCITEMIDLIST);
1276     UINT ILGetSize(LPCITEMIDLIST);
1277     void ILFree(LPITEMIDLIST);
1278 
1279     HRESULT SHCoCreateInstance(LPCWSTR, REFCLSID, IUnknown, REFIID, void**);
1280 }
1281 
1282 version (Unicode) {
1283     alias IShellExecuteHookW IShellExecuteHook;
1284     alias IShellLinkW IShellLink;
1285     alias BROWSEINFOW BROWSEINFO;
1286     alias SHBrowseForFolderW SHBrowseForFolder;
1287     alias SHGetDataFromIDListW SHGetDataFromIDList;
1288     alias SHGetPathFromIDListW SHGetPathFromIDList;
1289     static if (_WIN32_IE >= 0x400) {
1290         alias SHGetSpecialFolderPathW SHGetSpecialFolderPath;
1291     }
1292     alias SHGetFolderPathW SHGetFolderPath;
1293     static if (_WIN32_WINNT >= 0x500) {
1294         alias SHGetIconOverlayIndexW SHGetIconOverlayIndex;
1295         alias SHCreateDirectoryExW SHCreateDirectoryEx;
1296     }
1297     static if (_WIN32_WINNT >= 0x501) {
1298         alias SHGetFolderPathAndSubDirW SHGetFolderPathAndSubDir;
1299     }
1300     alias FILEDESCRIPTORW FILEDESCRIPTOR;
1301     alias LPFILEDESCRIPTORW LPFILEDESCRIPTOR;
1302     alias FILEGROUPDESCRIPTORW FILEGROUPDESCRIPTOR;
1303     alias LPFILEGROUPDESCRIPTORW LPFILEGROUPDESCRIPTOR;
1304 
1305 } else {
1306     alias IShellExecuteHookA IShellExecuteHook;
1307     alias IShellLinkA IShellLink;
1308     alias BROWSEINFOA BROWSEINFO;
1309     alias SHBrowseForFolderA SHBrowseForFolder;
1310     alias SHGetDataFromIDListA SHGetDataFromIDList;
1311     alias SHGetPathFromIDListA SHGetPathFromIDList;
1312     static if (_WIN32_IE >= 0x400) {
1313         alias SHGetSpecialFolderPathA SHGetSpecialFolderPath;
1314     }
1315     alias SHGetFolderPathA SHGetFolderPath;
1316     static if (_WIN32_WINNT >= 0x500) {
1317         alias SHGetIconOverlayIndexA SHGetIconOverlayIndex;
1318         alias SHCreateDirectoryExA SHCreateDirectoryEx;
1319     }
1320     static if (_WIN32_WINNT >= 0x501) {
1321         alias SHGetFolderPathAndSubDirA SHGetFolderPathAndSubDir;
1322     }
1323     alias FILEDESCRIPTORA FILEDESCRIPTOR;
1324     alias LPFILEDESCRIPTORA LPFILEDESCRIPTOR;
1325     alias FILEGROUPDESCRIPTORA FILEGROUPDESCRIPTOR;
1326     alias LPFILEGROUPDESCRIPTORA LPFILEGROUPDESCRIPTOR;
1327 }
1328 alias BROWSEINFO* PBROWSEINFO, LPBROWSEINFO;
1329 
1330 static if (_WIN32_WINNT >= 0x501) {
1331     interface IFolderView : IUnknown {
1332        HRESULT GetAutoArrange();
1333        HRESULT GetCurrentViewMode(UINT);
1334        HRESULT GetDefaultSpacing(POINT*);
1335        HRESULT GetFocusedItem(int*);
1336        HRESULT GetFolder(REFIID, PVOID*);
1337        HRESULT GetItemPosition(LPCITEMIDLIST, POINT*);
1338        HRESULT GetSelectionMarkedItem(int*);
1339        HRESULT GetSpacing(POINT*);
1340        HRESULT Item(int, LPITEMIDLIST*);
1341        HRESULT ItemCount(UINT, int*);
1342        HRESULT Items(UINT, REFIID, PVOID*);
1343        HRESULT SelectAndPositionItems(UINT, LPCITEMIDLIST*, POINT*, DWORD);
1344        HRESULT SelectItem(int, DWORD);
1345        HRESULT SetCurrentViewMode(UINT);
1346     }
1347     alias IFolderView LPFOLDERVIEW;
1348 }