Rev 75 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 75 | Rev 91 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | StdCtrls, SynEdit, ActiveX; |
7 | StdCtrls, SynEdit, ActiveX; |
8 | 8 | ||
9 | type |
9 | type |
10 | TContentCallBack = procedure(Content: string) of object; |
10 | TContentCallBack = procedure(Content: string) of object; |
11 | 11 | ||
12 | function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): string; |
12 | function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): String; |
13 | function StrIPos(const SubStr, S: string): Integer; |
13 | function StrIPos(const SubStr, S: string): Integer; |
14 | function LoadFileToStr(const FileName: TFileName): AnsiString; |
14 | function LoadFileToStr(const FileName: TFileName): AnsiString; |
15 | function LastPos(const SubStr, S: string): integer; |
15 | function LastPos(const SubStr, S: string): integer; |
16 | function IsTextHTML(s: string): boolean; |
16 | function IsTextHTML(s: string): boolean; |
17 | function GetWordUnderPos(AMemo: TSynEdit; Line, Column: integer): string; |
17 | function GetWordUnderPos(AMemo: TSynEdit; Line, Column: integer): string; |
Line 29... | Line 29... | ||
29 | 29 | ||
30 | uses |
30 | uses |
31 | ShlObj, // Needed for the CSIDL constants |
31 | ShlObj, // Needed for the CSIDL constants |
32 | IdGlobal, IdHash, IdHashMessageDigest; // used for MD5 calculation |
32 | IdGlobal, IdHash, IdHashMessageDigest; // used for MD5 calculation |
33 | 33 | ||
34 | function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): string; |
34 | function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): String; |
35 | var |
35 | var |
36 | SA: TSecurityAttributes; |
36 | SA: TSecurityAttributes; |
37 | SI: TStartupInfo; |
37 | SI: TStartupInfo; |
38 | PI: TProcessInformation; |
38 | PI: TProcessInformation; |
39 | StdOutPipeRead, StdOutPipeWrite: THandle; |
39 | StdOutPipeRead, StdOutPipeWrite: THandle; |
Line 73... | Line 73... | ||
73 | repeat |
73 | repeat |
74 | WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil); |
74 | WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil); |
75 | if BytesRead > 0 then |
75 | if BytesRead > 0 then |
76 | begin |
76 | begin |
77 | Buffer[BytesRead] := #0; |
77 | Buffer[BytesRead] := #0; |
78 | Result := Result + Buffer; |
78 | Result := Result + string(Buffer); |
79 | if Assigned(ContentCallBack) then ContentCallBack(Buffer); |
79 | if Assigned(ContentCallBack) then ContentCallBack(string(Buffer)); |
80 | end; |
80 | end; |
81 | until not WasOK or (BytesRead = 0); |
81 | until not WasOK or (BytesRead = 0); |
82 | WaitForSingleObject(PI.hProcess, INFINITE); |
82 | WaitForSingleObject(PI.hProcess, INFINITE); |
83 | finally |
83 | finally |
84 | CloseHandle(PI.hThread); |
84 | CloseHandle(PI.hThread); |