Subversion Repositories fastphp

Rev

Rev 49 | Rev 67 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 49 Rev 61
Line 4... Line 4...
4
 
4
 
5
uses
5
uses
6
  Windows, Messages, SysUtils, StrUtils, IniFiles, Classes, Forms, Variants, MsHTML,
6
  Windows, Messages, SysUtils, StrUtils, IniFiles, Classes, Forms, Variants, MsHTML,
7
  StdCtrls, SynEdit, ActiveX;
7
  StdCtrls, SynEdit, ActiveX;
8
 
8
 
-
 
9
type
-
 
10
  TContentCallBack = procedure(Content: string) of object;
-
 
11
 
9
function GetDosOutput(CommandLine: string; Work: string = ''): string;
12
function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): string;
10
function StrIPos(const SubStr, S: string): Integer;
13
function StrIPos(const SubStr, S: string): Integer;
11
function LoadFileToStr(const FileName: TFileName): AnsiString;
14
function LoadFileToStr(const FileName: TFileName): AnsiString;
12
function LastPos(const SubStr, S: string): integer;
15
function LastPos(const SubStr, S: string): integer;
13
function IsTextHTML(s: string): boolean;
16
function IsTextHTML(s: string): boolean;
14
function GetWordUnderPos(AMemo: TSynEdit; Line, Column: integer): string;
17
function GetWordUnderPos(AMemo: TSynEdit; Line, Column: integer): string;
Line 23... Line 26...
23
implementation
26
implementation
24
 
27
 
25
uses
28
uses
26
  ShlObj; // Needed for the CSIDL constants
29
  ShlObj; // Needed for the CSIDL constants
27
 
30
 
28
function GetDosOutput(CommandLine: string; Work: string = ''): string;
31
function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): string;
29
var
32
var
30
  SA: TSecurityAttributes;
33
  SA: TSecurityAttributes;
31
  SI: TStartupInfo;
34
  SI: TStartupInfo;
32
  PI: TProcessInformation;
35
  PI: TProcessInformation;
33
  StdOutPipeRead, StdOutPipeWrite: THandle;
36
  StdOutPipeRead, StdOutPipeWrite: THandle;
Line 68... Line 71...
68
          WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
71
          WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
69
          if BytesRead > 0 then
72
          if BytesRead > 0 then
70
          begin
73
          begin
71
            Buffer[BytesRead] := #0;
74
            Buffer[BytesRead] := #0;
72
            Result := Result + Buffer;
75
            Result := Result + Buffer;
-
 
76
            if Assigned(ContentCallBack) then ContentCallBack(Buffer);
73
          end;
77
          end;
74
        until not WasOK or (BytesRead = 0);
78
        until not WasOK or (BytesRead = 0);
75
        WaitForSingleObject(PI.hProcess, INFINITE);
79
        WaitForSingleObject(PI.hProcess, INFINITE);
76
      finally
80
      finally
77
        CloseHandle(PI.hThread);
81
        CloseHandle(PI.hThread);