This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocs.pas
87 lines (62 loc) · 1.4 KB
/
procs.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
unit procs;
interface
uses
Windows, SysUtils, Dialogs;
const
cApp = 'Pitikare Commander';
cVersion = '0.1 alpha';
Debugging : boolean = true;
maxStatusLines = 10;
// process help functions
procedure run(const what:string);
// debug help functions
procedure debug(const src,msg:string);
// report functions
procedure ShowError(const msg:string);
// string functions
function BoolToStr(b:boolean; const sT,sF:string):string;
implementation
uses
Controls, Forms, mainfrm;
procedure run;
var
si:TStartupInfo;
pi:TProcessInformation;
begin
Screen.Cursor := crHourGlass;
try
FillChar(si,SizeOf(si),0);
si.cb := SizeOf(si);
if not CreateProcess(NIL,PChar(what),NIL,NIL,false,DETACHED_PROCESS,NIL,NIL,si,pi)
then raise Exception.Create('Execution failed: '+what);
finally
Screen.Cursor := crDefault;
end;
end;
procedure status(const src,msg:string);
var
line:string;
begin
with fMain.memConsole do begin
line := FormatDateTime('dd/mm/yyyy hh:nn',Now)+' ['+src+'] '+msg;
// OutputDebugString(PChar(line));
with Lines do begin
while Count > maxStatusLines do Delete(0);
Add(line);
SelStart := length(Text);
end;
end;
end;
procedure debug;
begin
if Debugging then status(src,msg);
end;
function BoolToStr;
begin
if b then Result := sT else Result := sF;
end;
procedure ShowError;
begin
MessageDlg(msg,mtError,[mbOK],0);
end;
end.