summary refs log tree commit diff stats
path: root/lib/windows/shellapi.nim
blob: fbbd1999abbb6a17abf520a1cfe094768e9b42d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
#
#
#            Nimrod's Runtime Library
#        (c) Copyright 2006 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#
# leave out unused functions so the unit can be used on win2000 as well

#+-------------------------------------------------------------------------
#
#  Microsoft Windows
#  Copyright (c) Microsoft Corporation. All rights reserved.
#
#  File: shellapi.h
#
#  Header translation by Marco van de Voort for Free Pascal Platform
#  SDK dl'ed January 2002
#
#--------------------------------------------------------------------------

#
#    shellapi.h -  SHELL.DLL functions, types, and definitions
#    Copyright (c) Microsoft Corporation. All rights reserved.

import
  Windows

type
  HDROP* = THandle
  UINT_PTR* = ptr UINT
  DWORD_PTR* = ptr DWORD
  pHICON* = ptr HICON
  pBool* = ptr BOOL
  STARTUPINFOW* = record      # a guess. Omission should get fixed in Windows.
    cb*: DWORD
    lpReserved*: LPTSTR
    lpDesktop*: LPTSTR
    lpTitle*: LPTSTR
    dwX*: DWORD
    dwY*: DWORD
    dwXSize*: DWORD
    dwYSize*: DWORD
    dwXCountChars*: DWORD
    dwYCountChars*: DWORD
    dwFillAttribute*: DWORD
    dwFlags*: DWORD
    wShowWindow*: int16
    cbReserved2*: int16
    lpReserved2*: LPBYTE
    hStdInput*: HANDLE
    hStdOutput*: HANDLE
    hStdError*: HANDLE

  LPSTARTUPINFOW* = ptr STARTUPINFOW
  TSTARTUPINFOW* = STARTUPINFOW
  PSTARTUPINFOW* = ptr STARTUPINFOW #unicode

