Const
ReadBuffer=4096;
Var
Buffer: PAnsiChar;
BytesRead: DWORD;
The begin
Result:=';
If GetFileSize (Pipe, nil)=0 then
The Exit;
Code omitted 100 lines,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
Due to some function after using the code fails, can only restart the application to use,
Question:
Application function failure, how to reload the code? Need detailed,
The function TForm2. ReadFromPipe (Pipe: THandle) : string;
Make it a button, point to overloading, in this way,
CodePudding user response:
Try,,, catch?CodePudding user response:
Make a button, click can overload,,Is a reload function TForm2. ReadFromPipe (Pipe: THandle) : string;
CodePudding user response:
Put a button on the interface and then double-click within buttonclick write ReadFromPipe (Pipe);Is this mean?
CodePudding user response:
Source code should have a question, you might as well to solve the problem of the source code, rather than just thinking about how to automatically restart,The code below is for reference only:
The function ReadPipe (Pipe: THandle; Var BytesRemain: Integer) : AnsiString;
//read the Cmd console output, through the pipe BytesRemain for unread bytes
Var
TextBuffer: an array of AnsiChar [1.. 32767];
BytesRead: LongWord;
PipeSize: Cardinal;
The begin
Result:=';
PipeSize:=Sizeof (TextBuffer);
//check whether the pipe is something to read
PeekNamedPipe (Pipe, nil, PipeSize, @ BytesRead, @ PipeSize, @ BytesRemain);
If BytesRead & gt; 0 then
The begin
ReadFile (Pipe, TextBuffer PipeSize BytesRead, nil);
Result:=AnsiString (TextBuffer);//TextBuffer containing the AnsiString string
SetLength (Result, BytesRead);
end;
end;
CodePudding user response:
Try.
Except,
.//here processing
end;
CodePudding user response:
Put the code in a thread,Establish thread use time status word: timeuse: Double;
New monitoring thread, determine if timeuse> The timeout then begin t1. Termiante; T1:=Tt1. Create; T1. Resume; end;
CodePudding user response:
Thread processing is possible,CodePudding user response:
The restart of the code, first of all to the wrong words.if error, judge, is a functional or necrotic mistakes,Functional errors, it is caused by environment, can be repeated regularly, test execution, otherwise can't repeat,
A good way:
Try
.
Except,
.//error handling
end;