-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathShellExec.dpr
More file actions
95 lines (67 loc) · 2.05 KB
/
Copy pathShellExec.dpr
File metadata and controls
95 lines (67 loc) · 2.05 KB
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
program ShellExec;
{
Jacek Pazera
https://www.pazera-software.com
https://github.com/jackdp
------------------------------------------------------
ShellExec - Performs an operation on a specified file.
A "console wrapper" for the ShellExecuteEx function.
------------------------------------------------------
Links:
https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecuteexw
https://docs.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfow
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow#parameters
https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew
https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-waitforinputidle
}
{$APPTYPE CONSOLE}
// Disable extended RTTI
{$IF CompilerVersion >= 21.0} // >= Delphi 2010
{$WEAKLINKRTTI ON}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$ENDIF}
{$SetPEFlags 1} // IMAGE_FILE_RELOCS_STRIPPED
{$SetPEFlags $20} // IMAGE_FILE_LARGE_ADDRESS_AWARE
uses
Windows,
SysUtils,
JPL.Console,
SHEX.App in 'SHEX.App.pas',
SHEX.Types in 'SHEX.Types.pas',
SHEX.Procs in 'SHEX.Procs.pas';
var
App: TApp;
procedure MyExitProcedure;
begin
if Assigned(App) then
begin
App.Done;
FreeAndNil(App);
end;
end;
{$R *.res}
// ---------------------------- ENTRY POINT ------------------------------
begin
{$IFDEF DEBUG}
ReportMemoryLeaksOnShutdown := True;
{$ENDIF}
App := TApp.Create;
try
try
App.ExitProcedure := @MyExitProcedure;
App.Init;
App.Run;
if Assigned(App) then App.Done;
except
on E: Exception do
begin
Writeln(E.ClassName, ': ', E.Message);
if GetLastError <> 0 then Writeln('OS Error No. ', GetLastError, ': ', SysErrorMessage(GetLastError));
ExitCode := TConsole.ExitCodeError;
end;
end;
finally
if Assigned(App) then FreeAndNil(App);
end;
end.