proc DragQueryFileA*(arg1: HDROP, arg2: UINT, arg3: LPSTR, arg4: UINT): UINT{.
    stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".}
proc DragQueryFileW*(arg1: HDROP, arg2: UINT, arg3: LPWSTR, arg4: UINT): UINT{.
    stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".}
proc DragQueryFile*(arg1: HDROP, arg2: UINT, arg3: LPSTR, arg4: UINT): UINT{.
    stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".}
proc DragQueryFile*(arg1: HDROP, arg2: UINT, arg3: LPWSTR, arg4: UINT): UINT{.
    stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".}
proc DragQueryPoint*(arg1: HDROP, arg2: LPPOINT): BOOL{.stdcall,
    dynlib: "shell32.dll", importc: "DragQueryPoint".}
proc DragFinish*(arg1: HDROP){.stdcall, dynlib: "shell32.dll",
                               importc: "DragFinish".}
proc DragAcceptFiles*(hwnd: HWND, arg2: BOOL){.stdcall, dynlib: "shell32.dll",
    importc: "DragAcceptFiles".}
proc ShellExecuteA*(HWND: hwnd, lpOperation: LPCSTR, lpFile: LPCSTR,
                    lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{.
    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
proc ShellExecuteW*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR,
                    lpParameters: LPCWSTR, lpDirectory: LPCWSTR, nShowCmd: int32): HInst{.
    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".}
proc ShellExecute*(HWND: hwnd, lpOperation: LPCSTR, lpFile: LPCSTR,
                   lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{.
    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
proc ShellExecute*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR,
                   lpParameters: LPCWSTR, lpDirectory: LPCWSTR, nShowCmd: int32): HInst{.
    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".}
proc FindExecutableA*(lpFile: LPCSTR, lpDirectory: LPCSTR, lpResult: LPSTR): HInst{.
    stdcall, dynlib: "shell32.dll", importc: "FindExecutableA".}
proc FindExecutableW*(lpFile: LPCWSTR, lpDirectory: LPCWSTR, lpResult: LPWSTR): HInst{.
    stdcall, dynlib: "shell32.dll", importc: "FindExecutableW".}
proc FindExecutable*(lpFile: LPCSTR, lpDirectory: LPCSTR, lpResult: LPSTR): HInst{.
    stdcall, dynlib: "shell32.dll", importc: "FindExecutableA".}
proc FindExecutable*(lpFile: LPCWSTR, lpDirectory: LPCWSTR, lpResult: LPWSTR): HInst{.
    stdcall, dynlib: "shell32.dll", importc: "FindExecutableW".}
proc CommandLineToArgvW*(lpCmdLine: LPCWSTR, pNumArgs: ptr int32): pLPWSTR{.
    stdcall, dynlib: "shell32.dll", importc: "CommandLineToArgvW".}
proc ShellAboutA*(HWND: hWnd, szApp: LPCSTR, szOtherStuff: LPCSTR, HICON: hIcon): int32{.
    stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".}
proc ShellAboutW*(HWND: hWnd, szApp: LPCWSTR, szOtherStuff: LPCWSTR,
                  HICON: hIcon): int32{.stdcall, dynlib: "shell32.dll",
                                        importc: "ShellAboutW".}
proc ShellAbout*(HWND: hWnd, szApp: LPCSTR, szOtherStuff: LPCSTR, HICON: hIcon): int32{.
    stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".}
proc ShellAbout*(HWND: hWnd, szApp: LPCWSTR, szOtherStuff: LPCWSTR, HICON: hIcon): int32{.
    stdcall, dynlib: "shell32.dll", importc: "ShellAboutW".}
proc DuplicateIcon*(hinst: HINST, HICON: hIcon): HIcon{.stdcall,
    dynlib: "shell32.dll", importc: "DuplicateIcon".}
proc ExtractAssociatedIconA*(hInst: HINST, lpIconPath: LPSTR, lpiIcon: LPWORD): HICON{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconA".}
proc ExtractAssociatedIconW*(hInst: HINST, lpIconPath: LPWSTR, lpiIcon: LPWORD): HICON{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconW".}
proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPSTR, lpiIcon: LPWORD): HICON{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconA".}
proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPWSTR, lpiIcon: LPWORD): HICON{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconW".}
proc ExtractIconA*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: UINT): HICON{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".}
proc ExtractIconW*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: UINT): HICON{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".}
proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: UINT): HICON{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".}
proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: UINT): HICON{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".}
  # if(WINVER >= 0x0400)
type                          # init with sizeof(DRAGINFO)
  DRAGINFOA* = record
    uSize*: UINT
    pt*: POINT
    fNC*: BOOL
    lpFileList*: LPSTR
    grfKeyState*: DWORD

  TDRAGINFOA* = DRAGINFOA
  LPDRAGINFOA* = ptr DRAGINFOA # init with sizeof(DRAGINFO)
  DRAGINFOW* = record
    uSize*: UINT
    pt*: POINT
    fNC*: BOOL
    lpFileList*: LPWSTR
    grfKeyState*: DWORD

  TDRAGINFOW* = DRAGINFOW
  LPDRAGINFOW* = ptr DRAGINFOW

when defined(UNICODE):
  type
    DRAGINFO* = DRAGINFOW
    TDRAGINFO* = DRAGINFOW
    LPDRAGINFO* = LPDRAGINFOW
else:
  type
    DRAGINFO* = DRAGINFOA
    TDRAGINFO* = DRAGINFOW
    LPDRAGINFO* = LPDRAGINFOA
const
  ABM_NEW* = 0x00000000
  ABM_REMOVE* = 0x00000001
  ABM_QUERYPOS* = 0x00000002
  ABM_SETPOS* = 0x00000003
  ABM_GETSTATE* = 0x00000004
  ABM_GETTASKBARPOS* = 0x00000005
  ABM_ACTIVATE* = 0x00000006  # lParam == TRUE/FALSE means activate/deactivate
  ABM_GETAUTOHIDEBAR* = 0x00000007
  ABM_SETAUTOHIDEBAR* = 0x00000008 # this can fail at any time.  MUST check the result
                                   # lParam = TRUE/FALSE  Set/Unset
                                   # uEdge = what edge
  ABM_WINDOWPOSCHANGED* = 0x00000009
  ABM_SETSTATE* = 0x0000000A
  ABN_STATECHANGE* = 0x00000000 # these are put in the wparam of callback messages
  ABN_POSCHANGED* = 0x00000001
  ABN_FULLSCREENAPP* = 0x00000002
  ABN_WINDOWARRANGE* = 0x00000003 # lParam == TRUE means hide
                                  # flags for get state
  ABS_AUTOHIDE* = 0x00000001
  ABS_ALWAYSONTOP* = 0x00000002
  ABE_LEFT* = 0
  ABE_TOP* = 1
  ABE_RIGHT* = 2
  ABE_BOTTOM* = 3

type
  AppBarData* = record
    cbSize*: DWORD
    hWnd*: HWND
    uCallbackMessage*: UINT
    uEdge*: UINT
    rc*: RECT
    lParam*: LPARAM           # message specific

  TAPPBARDATA* = AppBarData
  PAPPBARDATA* = ptr AppBarData

proc SHAppBarMessage*(dwMessage: DWORD, pData: APPBARDATA): UINT_PTR{.stdcall,
    dynlib: "shell32.dll", importc: "SHAppBarMessage".}
  #
  #  EndAppBar
  #
proc DoEnvironmentSubstA*(szString: LPSTR, cchString: UINT): DWORD{.stdcall,
    dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".}
proc DoEnvironmentSubstW*(szString: LPWSTR, cchString: UINT): DWORD{.stdcall,
    dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".}
proc DoEnvironmentSubst*(szString: LPSTR, cchString: UINT): DWORD{.stdcall,
    dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".}
proc DoEnvironmentSubst*(szString: LPWSTR, cchString: UINT): DWORD{.stdcall,
    dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".}
  #Macro
proc EIRESID*(x: int32): int32
proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: pHICON,
                     phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall,
    dynlib: "shell32.dll", importc: "ExtractIconExA".}
proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: pHICON,
                     phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall,
    dynlib: "shell32.dll", importc: "ExtractIconExW".}
proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32,
                     phiconLarge: var HICON, phiconSmall: var HIcon,
                     nIcons: UINT): UINT{.stdcall, dynlib: "shell32.dll",
    importc: "ExtractIconExA".}
proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32,
                     phiconLarge: var HICON, phiconSmall: var HIcon,
                     nIcons: UINT): UINT{.stdcall, dynlib: "shell32.dll",
    importc: "ExtractIconExW".}
proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: pHICON,
                    phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall,
    dynlib: "shell32.dll", importc: "ExtractIconExA".}
proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: pHICON,
                    phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall,
    dynlib: "shell32.dll", importc: "ExtractIconExW".}
proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: var HICON,
                    phiconSmall: var HIcon, nIcons: UINT): UINT{.stdcall,
    dynlib: "shell32.dll", importc: "ExtractIconExA".}
proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32,
                    phiconLarge: var HICON, phiconSmall: var HIcon, nIcons: UINT): UINT{.
    stdcall, dynlib: "shell32.dll", importc: "ExtractIconExW".}
  #
  # Shell File Operations
  #
  #ifndef FO_MOVE  //these need to be kept in sync with the ones in shlobj.h}
const
  FO_MOVE* = 0x00000001
  FO_COPY* = 0x00000002
  FO_DELETE* = 0x00000003
  FO_RENAME* = 0x00000004
  FOF_MULTIDESTFILES* = 0x00000001
  FOF_CONFIRMMOUSE* = 0x00000002
  FOF_SILENT* = 0x00000004    # don't create progress/report
  FOF_RENAMEONCOLLISION* = 0x00000008
  FOF_NOCONFIRMATION* = 0x00000010 # Don't prompt the user.
  FOF_WANTMAPPINGHANDLE* = 0x00000020 # Fill in SHFILEOPSTRUCT.hNameMappings
  FOF_ALLOWUNDO* = 0x00000040 # Must be freed using SHFreeNameMappings
  FOF_FILESONLY* = 0x00000080 # on *.*, do only files
  FOF_SIMPLEPROGRESS* = 0x00000100 # means don't show names of files
  FOF_NOCONFIRMMKDIR* = 0x00000200 # don't confirm making any needed dirs
  FOF_NOERRORUI* = 0x00000400 # don't put up error UI
  FOF_NOCOPYSECURITYATTRIBS* = 0x00000800 # dont copy NT file Security Attributes
  FOF_NORECURSION* = 0x00001000 # don't recurse into directories.
                                #if (_WIN32_IE >= 0x0500)
  FOF_NO_CONNECTED_ELEMENTS* = 0x00002000 # don't operate on connected elements.
  FOF_WANTNUKEWARNING* = 0x00004000 # during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
                                    #endif
                                    #if (_WIN32_WINNT >= 0x0501)
  FOF_NORECURSEREPARSE* = 0x00008000 # treat reparse points as objects, not containers
                                     #endif

type
  FILEOP_FLAGS* = int16

const
  PO_DELETE* = 0x00000013     # printer is being deleted
  PO_RENAME* = 0x00000014     # printer is being renamed
  PO_PORTCHANGE* = 0x00000020 # port this printer connected to is being changed
                              # if this id is set, the strings received by
                              # the copyhook are a doubly-null terminated
                              # list of strings.  The first is the printer
                              # name and the second is the printer port.
  PO_REN_PORT* = 0x00000034   # PO_RENAME and PO_PORTCHANGE at same time.
                              # no POF_ flags currently defined

type
  PRINTEROP_FLAGS* = int16 #endif}
                           # FO_MOVE
                           # implicit parameters are:
                           #      if pFrom or pTo are unqualified names the current directories are
                           #      taken from the global current drive/directory settings managed
                           #      by Get/SetCurrentDrive/Directory
                           #
                           #      the global confirmation settings
                           # only used if FOF_SIMPLEPROGRESS

type
  SHFILEOPSTRUCTA* = record
    hwnd*: HWND
    wFunc*: UINT
    pFrom*: LPCSTR
    pTo*: LPCSTR
    fFlags*: FILEOP_FLAGS
    fAnyOperationsAborted*: BOOL
    hNameMappings*: LPVOID
    lpszProgressTitle*: LPCSTR # only used if FOF_SIMPLEPROGRESS

  TSHFILEOPSTRUCTA* = SHFILEOPSTRUCTA
  LPSHFILEOPSTRUCTA* = ptr SHFILEOPSTRUCTA
  SHFILEOPSTRUCTW* = record
    hwnd*: HWND
    wFunc*: UINT
    pFrom*: LPCWSTR
    pTo*: LPCWSTR
    fFlags*: FILEOP_FLAGS
    fAnyOperationsAborted*: BOOL
    hNameMappings*: LPVOID
    lpszProgressTitle*: LPCWSTR

  TSHFILEOPSTRUCTW* = SHFILEOPSTRUCTW
  LPSHFILEOPSTRUCTW* = ptr SHFILEOPSTRUCTW

when defined(UNICODE):
  type
    SHFILEOPSTRUCT* = SHFILEOPSTRUCTW
    TSHFILEOPSTRUCT* = SHFILEOPSTRUCTW
    LPSHFILEOPSTRUCT* = LPSHFILEOPSTRUCTW
else:
  type
    SHFILEOPSTRUCT* = SHFILEOPSTRUCTA
    TSHFILEOPSTRUCT* = SHFILEOPSTRUCTA
    LPSHFILEOPSTRUCT* = LPSHFILEOPSTRUCTA
proc SHFileOperationA*(lpFileOp: LPSHFILEOPSTRUCTA): int32{.stdcall,
    dynlib: "shell32.dll", importc: "SHFileOperationA".}
proc SHFileOperationW*(lpFileOp: LPSHFILEOPSTRUCTW): int32{.stdcall,
    dynlib: "shell32.dll", importc: "SHFileOperationW".}
proc SHFileOperation*(lpFileOp: LPSHFILEOPSTRUCTA): int32{.stdcall,
    dynlib: "shell32.dll", importc: "SHFileOperationA".}
proc SHFileOperation*(lpFileOp: LPSHFILEOPSTRUCTW): int32{.stdcall,
    dynlib: "shell32.dll", importc: "SHFileOperationW".}
proc SHFreeNameMappings*(hNameMappings: THandle){.stdcall,
    dynlib: "shell32.dll", importc: "SHFreeNameMappings".}
type
  SHNAMEMAPPINGA* = record
    pszOldPath*: LPSTR
    pszNewPath*: LPSTR
    cchOldPath*: int32
    cchNewPath*: int32

  TSHNAMEMAPPINGA* = SHNAMEMAPPINGA
  LPSHNAMEMAPPINGA* = ptr SHNAMEMAPPINGA
  SHNAMEMAPPINGW* = record
    pszOldPath*: LPWSTR
    pszNewPath*: LPWSTR
    cchOldPath*: int32
    cchNewPath*: int32

  TSHNAMEMAPPINGW* = SHNAMEMAPPINGW
  LPSHNAMEMAPPINGW* = ptr SHNAMEMAPPINGW

when not(defined(UNICODE)):
  type
    SHNAMEMAPPING* = SHNAMEMAPPINGW
    TSHNAMEMAPPING* = SHNAMEMAPPINGW
    LPSHNAMEMAPPING* = LPSHNAMEMAPPINGW
else:
  type
    SHNAMEMAPPING* = SHNAMEMAPPINGA
    TSHNAMEMAPPING* = SHNAMEMAPPINGA
    LPSHNAMEMAPPING* = LPSHNAMEMAPPINGA
#
# End Shell File Operations
#
#
#  Begin ShellExecuteEx and family
#
# ShellExecute() and ShellExecuteEx() error codes
# regular WinExec() codes

const
  SE_ERR_FNF* = 2             # file not found
  SE_ERR_PNF* = 3             # path not found
  SE_ERR_ACCESSDENIED* = 5    # access denied
  SE_ERR_OOM* = 8             # out of memory
  SE_ERR_DLLNOTFOUND* = 32    # endif   WINVER >= 0x0400
                              # error values for ShellExecute() beyond the regular WinExec() codes
  SE_ERR_SHARE* = 26
  SE_ERR_ASSOCINCOMPLETE* = 27
  SE_ERR_DDETIMEOUT* = 28
  SE_ERR_DDEFAIL* = 29
  SE_ERR_DDEBUSY* = 30
  SE_ERR_NOASSOC* = 31        #if(WINVER >= 0x0400)}
                              # Note CLASSKEY overrides CLASSNAME
  SEE_MASK_CLASSNAME* = 0x00000001
  SEE_MASK_CLASSKEY* = 0x00000003 # Note INVOKEIDLIST overrides IDLIST
  SEE_MASK_IDLIST* = 0x00000004
  SEE_MASK_INVOKEIDLIST* = 0x0000000C
  SEE_MASK_ICON* = 0x00000010
  SEE_MASK_HOTKEY* = 0x00000020
  SEE_MASK_NOCLOSEPROCESS* = 0x00000040
  SEE_MASK_CONNECTNETDRV* = 0x00000080
  SEE_MASK_FLAG_DDEWAIT* = 0x00000100
  SEE_MASK_DOENVSUBST* = 0x00000200
  SEE_MASK_FLAG_NO_UI* = 0x00000400
  SEE_MASK_UNICODE* = 0x00004000
  SEE_MASK_NO_CONSOLE* = 0x00008000
  SEE_MASK_ASYNCOK* = 0x00100000
  SEE_MASK_HMONITOR* = 0x00200000 #if (_WIN32_IE >= 0x0500)
  SEE_MASK_NOQUERYCLASSSTORE* = 0x01000000
  SEE_MASK_WAITFORINPUTIDLE* = 0x02000000 #endif  (_WIN32_IE >= 0x500)
                                          #if (_WIN32_IE >= 0x0560)
  SEE_MASK_FLAG_LOG_USAGE* = 0x04000000 #endif
                                        # (_WIN32_IE >= 0x560)

type
  SHELLEXECUTEINFOA* = record
    cbSize*: DWORD
    fMask*: ULONG
    hwnd*: HWND
    lpVerb*: LPCSTR
    lpFile*: LPCSTR
    lpParameters*: LPCSTR
    lpDirectory*: LPCSTR
    nShow*: int32
    hInstApp*: HINST
    lpIDList*: LPVOID
    lpClass*: LPCSTR
    hkeyClass*: HKEY
    dwHotKey*: DWORD
    hMonitor*: HANDLE         # also: hIcon
    hProcess*: HANDLE

  TSHELLEXECUTEINFOA* = SHELLEXECUTEINFOA
  LPSHELLEXECUTEINFOA* = ptr SHELLEXECUTEINFOA
  SHELLEXECUTEINFOW* = record
    cbSize*: DWORD
    fMask*: ULONG
    hwnd*: HWND
    lpVerb*: lpcwstr
    lpFile*: lpcwstr
    lpParameters*: lpcwstr
    lpDirectory*: lpcwstr
    nShow*: int32
    hInstApp*: HINST
    lpIDList*: LPVOID
    lpClass*: LPCWSTR
    hkeyClass*: HKEY
    dwHotKey*: DWORD
    hMonitor*: HANDLE         # also: hIcon
    hProcess*: HANDLE

  TSHELLEXECUTEINFOW* = SHELLEXECUTEINFOW
  LPSHELLEXECUTEINFOW* = ptr SHELLEXECUTEINFOW

when defined(UNICODE):
  type
    SHELLEXECUTEINFO* = SHELLEXECUTEINFOW
    TSHELLEXECUTEINFO* = SHELLEXECUTEINFOW
    LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOW
else:
  type
    SHELLEXECUTEINFO* = SHELLEXECUTEINFOA
    TSHELLEXECUTEINFO* = SHELLEXECUTEINFOA
    LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOA
proc ShellExecuteExA*(lpExecInfo: LPSHELLEXECUTEINFOA): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "ShellExecuteExA".}
proc ShellExecuteExW*(lpExecInfo: LPSHELLEXECUTEINFOW): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "ShellExecuteExW".}
proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOA): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "ShellExecuteExA".}
proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOW): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "ShellExecuteExW".}
proc WinExecErrorA*(HWND: hwnd, error: int32, lpstrFileName: LPCSTR,
                    lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll",
    importc: "WinExecErrorA".}
proc WinExecErrorW*(HWND: hwnd, error: int32, lpstrFileName: LPCWSTR,
                    lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll",
    importc: "WinExecErrorW".}
proc WinExecError*(HWND: hwnd, error: int32, lpstrFileName: LPCSTR,
                   lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll",
                                        importc: "WinExecErrorA".}
proc WinExecError*(HWND: hwnd, error: int32, lpstrFileName: LPCWSTR,
                   lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll",
    importc: "WinExecErrorW".}
type
  SHCREATEPROCESSINFOW* = record
    cbSize*: DWORD
    fMask*: ULONG
    hwnd*: HWND
    pszFile*: LPCWSTR
    pszParameters*: LPCWSTR
    pszCurrentDirectory*: LPCWSTR
    hUserToken*: HANDLE
    lpProcessAttributes*: LPSECURITY_ATTRIBUTES
    lpThreadAttributes*: LPSECURITY_ATTRIBUTES
    bInheritHandles*: BOOL
    dwCreationFlags*: DWORD
    lpStartupInfo*: LPSTARTUPINFOW
    lpProcessInformation*: LPPROCESS_INFORMATION

  TSHCREATEPROCESSINFOW* = SHCREATEPROCESSINFOW
  PSHCREATEPROCESSINFOW* = ptr SHCREATEPROCESSINFOW

proc SHCreateProcessAsUserW*(pscpi: PSHCREATEPROCESSINFOW): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHCreateProcessAsUserW".}
  #
  #  End ShellExecuteEx and family }
  #
  #
  # RecycleBin
  #
  # struct for query recycle bin info
type
  SHQUERYRBINFO* = record
    cbSize*: DWORD
    i64Size*: int64
    i64NumItems*: int64

  TSHQUERYRBINFO* = SHQUERYRBINFO
  LPSHQUERYRBINFO* = ptr SHQUERYRBINFO # flags for SHEmptyRecycleBin

const
  SHERB_NOCONFIRMATION* = 0x00000001
  SHERB_NOPROGRESSUI* = 0x00000002
  SHERB_NOSOUND* = 0x00000004

proc SHQueryRecycleBinA*(pszRootPath: LPCSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinA".}
proc SHQueryRecycleBinW*(pszRootPath: LPCWSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinW".}
proc SHQueryRecycleBin*(pszRootPath: LPCSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinA".}
proc SHQueryRecycleBin*(pszRootPath: LPCWSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinW".}
proc SHEmptyRecycleBinA*(hwnd: HWND, pszRootPath: LPCSTR, dwFlags: DWORD): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinA".}
proc SHEmptyRecycleBinW*(hwnd: HWND, pszRootPath: LPCWSTR, dwFlags: DWORD): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinW".}
proc SHEmptyRecycleBin*(hwnd: HWND, pszRootPath: LPCSTR, dwFlags: DWORD): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinA".}
proc SHEmptyRecycleBin*(hwnd: HWND, pszRootPath: LPCWSTR, dwFlags: DWORD): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinW".}
  #
  # end of RecycleBin
  #
  #
  # Tray notification definitions
  #
type
  NOTIFYICONDATAA* = record
    cbSize*: DWORD
    hWnd*: HWND
    uID*: UINT
    uFlags*: UINT
    uCallbackMessage*: UINT
    hIcon*: HICON
    szTip*: array[0..127, CHAR]
    dwState*: DWORD
    dwStateMask*: DWORD
    szInfo*: array[0..255, CHAR]
    uTimeout*: UINT           # also: uVersion
    szInfoTitle*: array[0..63, CHAR]
    dwInfoFlags*: DWORD
    guidItem*: TGUID

  TNOTIFYICONDATAA* = NOTIFYICONDATAA
  PNOTIFYICONDATAA* = ptr NOTIFYICONDATAA
  NOTIFYICONDATAW* = record
    cbSize*: DWORD
    hWnd*: HWND
    uID*: UINT
    uFlags*: UINT
    uCallbackMessage*: UINT
    hIcon*: HICON
    szTip*: array[0..127, WCHAR]
    dwState*: DWORD
    dwStateMask*: DWORD
    szInfo*: array[0..255, WCHAR]
    uTimeout*: UINT           # also uVersion : UINT
    szInfoTitle*: array[0..63, CHAR]
    dwInfoFlags*: DWORD
    guidItem*: TGUID

  TNOTIFYICONDATAW* = NOTIFYICONDATAW
  PNOTIFYICONDATAW* = ptr NOTIFYICONDATAW

when defined(UNICODE):
  type
    NOTIFYICONDATA* = NOTIFYICONDATAW
    TNOTIFYICONDATA* = NOTIFYICONDATAW
    PNOTIFYICONDATA* = PNOTIFYICONDATAW
else:
  type
    NOTIFYICONDATA* = NOTIFYICONDATAA
    TNOTIFYICONDATA* = NOTIFYICONDATAA
    PNOTIFYICONDATA* = PNOTIFYICONDATAA
const
  NIN_SELECT* = WM_USER + 0
  NINF_KEY* = 0x00000001
  NIN_KEYSELECT* = NIN_SELECT or NINF_KEY
  NIN_BALLOONSHOW* = WM_USER + 2
  NIN_BALLOONHIDE* = WM_USER + 3
  NIN_BALLOONTIMEOUT* = WM_USER + 4
  NIN_BALLOONUSERCLICK* = WM_USER + 5
  NIM_ADD* = 0x00000000
  NIM_MODIFY* = 0x00000001
  NIM_DELETE* = 0x00000002
  NIM_SETFOCUS* = 0x00000003
  NIM_SETVERSION* = 0x00000004
  NOTIFYICON_VERSION* = 3
  NIF_MESSAGE* = 0x00000001
  NIF_ICON* = 0x00000002
  NIF_TIP* = 0x00000004
  NIF_STATE* = 0x00000008
  NIF_INFO* = 0x00000010
  NIF_GUID* = 0x00000020
  NIS_HIDDEN* = 0x00000001
  NIS_SHAREDICON* = 0x00000002 # says this is the source of a shared icon
                               # Notify Icon Infotip flags
  NIIF_NONE* = 0x00000000     # icon flags are mutually exclusive
                              # and take only the lowest 2 bits
  NIIF_INFO* = 0x00000001
  NIIF_WARNING* = 0x00000002
  NIIF_ERROR* = 0x00000003
  NIIF_ICON_MASK* = 0x0000000F
  NIIF_NOSOUND* = 0x00000010

proc Shell_NotifyIconA*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".}
proc Shell_NotifyIconW*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".}
proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".}
proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".}
  #
  #       The SHGetFileInfo API provides an easy way to get attributes
  #       for a file given a pathname.
  #
  #         PARAMETERS
  #
  #           pszPath              file name to get info about
  #           dwFileAttributes     file attribs, only used with SHGFI_USEFILEATTRIBUTES
  #           psfi                 place to return file info
  #           cbFileInfo           size of structure
  #           uFlags               flags
  #
  #         RETURN
  #           TRUE if things worked
  #
  # out: icon
  # out: icon index
  # out: SFGAO_ flags
  # out: display name (or path)
  # out: type name
type
  SHFILEINFOA* = record
    hIcon*: HICON             # out: icon
    iIcon*: int32             # out: icon index
    dwAttributes*: DWORD      # out: SFGAO_ flags
    szDisplayName*: array[0..(MAX_PATH) - 1, CHAR] # out: display name (or path)
    szTypeName*: array[0..79, CHAR] # out: type name

  TSHFILEINFOA* = SHFILEINFOA
  pSHFILEINFOA* = ptr SHFILEINFOA
  SHFILEINFOW* = record
    hIcon*: HICON             # out: icon
    iIcon*: int32             # out: icon index
    dwAttributes*: DWORD      # out: SFGAO_ flags
    szDisplayName*: array[0..(MAX_PATH) - 1, WCHAR] # out: display name (or path)
    szTypeName*: array[0..79, WCHAR] # out: type name

  TSHFILEINFOW* = SHFILEINFOW
  pSHFILEINFOW* = ptr SHFILEINFOW

when defined(UNICODE):
  type
    SHFILEINFO* = SHFILEINFOW
    TSHFILEINFO* = SHFILEINFOW
    pFILEINFO* = SHFILEINFOW
else:
  type
    SHFILEINFO* = SHFILEINFOA
    TSHFILEINFO* = SHFILEINFOA
    pFILEINFO* = SHFILEINFOA
# NOTE: This is also in shlwapi.h.  Please keep in synch.

const
  SHGFI_ICON* = 0x00000100    # get Icon
  SHGFI_DISPLAYNAME* = 0x00000200 # get display name
  SHGFI_TYPENAME* = 0x00000400 # get type name
  SHGFI_ATTRIBUTES* = 0x00000800 # get attributes
  SHGFI_ICONLOCATION* = 0x00001000 # get icon location
  SHGFI_EXETYPE* = 0x00002000 # return exe type
  SHGFI_SYSICONINDEX* = 0x00004000 # get system icon index
  SHGFI_LINKOVERLAY* = 0x00008000 # put a link overlay on icon
  SHGFI_SELECTED* = 0x00010000 # show icon in selected state
  SHGFI_ATTR_SPECIFIED* = 0x00020000 # get only specified attributes
  SHGFI_LARGEICON* = 0x00000000 # get large icon
  SHGFI_SMALLICON* = 0x00000001 # get small icon
  SHGFI_OPENICON* = 0x00000002 # get open icon
  SHGFI_SHELLICONSIZE* = 0x00000004 # get shell size icon
  SHGFI_PIDL* = 0x00000008    # pszPath is a pidl
  SHGFI_USEFILEATTRIBUTES* = 0x00000010 # use passed dwFileAttribute
  SHGFI_ADDOVERLAYS* = 0x00000020 # apply the appropriate overlays
  SHGFI_OVERLAYINDEX* = 0x00000040 # Get the index of the overlay
                                   # in the upper 8 bits of the iIcon

proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD,
                     psfi: pSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
                     psfi: pSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD,
                    psfi: pSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD,
                     psfi: var TSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
                     psfi: var TSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD,
                    psfi: var TSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
proc SHGetFileInfo*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
                    psfi: var TSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
proc SHGetDiskFreeSpaceExA*(pszDirectoryName: LPCSTR,
                            pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
                            pulTotalNumberOfBytes: pULARGE_INTEGER,
                            pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
proc SHGetDiskFreeSpaceExW*(pszDirectoryName: LPCWSTR,
                            pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
                            pulTotalNumberOfBytes: pULARGE_INTEGER,
                            pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCSTR,
                           pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
                           pulTotalNumberOfBytes: pULARGE_INTEGER,
                           pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
proc SHGetDiskFreeSpace*(pszDirectoryName: LPCSTR,
                         pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
                         pulTotalNumberOfBytes: pULARGE_INTEGER,
                         pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCWSTR,
                           pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
                           pulTotalNumberOfBytes: pULARGE_INTEGER,
                           pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
proc SHGetDiskFreeSpace*(pszDirectoryName: LPCWSTR,
                         pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
                         pulTotalNumberOfBytes: pULARGE_INTEGER,
                         pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
proc SHGetNewLinkInfoA*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR,
                        pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".}
proc SHGetNewLinkInfoW*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR,
                        pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".}
proc SHGetNewLinkInfo*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR,
                       pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".}
proc SHGetNewLinkInfo*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR,
                       pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".}
const
  SHGNLI_PIDL* = 0x00000001   # pszLinkTo is a pidl
  SHGNLI_PREFIXNAME* = 0x00000002 # Make name "Shortcut to xxx"
  SHGNLI_NOUNIQUE* = 0x00000004 # don't do the unique name generation
  SHGNLI_NOLNK* = 0x00000008  # don't add ".lnk" extension
  PRINTACTION_OPEN* = 0
  PRINTACTION_PROPERTIES* = 1
  PRINTACTION_NETINSTALL* = 2
  PRINTACTION_NETINSTALLLINK* = 3
  PRINTACTION_TESTPAGE* = 4
  PRINTACTION_OPENNETPRN* = 5
  PRINTACTION_DOCUMENTDEFAULTS* = 6
  PRINTACTION_SERVERPROPERTIES* = 7

proc SHInvokePrinterCommandA*(HWND: hwnd, uAction: UINT, lpBuf1: LPCSTR,
                              lpBuf2: LPCSTR, fModal: Bool): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".}
proc SHInvokePrinterCommandW*(HWND: hwnd, uAction: UINT, lpBuf1: LPCWSTR,
                              lpBuf2: LPCWSTR, fModal: Bool): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
proc SHInvokePrinterCommand*(HWND: hwnd, uAction: UINT, lpBuf1: LPCSTR,
                             lpBuf2: LPCSTR, fModal: Bool): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".}
proc SHInvokePrinterCommand*(HWND: hwnd, uAction: UINT, lpBuf1: LPCWSTR,
                             lpBuf2: LPCWSTR, fModal: Bool): Bool{.stdcall,
    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
proc SHLoadNonloadedIconOverlayIdentifiers*(): HResult{.stdcall,
    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
proc SHIsFileAvailableOffline*(pwszPath: LPCWSTR, pdwStatus: LPDWORD): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHIsFileAvailableOffline".}
const
  OFFLINE_STATUS_LOCAL* = 0x00000001 # If open, it's open locally
  OFFLINE_STATUS_REMOTE* = 0x00000002 # If open, it's open remotely
  OFFLINE_STATUS_INCOMPLETE* = 0x00000004 # The local copy is currently incomplete.
                                          # The file will not be available offline
                                          # until it has been synchronized.
                                          #  sets the specified path to use the string resource
                                          #  as the UI instead of the file system name

proc SHSetLocalizedName*(pszPath: LPWSTR, pszResModule: LPCWSTR, idsRes: int32): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHSetLocalizedName".}
proc SHEnumerateUnreadMailAccountsA*(hKeyUser: HKEY, dwIndex: DWORD,
                                     pszMailAddress: LPSTR,
                                     cchMailAddress: int32): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsA".}
proc SHEnumerateUnreadMailAccountsW*(hKeyUser: HKEY, dwIndex: DWORD,
                                     pszMailAddress: LPWSTR,
                                     cchMailAddress: int32): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsW".}
proc SHEnumerateUnreadMailAccounts*(hKeyUser: HKEY, dwIndex: DWORD,
                                    pszMailAddress: LPWSTR,
                                    cchMailAddress: int32): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsW".}
proc SHGetUnreadMailCountA*(hKeyUser: HKEY, pszMailAddress: LPCSTR,
                            pdwCount: PDWORD, pFileTime: PFILETIME,
                            pszShellExecuteCommand: LPSTR,
                            cchShellExecuteCommand: int32): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHGetUnreadMailCountA".}
proc SHGetUnreadMailCountW*(hKeyUser: HKEY, pszMailAddress: LPCWSTR,
                            pdwCount: PDWORD, pFileTime: PFILETIME,
                            pszShellExecuteCommand: LPWSTR,
                            cchShellExecuteCommand: int32): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHGetUnreadMailCountW".}
proc SHGetUnreadMailCount*(hKeyUser: HKEY, pszMailAddress: LPCSTR,
                           pdwCount: PDWORD, pFileTime: PFILETIME,
                           pszShellExecuteCommand: LPSTR,
                           cchShellExecuteCommand: int32): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHGetUnreadMailCountA".}
proc SHGetUnreadMailCount*(hKeyUser: HKEY, pszMailAddress: LPCWSTR,
                           pdwCount: PDWORD, pFileTime: PFILETIME,
                           pszShellExecuteCommand: LPWSTR,
                           cchShellExecuteCommand: int32): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHGetUnreadMailCountW".}
proc SHSetUnreadMailCountA*(pszMailAddress: LPCSTR, dwCount: DWORD,
                            pszShellExecuteCommand: LPCSTR): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHSetUnreadMailCountA".}
proc SHSetUnreadMailCountW*(pszMailAddress: LPCWSTR, dwCount: DWORD,
                            pszShellExecuteCommand: LPCWSTR): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHSetUnreadMailCountW".}
proc SHSetUnreadMailCount*(pszMailAddress: LPCSTR, dwCount: DWORD,
                           pszShellExecuteCommand: LPCSTR): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHSetUnreadMailCountA".}
proc SHSetUnreadMailCount*(pszMailAddress: LPCWSTR, dwCount: DWORD,
                           pszShellExecuteCommand: LPCWSTR): HRESULT{.stdcall,
    dynlib: "shell32.dll", importc: "SHSetUnreadMailCountW".}
proc SHGetImageList*(iImageList: int32, riid: TIID, ppvObj: ptr pointer): HRESULT{.
    stdcall, dynlib: "shell32.dll", importc: "SHGetImageList".}
const
  SHIL_LARGE* = 0             # normally 32x32
  SHIL_SMALL* = 1             # normally 16x16
  SHIL_EXTRALARGE* = 2
  SHIL_SYSSMALL* = 3          # like SHIL_SMALL, but tracks system small icon metric correctly
  SHIL_LAST* = SHIL_SYSSMALL

# implementation

proc EIRESID(x: int32): int32 =
  result = - int(x)