forked from gabr42/OmniThreadLibrary
/
DSiWin32.pas
8858 lines (8282 loc) · 330 KB
/
DSiWin32.pas
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
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*:Collection of Win32/Win64 wrappers and helper functions.
@desc <pre>
Free for personal and commercial use. No rights reserved.
Maintainer : gabr
Contributors : ales, aoven, gabr, Lee_Nover, _MeSSiah_, Miha-R, Odisej, xtreme,
Brdaws, Gre-Gor, krho, Cavlji, radicalb, fora, M.C, MP002, Mitja,
Christian Wimmer, Tommi Prami, Miha, Craig Peterson, Tommaso Ercole.
Creation date : 2002-10-09
Last modification : 2015-10-20
Version : 1.84
</pre>*)(*
History:
1.84: 2015-10-20
- Updated DSiGetWindowsVersion for Windows 8.1, Windows 10, Windows Server 2012,
and Windows Server 2016.
1.83: 2015-09-22
- Added function DSiFileSizeAndTime.
1.82b: 2015-09-22
- File handle is open with least access in DSiGetFileTimes.
1.82a: 2015-07-29
- Fixed DSiGetClassName for Unicode.
1.82: 2015-04-24
- Affinity functions support up to 64 cores in 64-bit mode
(previously they were limited to 32 cores).
1.81: 2015-04-17
- Fixed DSiClassWndProc parameter types for Win64.
- DSiClassWndProc catches exceptions in instance's WndProc.
1.80: 2015-03-06
- Added function DSiGetFocusedWindow.
1.79d: 2015-01-06
- Compiles with D2007 and D2009 again.
1.79c: 2015-01-05
- Attribute is no longer checked in _DSiEnumFilesEx and returns all from FindFirst/Next.
1.79b: 2014-12-08
- Fixed attribute checking in _DSiEnumFilesEx.
1.79a: 2014-11-11
- DSiFileSize opens file with FILE_SHARE_READ OR FILE_SHARE_WRITE OR FILE_SHARE_DELETE.
1.79: 2014-10-15
- Creation flags can be passed to DSiExecute and DSiExecuteAndCapture.
1.78: 2014-10-09
- Added allowRoot parameter to DSiDeleteTree (default False).
- Added safety checks to DSiDeleteTree.
1.77: 2014-10-06
- Added another DSiExecute overload which returns TProcessInformation with active
process and thread handles (caller should CloseHandle them).
1.76: 2014-07-24
- Defined DSiRegisterUserFileAssoc and DSiUnregisterUserFileAssoc.
1.75: 2014-06-02
- Defined LCID constants.
1.74: 2014-05-12
- Defined CSIDL_PERSONAL constant.
- DSiGetFolderLocation uses SHGetFolderLocation instead of deprecated
SHGetSpecialFolderPath.
1.73: 2014-04-21
- DSiEnumFiles family has new parameter - ignoreDottedFolders. When True (default
is False), folders that start in a dot (for example, .UnitTests) will be skipped
during enumeration.
1.72e: 2013-10-27
- Fixed invalid control flow in DSiFileExtensionIs.
1.72d: 2013-10-14
- Removed compiler warnings in XE5.
1.72c: 2013-10-07
- Compiles with D2009 again.
1.72b: 2013-10-06
- Fixed enumeration routines to not return folders that don't match the mask.
1.72a: 2013-06-03
- [Tommaso Ercole] DSiAllocateHWnd accepts 'style' and 'parentWindow' parameter
which are by default set to (WS_EX_TOOLWINDOW OR WS_EX_NOACTIVATE) and
HWND_MESSAGE, respectively. These are suggested values for message-only windows
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms632680(v=vs.85).aspx).
Previously, these values were WS_EX_TOOLWINDOW and 0, respectively.
1.72: 2013-02-07
- Added function DSiIsCodeSigned.
1.71b: 2012-12-12
- Fixed parameter types in DSiClassWndProc.
1.71a: 2012-11-04
- TNonClientMetrics.cbSize is correctly initialized.
1.71: 2012-10-19
- Defined type DSiNativeInt and DSiNativeUInt which map to integer/cardinal on
Delphi XE and older.
- Fixed invalid casting in DSiAllocateHWnd.
- All internal DEFINEs were renamed with 'DSi' prefix.
1.70b: 2012-06-12
- DSiEnumFiles* will also enumerate hidden folders if 'attr' contains faHidden flag.
1.70a: 2012-05-22
- [Tommi Prami, MihaR] Defined ULONG_PTR and ULONGLONG for Delphis up to D2006.
1.70: 2012-05-21
- TDSiRegistry.ReadBool accepts 't' and 'true' as True.
1.69: 2012-05-18
- Added dynamically loaded API forwarder DSiGetLogicalProcessorInformation.
- Added function DSiGetLogicalProcessorInfo.
- Fixed a bug in DSiEnumFilesToOL.
1.68: 2012-05-16
- New function: DSiEnumFilesToOL.
1.67: 2012-05-15
- Callback functions are declared as anonymous delegates in D2009 and newer.
1.66: 2012-04-20
- TDSiRegistry.ReadBinary, WriteBinary now use RawByteString for data buffer.
1.65: 2012-02-06
- Implemented DSiSetFileTime and DSiSetFileTimes.
- Implemented DSiDateTimeToFileTime.
1.64b: 2012-01-11
- Set msg.Result := 0; in DSiClassWndProc.
1.64a: 2011-12-20
- DSiAllocateHWnd works in 64-bit mode.
- Fixed 64-bit DSiInterlockedExchangeAdd64.
1.64: 2011-12-16
- [GJ] Assembler implementation of the x64 version of Interlocked*64 family of functions.
1.63: 2011-10-21
- Interlocked*64 family implemented using Windows' InterlockedCompareExchange64
on Win64-bit platform.
- Removed dependency on the Consts unit.
- Scoped unit names are used in XE2.
1.62a: 2011-11-07
- Compiles with XE2 (in 32-bit mode).
1.62: 2011-09-26
- Implemented DSiGetThreadTime (two overloaded versions).
1.61c: 2011-07-26
- [miha] SetErrorMode (SEM_NOOPENFILEERRORBOX) is called before LoadLibrary to
prevent opening messagebox by Windows.
1.61b: 2011-06-27
- [tommi prami] Compiles with D7.
1.61a: 2011-05-06
- [achim] DSiAddApplicationToFirewallExceptionListXP could fail with "Unknown
resoveConflict" exception due to a syntax error.
1.61: 2011-03-01
- Faster DSiFileExtensionIs.
1.60: 2010-12-04
- When compiled with D2007 or newer, unit FileCtrl is not included.
1.59b: 2010-10-28
- Call UniqueString before calling CreateProcessW.
1.59a: 2010-09-25
- [Tommi Prami] Added types missing in Delphi 7.
1.59: 2010-09-24
- Added function DSiDisableStandby that will try to disable standby and hibernate
on Windows XP SP 2 and newer.
1.58a: 2010-09-19
- Define TStartupInfoW in Delphi 7 and earlier.
1.58: 2010-07-27
- DSiAddApplicationToFirewallExceptionList[Advanced|XP] got a new parameter
TDSiFwResolveConflict (default rcDuplicate) where the caller can specify
behaviour if the rule with the same name already exists.
[rcDuplicate = add new rule with the same name, rcOverwrite = remove all rules
with the same name and then add the new rule, rcSkip = leave existing rules
intact and don't add the new rule]
- Implemented DSiFindApplicationInFirewallExceptionList[Advanced|XP].
1.57a: 2010-07-20
- Bug fix in DSiAddApplicationToFirewallExceptionListAdvanced: setting
rule.ServiceName to '' caused fwPolicy2.Rules.Add(rule) to raise exception.
1.57: 2010-06-18
- DSiExecuteAsUser now calls CreateProcessWithLogonW if CreateProcessAsUser fails
with ERROR_PRIVILEGE_NOT_HELD (1314). Windows error code is now returned in a
parameter. Window station and desktop process-specific ACEs are removed in a
background thread when child process exits (thanks to Christian Wimmer to pointing
out this problem). If the username is not set, DSiExecuteAsUser still sets up
ACEs for window station/desktop access but ends calling CreateProcess and does
not remove ACEs at the end.
- Two overloaded versions of DSiExecuteAsUser are implemented. One is backwards
compatible and another introduces two parameters -
out processInfo: TProcessInformation and startInfo: PStartupInfo (default: nil).
If the latter is assigned, it will be used instead of the internally generated
TStartupInfo. This version does not close process and thread handle returned
in the TProcessInformation if 'wait' is False.
- Implemented DSiRemoveAceFromWindowStation and DSiRemoveAceFromDesktop.
- Added dynamically loaded API forwarders DSiCreateProcessWithLogonW,
DSiCreateEnvironmentBlock, DSiDestroyEnvironmentBlock and
DSiGetUserProfileDirectoryW.
- DSiAddAceTo[WindowStation|Desktop] will not add SID if it already exists in the
ACL.
1.56: 2010-06-10
- [Mitja] Clear the last error if CreateProcess succeeds in DSiExecuteAndCapture
(found a test case where CreateProcess succeeded but last error was 126).
- [Christian Wimmer] In Unicode Delphis, DSiOpenSCManager, DSiGetLongPathName,
DSiGetModuleFileNameEx, DSiGetProcessImageFileName, DSiSetDllDirectory, and
DSiSHEmptyRecycleBin were linking to the wrong verison of the API.
- [Christian Wimmer] DSiCreateProcessAsUser must make a local copy of the
commandLine parameter when using Unicode API because the API may modify the
contents of this parameter.
- Implemented DSiGetLogonSID, DSiAddAceToWindowStation and DSiAddAceToDesktop.
- Redesigned DSiExecuteAsUser.
1.55: 2010-04-12
- Implemented DSiHasElapsed64 and DSiElapsedTime64.
1.54: 2010-04-08
- Implemented DSiLogonAs and DSiVerifyPassword.
1.53c: 2010-02-01
- DSiGetProcAddress made public.
1.53b: 2009-12-15
- Fixed Delphi 5 compilation.
1.53a: 2009-11-24
- Fixed TDSiRegistry.ReadVariant and WriteVariant to work with varUString
(also fixes all sorts of TDSiRegistry problems in Delphi 2010.)
1.53: 2009-11-13
- Implemented DSiDeleteRegistryValue.
- Added parameter 'access' to the DSiKillRegistry.
1.52a: 2009-11-04
- [Mitja] Fixed allocation in DSiGetUserName.
- [Mitja] Also catch 'error' output in DSiExecuteAndCapture.
1.52: 2009-10-28
- DSiAddApplicationToFirewallExceptionList renamed to
DSiAddApplicationToFirewallExceptionListXP.
- Added DSiAddApplicationToFirewallExceptionListAdvanced which uses Advanced
Firewall interface, available on Vista+.
- DSiAddApplicationToFirewallExceptionList now calls either
DSiAddApplicationToFirewallExceptionListXP or
DSiAddApplicationToFirewallExceptionListAdvanced, depending on OS version.
- Implemented functions to remove application from the firewall exception list:
DSiRemoveApplicationFromFirewallExceptionList,
DSiRemoveApplicationFromFirewallExceptionListAdvanced,
DSiRemoveApplicationFromFirewallExceptionListXP.
1.51a: 2009-10-27
- Convert non-EOleSysError exceptions in DSiAddApplicationToFirewallExceptionList
into ERROR_INVALID_FUNCTION error.
1.51: 2009-10-22
- Added 'onNewLine' callback to the DSiExecuteAndCapture. This event reports
program output line-by-line in real time and it can extend total time allowed
for program execution.
1.50: 2009-10-20
- [Mitja] Updated DSiExecuteAndCapture: settable timeout, Unicode Delphi support,
LastError is set if CreateProcess fails.
- Implemented functions DSiGetSubstDrive and DSiGetSubstPath.
1.49: 2009-10-12
- Added 'access' parameter to the DSiWriteRegistry methods so that user can
request writing to the non-virtualized key when running on 64-bit system
(KEY_WOW64_64KEY).
1.48: 2009-10-09
- Defined TOSVersionInfoEx record and corresponding constants.
- Extended DSiGetWindowsVersion to return wvWinServer2008, wvWin7 and
wvWinServer2008R2.
- Extended DSiGetTrueWindowsVersion to return wvWinServer2008OrVistaSP1 and
wvWin7OrServer2008R2.
1.47a: 2009-09-03
- Added parameter connectionIsAvailable to the DSiGetNetworkResource.
1.47: 2009-05-22
- Added dynamically loaded API forwarder DSiGetTickCount64.
1.46: 2009-03-17
- Added dynamically loaded API forwarders DSiWow64DisableWow64FsRedirection and
DSiWow64RevertWow64FsRedirection.
- Implemented function DSiDisableWow64FsRedirection and DSiRevertWow64FsRedirection.
1.45: 2009-03-16
- Implemented DSiGetCurrentThreadHandle and DSiGetCurrentProcessHandle.
1.44a: 2009-02-28
- Added D2009 compatibility fixes to DSiGetFolderLocation, DSiGetNetworkResource,
DSiGetComputerName, DSiGetWindowsFolder.
- Fixed DSiGetTempFileName, DSiGetUserName.
1.44: 2009-02-05
- Added functions DSiAddApplicationToFirewallExceptionList and
DSiAddPortToFirewallExceptionList.
1.43: 2009-01-28
- Added functions DSiGetNetworkResource, DSiDisconnectFromNetworkResource.
1.42: 2009-01-23
- Added functions DSiGetGlobalMemoryStatus, DSiGlobalMemoryStatusEx.
1.41: 2008-08-20
- Delphi 2009 compatibility.
1.40c: 2008-07-14
- Bug fixed: It was not possible to use DSiTimeGetTime64 in parallel from multiple
threads
1.40b: 2008-07-11
- Forced {$T-} as the code doesn't compile in {$T+} state.
1.40a: 2008-06-23
- Added constants FILE_LIST_DIRECTORY, FILE_SHARE_FULL, FILE_ACTION_ADDED,
FILE_ACTION_REMOVED, FILE_ACTION_MODIFIED, FILE_ACTION_RENAMED_OLD_NAME,
FILE_ACTION_RENAMED_NEW_NAME.
1.40: 2008-05-30
- Added function DSiCopyFileAnimated.
1.39: 2008-05-05
- Added function DSiConnectToNetworkResource.
1.38: 2008-04-29
- Added functions to copy HTML format to and from the clipboard:
DSiIsHtmlFormatOnClipboard, DSiGetHtmlFormatFromClipboard,
DSiCopyHtmlFormatToClipboard.
1.37: 2008-03-27
- Created DSiInterlocked*64 family of functions by copying the code from
http://qc.borland.com/wc/qcmain.aspx?d=6212. Functions were written by
Will DeWitt Jr [edge@icehouse.net] and are included with permission.
- Implemented DSiYield.
1.36a: 2008-01-16
- Changed DSiIsAdmin to use big enough buffer for token data.
- Changed DSiIsAdmin to ignore SE_GROUP_ENABLED attribute because function was
sometimes incorrectly returning False.
1.36: 2007-12-29
- Added procedures DSiCenterRectInRect and DSiMakeRectFullyVisibleOnRect.
1.35: 2007-12-17
- Added DSiTerminateProcessById procedure.
1.34: 2007-12-03
- Added three performance counter helpers DSiPerfCounterToMS, DSiPerfCounterToUS,
and DSiQueryPerfCounterAsUS.
1.33: 2007-11-26
- Added function DSiTimeGetTime64.
1.32: 2007-11-13
- Added parameter 'parameters' to DSiCreateShortcut and DSiGetShortcutInfo.
- Added function DSiEditShortcut.
- Added function DSiInitFontToSystemDefault.
1.31: 2007-11-06
- Added SHGetSpecialFolderLocation folder constants: CSIDL_ALTSTARTUP,
CSIDL_CDBURN_AREA, CSIDL_COMMON_ALTSTARTUP, CSIDL_COMMON_DESKTOPDIRECTORY,
CSIDL_COMMON_FAVORITES, CSIDL_COMMON_MUSIC, CSIDL_COMMON_PICTURES,
CSIDL_COMMON_PROGRAMS, CSIDL_COMMON_STARTMENU, CSIDL_COMMON_STARTUP,
CSIDL_COMMON_TEMPLATES, CSIDL_COMMON_VIDEO, CSIDL_COMPUTERSNEARME,
CSIDL_CONNECTIONS, CSIDL_COOKIES, CSIDL_INTERNET, CSIDL_INTERNET_CACHE,
CSIDL_MYDOCUMENTS, CSIDL_MYMUSIC, CSIDL_MYVIDEO, CSIDL_PHOTOALBUMS,
CSIDL_PLAYLISTS, CSIDL_PRINTHOOD, CSIDL_PROFILE, CSIDL_RESOURCES,
CSIDL_SAMPLE_MUSIC, CSIDL_SAMPLE_PLAYLISTS, CSIDL_SAMPLE_PICTURES,
CSIDL_SAMPLE_VIDEOS.
- Added ShGetSpecialFolderLocation flags CSIDL_FLAG_DONT_UNEXPAND and
CSIDL_FLAG_DONT_VERIFY.
- Added dynamically loaded API forwarder DSiSetSuspendState.
- Added dynamically loaded API forwarders DSiEnumProcessModules,
DSiGetModuleFileNameEx, and DSiGetProcessImageFileName.
- Added function DSiGetProcessFileName.
- More stringent checking in DSiGetProcessWindow.
- Fixed DSiLoadLibrary so that it can be called before initialization section is
executed. Somehow, D2007 doesn't always call initialization sectins in correct
order >:-(
1.30: 2007-10-25
- Added dynamically loaded API forwarders DSiDwmEnableComposition and
DsiDwmIsCompositionEnabled.
- Added Aero group with functions DSiAeroDisable, DSiAeroEnable, and
DSiAeroIsEnabled.
1.29: 2007-10-03
- Added function DSiIsAdmin.
1.28a: 2007-09-12
- TDSiTimer properties changed from published to public.
1.28: 2007-07-25
- Added function DSiMoveFile.
- Small changes in DSiMoveOnReboot.
1.27: 2007-07-11
- Added two overloaded functions DSiGetThreadTimes.
1.26: 2007-06-13
- Added two overloaded function DSiFileExtensionIs.
1.25: 2007-05-30
- Added thread-safe alternative to (De)AllocateHwnd - DSi(De)AllocateHwnd.
- Added TDSiTimer - a TTimer clone that uses DSi(De)AllocateHwnd internally.
- New function DSiGetFolderSize.
- Bug fixed: GetProcAddress result was not checked in DSiRegisterActiveX.
1.24: 2007-03-21
- Added support for search depth limitation to DSiEnumFilesEx and
DSiEnumFilesToSL.
1.23: 2007-02-14
- New functions: DSiGetProcessTimes (two overloaded versions), DSiGetFileTimes,
DSiFileTimeToDateTime (two overloaded versions), DSiFileTimeToMicroSeconds,
DSiGetProcessMemoryInfo, DSiGetProcessMemory (two overloaded versions),
DSiIsWow64, DSiGetAppCompatFlags, DSiGetTrueWindowsVersion.
- New dynamically loaded API forwarder: DSiIsWow64Process.
- Added parameter 'access' to DSiReadRegistry, DSiRegistryKeyExists, and
DSiRegistryValueExists functions.
1.22: 2006-12-07
- New function: DSiGetFileTime.
- Added Windows Vista detection to DSiGetWindowsVersion.
1.21: 2006-08-14
- New functions: DSiFileExistsW, DSiDirectoryExistsW, DSiFileSizeW,
DSiCompressFile, DSiUncompressFile, DSiIsFileCompressed, DSiIsFileCompressedW.
1.20: 2006-06-20
- New function: DSiGetShortcutInfo.
1.19: 2006-05-15
- New functions: DSiEnumFilesToSL, DSiGetLongPathName.
1.18: 2006-04-11
- New function: DSiSetDllDirectory.
1.17a: 2006-04-05
- Exit DSiProcessMessages when WM_QUIT is received.
1.17: 2006-03-14
- New function: DSiRegistryValueExists.
- Added 'working dir' parameter to the DSiCreateShortcut function.
1.16: 2006-01-23
- New DSiExecuteAndCapture implementation, contributed by matej.
1.15b: 2005-12-19
- TDSiRegistry.ReadInteger can now also read 4-byte binary values.
1.15a: 2005-08-09
- Removed StrNew from DSiGetComputerName because it caused the result never to
be released.
1.15: 2005-07-11
- New function: DSiWin32CheckNullHandle.
1.14: 2005-06-09
- New function: DSiGetEnvironmentVariable.
- DSiExecuteAndCapture modified to return exit code in a (newly added) parameter
and fixed to work on fast computers.
1.13a: 2005-03-15
- Make DSiGetTempFileName return empty string when GetTempFileName fails.
1.13: 2005-02-12
- New functions: DSiExitWindows, DSiGetSystemLanguage, DSiGetKeyboardLayouts.
- New methods: TDSiRegistry.ReadBinary (two overloaded versions),
TDSiRegistry.WriteBinary (two overloaded versions).
- Added OLE string processing to TDSiRegistry.ReadVariant and
TDSiRegistry.WriteVariant.
- Exported helper functions UTF8Encode and UTF8Decode for old Delphis (D5 and
below).
- Added Windows 2003 detection to DSiGetWindowsVersion.
- Modified DSiEnablePrivilege to return True without doint anything on 9x platform.
- Fixed handle leak in DSiSetProcessPriorityClass.
- Removed some dead code.
- Documented the Information segment.
1.12: 2004-09-21
- Added function DSiIncrementWorkingSet.
1.11: 2004-02-12
- Added functions DSiSetProcessPriorityClass, DSiGetProcessOwnerInfo (two
overloaded versions), DSiEnablePrivilege.
1.10: 2003-12-18
- Updated TDSiRegistry.ReadString to handle DWORD registry values too.
- Updated TDSiRegistry.ReadInteger to handle string registry values too.
1.09: 2003-11-14
- Added functions DSiValidateProcessAffinity, DSiValidateThreadAffinity,
DSiValidateProcessAffinityMask, DSiValidateThreadAffinityMask,
DSiGetSystemAffinityMask, DSiGetProcessAffinityMask,
DSiGetThreadAffinityMask, DSiAffinityMaskToString, and
DSiStringToAffinityMask.
1.08: 2003-11-12
- Added functions DSiCloseHandleAndInvalidate, DSiWin32CheckHandle,
DSiGetSystemAffinity, DSiGetProcessAffinity, DSiSetProcessAffinity,
DSiGetThreadAffinity, DSiSetThreadAffinity.
- Added types TDSiFileHandle, TDSiPipeHandle, TDSiMutexHandle, TDSiEventHandle,
TDSiSemaphoreHandle; all equivaled to THandle.
1.07a: 2003-10-18
- DSiuSecDelay was broken. Fixed.
1.07: 2003-10-09
- Added functions DSiGetUserNameEx, DSiIsDiskInDrive, DSiGetDiskLabel,
DSiGetMyDocumentsFolder, DSiGetSystemVersion, DSiRefreshDesktop,
DSiGetWindowsVersion, DSiRebuildDesktopIcons.
- Added TDSiRegistry methods ReadStrings and WriteStrings dealing with MULTI_SZ
registry format.
1.06a: 2003-09-03
- Typo fixed in DSiMsgWaitForTwoObjectsEx.
1.06: 2003-09-02
- New functions: DSiMsgWaitForTwoObjectsEx, DSiMsgWaitForThreeObjectsEx.
- Documented 'Handles' and 'Registry' sections.
- Bug fixed in DSiLoadLibrary.
1.05: 2003-09-02
- New functions: DSiMonitorOn, DSiMonitorOff, DSiMonitorStandby, DSiGetBootType,
DSiShareFolder, DSiUnshareFolder, DSiFileSize, DSiEnumFiles, DSiEnumFilesEx,
DSiGetDomain, DSiProcessMessages, DSiProcessThreadMessages, DSiLoadLibrary,
DSiGetProcAddress, DSiDisableX, DSiEnableX.
- Added dynamically loaded API forwarders: DSiNetApiBufferFree, DSiNetWkstaGetInfo,
DSiSHEmptyRecycleBin, DSiCreateProcessAsUser, DSiLogonUser,
DSiImpersonateLoggedOnUser, DSiRevertToSelf, DSiCloseServiceHandle,
DSiOpenSCManager, DSi9xNetShareAdd, DSi9xNetShareDel, DSiNTNetShareAdd,
DSiNTNetShareDel.
- DSiGetUserName could fail on Win9x. Fixed.
- Declared constants WAIT_OBJECT_1 (= WAIT_OBJECT_0+1) to WAIT_OBJECT_9
(=WAIT_OBJECT_0+9).
- All dynamically loaded functions are now available to the public (see new
{ DynaLoad } section).
- All functions using dynamically loaded API calls were modified to use new
DynaLoad methods.
- All string parameters turned into 'const' parameters.
- Various constants and type declarations moved to the 'interface' section.
1.04: 2003-05-27
- New functions: DSiLoadMedia, DSiEjectMedia.
1.03: 2003-05-24
- New functions: DSiExecuteAndCapture, DSiFreeMemAndNil.
1.02a: 2003-05-05
- Refuses to compile with Kylix.
- Removed platform-related warnings on Delphi 6&7.
1.02: 2002-12-29
- New function: DSiElapsedSince.
1.01: 2002-12-19
- Compiles with Delphi 6 and Delphi 7.
- New functions:
Files:
procedure DSiDeleteFiles(folder: string; fileMask: string);
procedure DSiDeleteTree(folder: string; removeSubdirsOnly: boolean);
procedure DSiEmptyFolder(folder: string);
procedure DSiEmptyRecycleBin;
procedure DSiRemoveFolder(folder: string);
procedure DSiuSecDelay(delay: word);
Processes:
function DSiExecuteAsUser(const commandLine, username, password: string;
const domain: string = '.'; visibility: integer = SW_SHOWDEFAULT;
workDir: string = ''; wait: boolean = false): cardinal;
function DSiImpersonateUser(const username, password, domain: string): boolean;
procedure DSiStopImpersonatingUser;
1.0: 2002-11-25
- Released.
*)
unit DSiWin32;
{$J+,T-} // required!
interface
{$IFDEF Linux}{$MESSAGE FATAL 'This unit is for Windows only'}{$ENDIF Linux}
{$IFDEF OSX}{$MESSAGE FATAL 'This unit is for Windows only'}{$ENDIF OSX}
{$IFDEF MSWindows}{$WARN SYMBOL_PLATFORM OFF}{$WARN UNIT_PLATFORM OFF}{$ENDIF MSWindows}
{$DEFINE DSiNeedUTF}{$UNDEF DSiNeedVariants}{$DEFINE DSiNeedStartupInfo}
{$DEFINE DSiNeedFileCtrl}
{$DEFINE DSiNeedRawByteString}
{$IFDEF ConditionalExpressions}
{$UNDEF DSiNeedUTF}{$DEFINE DSiNeedVariants}{$UNDEF DSiNeedStartupInfo}{$UNDEF DSiHasSafeNativeInt}{$UNDEF UseAnsiStrings}
{$IF CompilerVersion >= 25}{$LEGACYIFEND ON}{$IFEND}
{$IF RTLVersion >= 18}{$UNDEF DSiNeedFileCtrl}{$IFEND}
{$IF CompilerVersion >= 26}{$DEFINE DSiUseAnsiStrings}{$IFEND}
{$IF CompilerVersion >= 23}{$DEFINE DSiScopedUnitNames}{$DEFINE DSiHasSafeNativeInt}{$DEFINE DSiHasTPath}{$IFEND}
{$IF CompilerVersion >= 20}{$DEFINE DSiHasAnonymousFunctions}{$IFEND}
{$IF CompilerVersion > 19}{$DEFINE DSiHasGetFolderLocation}{$IFEND}
{$IF CompilerVersion < 18.5}{$DEFINE DSiNeedULONGEtc}{$IFEND}
{$ENDIF}
{$IFDEF Unicode}{$UNDEF DSiNeedRawByteString}{$ENDIF}
uses
{$IFDEF DSiScopedUnitNames}Winapi.Windows{$ELSE}Windows{$ENDIF},
{$IFDEF DSiScopedUnitNames}Winapi.Messages{$ELSE}Messages{$ENDIF},
{$IFDEF DSiNeedVariants}
{$IFDEF DSiScopedUnitNames}System.Variants{$ELSE}Variants{$ENDIF},
{$ENDIF}
{$IFDEF DSiNeedFileCtrl}
FileCtrl, // use before SysUtils so deprecated functions from FileCtrl can be reintroduced
{$ENDIF DSiNeedFileCtrl}
{$IFDEF DSiScopedUnitNames}
System.UITypes,
{$ENDIF}
{$IFDEF DSiScopedUnitNames}System.SysUtils{$ELSE}SysUtils{$ENDIF},
{$IFDEF DSiScopedUnitNames}System.IOUtils,{$ENDIF}
{$IFDEF DSiScopedUnitNames}System.StrUtils,{$ENDIF}
{$IFDEF DSiScopedUnitNames}Winapi.ShellAPI{$ELSE}ShellAPI{$ENDIF},
{$IFDEF DSiScopedUnitNames}Winapi.ShlObj{$ELSE}ShlObj{$ENDIF},
{$IFDEF DSiScopedUnitNames}System.Classes{$ELSE}Classes{$ENDIF},
{$IFDEF DSiScopedUnitNames}System.Contnrs{$ELSE}Contnrs{$ENDIF},
{$IFDEF DSiScopedUnitNames}Vcl.Graphics{$ELSE}Graphics{$ENDIF},
{$IFDEF DSiScopedUnitNames}System.Win.Registry{$ELSE}Registry{$ENDIF}
{$IFDEF DSiUseAnsiStrings}, System.AnsiStrings{$ENDIF}
;
const
// pretty wrappers
WAIT_OBJECT_1 = WAIT_OBJECT_0+1;
WAIT_OBJECT_2 = WAIT_OBJECT_0+2;
WAIT_OBJECT_3 = WAIT_OBJECT_0+3;
WAIT_OBJECT_4 = WAIT_OBJECT_0+4;
WAIT_OBJECT_5 = WAIT_OBJECT_0+5;
WAIT_OBJECT_6 = WAIT_OBJECT_0+6;
WAIT_OBJECT_7 = WAIT_OBJECT_0+7;
WAIT_OBJECT_8 = WAIT_OBJECT_0+8;
WAIT_OBJECT_9 = WAIT_OBJECT_0+9;
// folder constants missing from ShellObj
CSIDL_ADMINTOOLS = $0030; //v5.0; <user name>\Start Menu\Programs\Administrative Tools
CSIDL_ALTSTARTUP = $001D; //The file system directory that corresponds to the user's nonlocalized Startup program group.
CSIDL_APPDATA = $001A; //v4.71; Application Data, new for NT4
CSIDL_CDBURN_AREA = $003B; //v6.0; The file system directory acting as a staging area for files waiting to be written to CD.
CSIDL_COMMON_ADMINTOOLS = $002F; //v5.0; All Users\Start Menu\Programs\Administrative Tools
CSIDL_COMMON_ALTSTARTUP = $001E; //The file system directory that corresponds to the nonlocalized Startup program group for all users.
CSIDL_COMMON_APPDATA = $0023; //v5.0; All Users\Application Data
CSIDL_COMMON_DESKTOPDIRECTORY = $0019; //The file system directory that contains files and folders that appear on the desktop for all users.
CSIDL_COMMON_DOCUMENTS = $002E; //All Users\Documents
CSIDL_COMMON_FAVORITES = $001F; //The file system directory that serves as a common repository for favorite items common to all users.
CSIDL_COMMON_MUSIC = $0035; //v6.0; The file system directory that serves as a repository for music files common to all users.
CSIDL_COMMON_PICTURES = $0036; //v6.0; The file system directory that serves as a repository for image files common to all users.
CSIDL_COMMON_PROGRAMS = $0017; //The file system directory that contains the directories for the common program groups that appear on the Start menu for all users.
CSIDL_COMMON_STARTMENU = $0016; //The file system directory that contains the programs and folders that appear on the Start menu for all users.
CSIDL_COMMON_STARTUP = $0018; //The file system directory that contains the programs that appear in the Startup folder for all users.
CSIDL_COMMON_TEMPLATES = $002D; //The file system directory that contains the templates that are available to all users.
CSIDL_COMMON_VIDEO = $0037; //v6.0; The file system directory that serves as a repository for video files common to all users.
CSIDL_COMPUTERSNEARME = $003D; //The folder representing other machines in your workgroup.
CSIDL_CONNECTIONS = $0031; //The virtual folder representing Network Connections, containing network and dial-up connections.
CSIDL_COOKIES = $0021; //The file system directory that serves as a common repository for Internet cookies.
CSIDL_HISTORY = $0022; //The file system directory that serves as a common repository for Internet history items.
CSIDL_INTERNET = $0001; //A viritual folder for Internet Explorer (icon on desktop).
CSIDL_INTERNET_CACHE = $0020; //v4.72; The file system directory that serves as a common repository for temporary Internet files.
CSIDL_LOCAL_APPDATA = $001C; //v5.0; non roaming, user\Local Settings\Application Data
CSIDL_MYDOCUMENTS = $000C; //v6.0; The virtual folder representing the My Documents desktop item.
CSIDL_MYMUSIC = $000D; //The file system directory that serves as a common repository for music files.
CSIDL_MYPICTURES = $0027; //v5.0; My Pictures, new for Win2K
CSIDL_MYVIDEO = $000E; //v6.0; The file system directory that serves as a common repository for video files.
CSIDL_PERSONAL = $0005; //v6.0; Equal to CSIDL_MYDOCUMENTS; previous; The file system directory used to physically store a user's common repository of documents.
CSIDL_PHOTOALBUMS = $0045; //Vista; The virtual folder used to store photo albums.
CSIDL_PLAYLISTS = $003F; //Vista; The virtual folder used to store play albums.
CSIDL_PRINTHOOD = $001B; //The file system directory that contains the link objects that can exist in the Printers virtual folder.
CSIDL_PROFILE = $0028; //v5.0; The user's profile folder.
CSIDL_PROGRAM_FILES = $0026; //v5.0; C:\Program Files
CSIDL_PROGRAM_FILES_COMMON = $002B; //v5.0; C:\Program Files\Common
CSIDL_RESOURCES = $0038; //Vista; The file system directory that contains resource data.
CSIDL_SAMPLE_MUSIC = $0040; //Vista; The file system directory that contains sample music.
CSIDL_SAMPLE_PICTURES = $0042; //Vista; The file system directory that contains sample pictures.
CSIDL_SAMPLE_PLAYLISTS = $0041; //Vista; The file system directory that contains sample playlists.
CSIDL_SAMPLE_VIDEOS = $0043; //Vista; The file system directory that contains sample videos.
CSIDL_SYSTEM = $0025; //v5.0; GetSystemDirectory()
CSIDL_WINDOWS = $0024; //GetWindowsDirectory()
CSIDL_FLAG_DONT_UNEXPAND = $2000; //Combine with another CSIDL constant to ensure expanding of environment variables.
CSIDL_FLAG_DONT_VERIFY = $4000; //Combine with another CSIDL constant, except for CSIDL_FLAG_CREATE, to return an unverified folder path-with no attempt to create or initialize the folder.
CSIDL_FLAG_CREATE = $8000; // new for Win2K, OR this in to force creation of folder
FILE_DEVICE_FILE_SYSTEM = 9;
FILE_DEVICE_MASS_STORAGE = $2D;
METHOD_BUFFERED = 0;
FILE_ANY_ACCESS = 0;
FILE_READ_ACCESS = 1;
FILE_WRITE_ACCESS = 2;
IOCTL_STORAGE_EJECT_MEDIA = (FILE_DEVICE_MASS_STORAGE shl 16) OR
(FILE_READ_ACCESS shl 14) OR
($202 shl 2) OR
(METHOD_BUFFERED);
IOCTL_STORAGE_LOAD_MEDIA = (FILE_DEVICE_MASS_STORAGE shl 16) OR
(FILE_READ_ACCESS shl 14) OR
($203 shl 2) OR
(METHOD_BUFFERED);
FSCTL_SET_COMPRESSION = (FILE_DEVICE_FILE_SYSTEM shl 16) OR
((FILE_READ_ACCESS OR FILE_WRITE_ACCESS) shl 14) OR
(16 shl 2) OR
(METHOD_BUFFERED);
COMPRESSION_FORMAT_NONE = 0;
COMPRESSION_FORMAT_DEFAULT = 1;
SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
STYPE_DISKTREE = 0;
SHI50F_RDONLY = $0001;
SHI50F_FULL = $0002;
SHI50F_DEPENDSON = SHI50F_RDONLY or SHI50F_FULL;
SHI50F_ACCESSMASK = SHI50F_RDONLY or SHI50F_FULL;
// IPersisteFile GUID
IID_IPersistFile: TGUID = (
D1: $0000010B; D2: $0000; D3: $0000; D4: ($C0, $00, $00, $00, $00, $00, $00, $46));
// Extension for shortcut files
CLinkExt = '.lnk';
// ShEmptyRecycleBinA flags
SHERB_NOCONFIRMATION = $00000001;
SHERB_NOPROGRESSUI = $00000002;
SHERB_NOSOUND = $00000004;
// CurrentVersion registry key
DSiWinVerKey9x = '\Software\Microsoft\Windows\CurrentVersion';
DSiWinVerKeyNT = '\Software\Microsoft\Windows NT\CurrentVersion';
DSiWinVerKeys: array [boolean] of string = (DSiWinVerKey9x, DSiWinVerKeyNT);
// CPU IDs for the Affinity familiy of functions
DSiCPUIDs = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@$';
const
// security constants needed in DSiIsAdmin
SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5));
SECURITY_BUILTIN_DOMAIN_RID = $00000020;
DOMAIN_ALIAS_RID_ADMINS = $00000220;
DOMAIN_ALIAS_RID_USERS : DWORD = $00000221;
DOMAIN_ALIAS_RID_GUESTS: DWORD = $00000222;
DOMAIN_ALIAS_RID_POWER_: DWORD = $00000223;
SE_GROUP_ENABLED = $00000004;
//LCID values, http://msdn.microsoft.com/nb-no/goglobal/bb964664.aspx
LCID_Afrikaans_SouthAfrica = $0436;
LCID_Albanian_Albania = $041c;
LCID_Alsatian = $0484;
LCID_Amharic_Ethiopia = $045e;
LCID_Arabic_SaudiArabia = $0401;
LCID_Arabic_Algeria = $1401;
LCID_Arabic_Bahrain = $3c01;
LCID_Arabic_Egypt = $0c01;
LCID_Arabic_Iraq = $0801;
LCID_Arabic_Jordan = $2c01;
LCID_Arabic_Kuwait = $3401;
LCID_Arabic_Lebanon = $3001;
LCID_Arabic_Libya = $1001;
LCID_Arabic_Morocco = $1801;
LCID_Arabic_Oman = $2001;
LCID_Arabic_Qatar = $4001;
LCID_Arabic_Syria = $2801;
LCID_Arabic_Tunisia = $1c01;
LCID_Arabic_UAE = $3801;
LCID_Arabic_Yemen = $2401;
LCID_Armenian_Armenia = $042b;
LCID_Assamese = $044d;
LCID_Azeri_Cyrillic = $082c;
LCID_Azeri_Latin = $042c;
LCID_Bashkir = $046d;
LCID_Basque = $042d;
LCID_Belarusian = $0423;
LCID_Bengali_India = $0445;
LCID_Bengali_Bangladesh = $0845;
LCID_Bosnian_BosniaHerzegovina = $141A;
LCID_Breton = $047e;
LCID_Bulgarian = $0402;
LCID_Burmese = $0455;
LCID_Catalan = $0403;
LCID_Cherokee_UnitedStates = $045c;
LCID_Chinese_PRC = $0804;
LCID_Chinese_Singapore = $1004;
LCID_Chinese_Taiwan = $0404;
LCID_Chinese_HongKongSAR = $0c04;
LCID_Chinese_MacaoSAR = $1404;
LCID_Corsican = $0483;
LCID_Croatian = $041a;
LCID_Croatian_BosniaHerzegovina = $101a;
LCID_Czech = $0405;
LCID_Danish = $0406;
LCID_Dari = $048c;
LCID_Divehi = $0465;
LCID_Dutch_Netherlands = $0413;
LCID_Dutch_Belgium = $0813;
LCID_Edo = $0466;
LCID_English_UnitedStates = $0409;
LCID_English_UnitedKingdom = $0809;
LCID_English_Australia = $0c09;
LCID_English_Belize = $2809;
LCID_English_Canada = $1009;
LCID_English_Caribbean = $2409;
LCID_English_HongKongSAR = $3c09;
LCID_English_India = $4009;
LCID_English_Indonesia = $3809;
LCID_English_Ireland = $1809;
LCID_English_Jamaica = $2009;
LCID_English_Malaysia = $4409;
LCID_English_NewZealand = $1409;
LCID_English_Philippines = $3409;
LCID_English_Singapore = $4809;
LCID_English_SouthAfrica = $1c09;
LCID_English_Trinidad = $2c09;
LCID_English_Zimbabwe = $3009;
LCID_Estonian = $0425;
LCID_Faroese = $0438;
LCID_Farsi = $0429;
LCID_Filipino = $0464;
LCID_Finnish = $040b;
LCID_French_France = $040c;
LCID_French_Belgium = $080c;
LCID_French_Cameroon = $2c0c;
LCID_French_Canada = $0c0c;
LCID_French_DRCongo = $240c;
LCID_French_CotedIvoire = $300c;
LCID_French_Haiti = $3c0c;
LCID_French_Luxembourg = $140c;
LCID_French_Mali = $340c;
LCID_French_Monaco = $180c;
LCID_French_Morocco = $380c;
LCID_French_NorthAfrica = $e40c;
LCID_French_Reunion = $200c;
LCID_French_Senegal = $280c;
LCID_French_Switzerland = $100c;
LCID_French_WestIndies = $1c0c;
LCID_Frisian_Netherlands = $0462;
LCID_Fulfulde_Nigeria = $0467;
LCID_FYRO_Macedonian = $042f;
LCID_Galician = $0456;
LCID_Georgian = $0437;
LCID_German_Germany = $0407;
LCID_German_Austria = $0c07;
LCID_German_Liechtenstein = $1407;
LCID_German_Luxembourg = $1007;
LCID_German_Switzerland = $0807;
LCID_Greek = $0408;
LCID_Greenlandic = $046f;
LCID_Guarani_Paraguay = $0474;
LCID_Gujarati = $0447;
LCID_Hausa_Nigeria = $0468;
LCID_Hawaiian_UnitedStates = $0475;
LCID_Hebrew = $040d;
LCID_Hindi = $0439;
LCID_Hungarian = $040e;
LCID_Ibibio_Nigeria = $0469;
LCID_Icelandic = $040f;
LCID_Igbo_Nigeria = $0470;
LCID_Indonesian = $0421;
LCID_Inuktitut = $045d;
LCID_Irish = $083c;
LCID_Italian_Italy = $0410;
LCID_Italian_Switzerland = $0810;
LCID_Japanese = $0411;
LCID_Kiche = $0486;
LCID_Kannada = $044b;
LCID_Kanuri_Nigeria = $0471;
LCID_Kashmiri = $0860;
LCID_Kashmiri_Arabic = $0460;
LCID_Kazakh = $043f;
LCID_Khmer = $0453;
LCID_Kinyarwanda = $0487;
LCID_Konkani = $0457;
LCID_Korean = $0412;
LCID_Kyrgyz_Cyrillic = $0440;
LCID_Lao = $0454;
LCID_Latin = $0476;
LCID_Latvian = $0426;
LCID_Lithuanian = $0427;
LCID_Luxembourgish = $046e;
LCID_Malay_Malaysia = $043e;
LCID_Malay_BruneiDarussalam = $083e;
LCID_Malayalam = $044c;
LCID_Maltese = $043a;
LCID_Manipuri = $0458;
LCID_Maori_NewZealand = $0481;
LCID_Mapudungun = $0471;
LCID_Marathi = $044e;
LCID_Mohawk = $047c;
LCID_Mongolian_Cyrillic = $0450;
LCID_Mongolian_Mongolian = $0850;
LCID_Nepali = $0461;
LCID_Nepali_India = $0861;
LCID_Norwegian_Bokmal = $0414;
LCID_Norwegian_Nynorsk = $0814;
LCID_Occitan = $0482;
LCID_Oriya = $0448;
LCID_Oromo = $0472;
LCID_Papiamentu = $0479;
LCID_Pashto = $0463;
LCID_Polish = $0415;
LCID_Portuguese_Brazil = $0416;
LCID_Portuguese_Portugal = $0816;
LCID_Punjabi = $0446;
LCID_Punjabi_Pakistan = $0846;
LCID_Quecha_Bolivia = $046B;
LCID_Quecha_Ecuador = $086B;
LCID_Quecha_Peru = $0C6B;
LCID_RhaetoRomanic = $0417;
LCID_Romanian = $0418;
LCID_Romanian_Moldava = $0818;
LCID_Russian = $0419;
LCID_Russian_Moldava = $0819;
LCID_Sami_Lappish = $043b;
LCID_Sanskrit = $044f;
LCID_Scottish_Gaelic = $043c;
LCID_Sepedi = $046c;
LCID_Serbian_Cyrillic = $0c1a;
LCID_Serbian_Latin = $081a;
LCID_Sindhi_India = $0459;
LCID_Sindhi_Pakistan = $0859;
LCID_Sinhalese_SriLanka = $045b;
LCID_Slovak = $041b;
LCID_Slovenian = $0424;
LCID_Somali = $0477;
LCID_Sorbian = $042e;
LCID_Spanish_Spain_ModernSort = $0c0a;
LCID_Spanish_Spain_TraditionalSort = $040a;
LCID_Spanish_Argentina = $2c0a;
LCID_Spanish_Bolivia = $400a;
LCID_Spanish_Chile = $340a;
LCID_Spanish_Colombia = $240a;
LCID_Spanish_CostaRica = $140a;
LCID_Spanish_DominicanRepublic = $1c0a;
LCID_Spanish_Ecuador = $300a;
LCID_Spanish_ElSalvador = $440a;
LCID_Spanish_Guatemala = $100a;
LCID_Spanish_Honduras = $480a;
LCID_Spanish_LatinAmerica = $580a;
LCID_Spanish_Mexico = $080a;
LCID_Spanish_Nicaragua = $4c0a;
LCID_Spanish_Panama = $180a;
LCID_Spanish_Paraguay = $3c0a;
LCID_Spanish_Peru = $280a;
LCID_Spanish_PuertoRico = $500a;
LCID_Spanish_UnitedStates = $540a;
LCID_Spanish_Uruguay = $380a;
LCID_Spanish_Venezuela = $200a;
LCID_Sutu = $0430;
LCID_Swahili = $0441;
LCID_Swedish = $041d;
LCID_Swedish_Finland = $081d;
LCID_Syriac = $045a;
LCID_Tajik = $0428;
LCID_Tamazight_Arabic = $045f;
LCID_Tamazight_Latin = $085f;
LCID_Tamil = $0449;
LCID_Tatar = $0444;
LCID_Telugu = $044a;
LCID_Thai = $041e;
LCID_Tibetan_Bhutan = $0851;
LCID_Tibetan_PRC = $0451;
LCID_Tigrigna_Eritrea = $0873;
LCID_Tigrigna_Ethiopia = $0473;
LCID_Tsonga = $0431;
LCID_Tswana = $0432;
LCID_Turkish = $041f;
LCID_Turkmen = $0442;
LCID_Uighur_China = $0480;
LCID_Ukrainian = $0422;
LCID_Urdu = $0420;
LCID_Urdu_India = $0820;
LCID_Uzbek_Cyrillic = $0843;
LCID_Uzbek_Latin = $0443;
LCID_Venda = $0433;
LCID_Vietnamese = $042a;
LCID_Welsh = $0452;
LCID_Wolof = $0488;
LCID_Xhosa = $0434;
LCID_Yakut = $0485;
LCID_Yi = $0478;
LCID_Yiddish = $043d;
LCID_Yoruba = $046a;
LCID_Zulu = $0435;
LCID_HID = $04ff;
type
{$IFDEF DSiNeedULONGEtc}
ULONG_PTR = Cardinal;
{$EXTERNALSYM ULONG_PTR}
ULONGLONG = UInt64;
{$EXTERNALSYM ULONGLONG}
{$ENDIF}
{$IFDEF DSiHasSafeNativeInt}
DSiNativeInt = NativeInt;
DSiNativeUInt = NativeUInt;
{$ELSE}
{$IFDEF CPUX64}! Implementation error{$ENDIF}
DSiNativeInt = integer;
DSiNativeUInt = cardinal;
{$ENDIF}
// API types not defined in Delphi 5
PWkstaInfo100 = ^TWkstaInfo100;
_WKSTA_INFO_100 = record
wki100_platform_id: DWORD;
wki100_computername: LPWSTR;
wki100_langroup: LPWSTR;
wki100_ver_major: DWORD;
wki100_ver_minor: DWORD;
end;
{$EXTERNALSYM _WKSTA_INFO_100}
TWkstaInfo100 = _WKSTA_INFO_100;
WKSTA_INFO_100 = _WKSTA_INFO_100;
{$EXTERNALSYM WKSTA_INFO_100}
SHARE_INFO_2_NT = record
shi2_netname: PWideChar;
shi2_type: Integer;
shi2_remark: PWideChar;
shi2_permissions: Integer;
shi2_max_uses: Integer;
shi2_current_uses: Integer;
shi2_path: PWideChar;
shi2_passwd: PWideChar;
end;
SHARE_INFO_50_9x = record
shi50_netname: array[1..13] of char;
shi50_type: byte;
shi50_flags: short;
shi50_remark: pchar;
shi50_path: pchar;
shi50_rw_password: array[1..9] of char;
shi50_ro_password: array[1..9] of char;
szWhatever: array[1..256] of char;
end;
_PROCESS_MEMORY_COUNTERS = packed record
cb: DWORD;
PageFaultCount: DWORD;
PeakWorkingSetSize: DWORD;
WorkingSetSize: DWORD;
QuotaPeakPagedPoolUsage: DWORD;
QuotaPagedPoolUsage: DWORD;
QuotaPeakNonPagedPoolUsage: DWORD;
QuotaNonPagedPoolUsage: DWORD;
PagefileUsage: DWORD;
PeakPagefileUsage: DWORD;
end;
PROCESS_MEMORY_COUNTERS = _PROCESS_MEMORY_COUNTERS;
PPROCESS_MEMORY_COUNTERS = ^_PROCESS_MEMORY_COUNTERS;
TProcessMemoryCounters = _PROCESS_MEMORY_COUNTERS;
PProcessMemoryCounters = ^_PROCESS_MEMORY_COUNTERS;
DWORDLONG = int64;
PMemoryStatusEx = ^TMemoryStatusEx;
_MEMORYSTATUSEX = record
dwLength: DWORD;
dwMemoryLoad: DWORD;
ullTotalPhys: DWORDLONG;
ullAvailPhys: DWORDLONG;
ullTotalPageFile: DWORDLONG;
ullAvailPageFile: DWORDLONG;
ullTotalVirtual: DWORDLONG;
ullAvailVirtual: DWORDLONG;
ullAvailExtendedVirtual: DWORDLONG;
end;
TMemoryStatusEx = _MEMORYSTATUSEX;
MEMORYSTATUSEX = _MEMORYSTATUSEX;
// Service Controller handle
SC_HANDLE = THandle;
// DSiEnumFiles callback
TDSiEnumFilesCallback = {$IFDEF DSiHasAnonymousFunctions}reference to{$ENDIF}
procedure(const longFileName: string)
{$IFNDEF DSiHasAnonymousFunctions}of object{$ENDIF};
// DSiEnumFilesEx callback
TDSiEnumFilesExCallback = {$IFDEF DSiHasAnonymousFunctions}reference to{$ENDIF}
procedure(const folder: string; S: TSearchRec;
isAFolder: boolean; var stopEnum: boolean)
{$IFNDEF DSiHasAnonymousFunctions}of object{$ENDIF};
// DSiExecuteAndCapture callback
TDSiOnNewLineCallback = {$IFDEF DSiHasAnonymousFunctions}reference to{$ENDIF}
procedure(const line: string; var runningTimeLeft_sec: integer)
{$IFNDEF DSiHasAnonymousFunctions}of object{$ENDIF};
TDSiFileTime = (ftCreation, ftLastAccess, ftLastModification);
{ Handles }
// Pretty-print aliases
TDSiFileHandle = THandle;
TDSiPipeHandle = THandle;
TDSiMutexHandle = THandle;
TDSiEventHandle = THandle;
TDSiSemaphoreHandle = THandle;
procedure DSiCloseHandleAndInvalidate(var handle: THandle);
procedure DSiCloseHandleAndNull(var handle: THandle);