Add(MainForm,13581682,84,63)
{
Left=20
Top=105
Visible=1
Point(Close)
link(onCreate,13467478:##open,[])
}
Add(TCP_ServerEx,13467478,154,98)
{
ServerPort=23
}
BEGIN_SDK
Add(EditMultiEx,3385328,3,3)
{
WorkCount=#6:##open|
Width=258
Height=179
}
Add(TCP_Connection,11302843,91,105)
{
link(onRead,10490002:doInput,[])
link(onConnect,12040629:doData,[(133,118)(133,93)(39,93)(39,41)])
link(onDisconnect,10490002:doClose,[(142,125)(142,118)])
}
Add(InlineCode,10490002,161,98)
{
@Hint=#11:ConsoleExec|
WorkPoints=#7:doStart|7:doInput|7:doClose|
EventPoints=#8:onOutput|7:onError|6:onExit|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|29:uses KOL,Share,Debug,Windows;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|23: hProcess: THandle;|30: hPipeInputWrite: THandle;|30: hPipeOutputRead: THandle;|30: hPipeErrorsRead: THandle;|5: |27: dwReadThreadID: dword;|26: hReadThread: THandle;|20: FRead: boolean;|0:|9: public|24: onOutput:THI_Event;|23: onError:THI_Event;|22: onExit:THI_Event;|0:|20: procedure Read;|25: procedure Terminate;|51: procedure doStart(var Data:TData; Index:word);|51: procedure doInput(var Data:TData; Index:word);|51: procedure doClose(var Data:TData; Index:word);|29: destructor Destroy; |5: end;|0:|14:implementation|0:|56:function ReadFunc(Parent:THiAsmClass):cardinal; stdcall;|5:begin|15: Parent.Read;|15: Result := 0;|4:end;|0:|30:procedure THiAsmClass.doStart;|3:var|26: sa: TSECURITYATTRIBUTES;|19: si: TSTARTUPINFO;|26: pi: TPROCESSINFORMATION;|26: hPipeInputRead: THandle;|28: hPipeOutputWrite: THandle;|28: hPipeErrorsWrite: THandle;|15: Res: Boolean;|29: env: array[0..100] of Char;|5:begin|27: sa.nLength := sizeof(sa);|28: sa.bInheritHandle := true;|33: sa.lpSecurityDescriptor := nil;|2: |54: CreatePipe(hPipeInputRead, hPipeInputWrite, @sa, 0);|56: CreatePipe(hPipeOutputRead, hPipeOutputWrite, @sa, 0);|56: CreatePipe(hPipeErrorsRead, hPipeErrorsWrite, @sa, 0);|2: |32: ZeroMemory(@env, SizeOf(env));|30: ZeroMemory(@si, SizeOf(si));|30: ZeroMemory(@pi, SizeOf(pi));|2: |22: si.cb := SizeOf(si);|61: si.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;|28: si.wShowWindow := SW_HIDE;|33: si.hStdInput := hPipeInputRead;|36: si.hStdOutput := hPipeOutputWrite;|35: si.hStdError := hPipeErrorsWrite;|0:|66: Res := CreateProcess(nil, PChar(ToString(Data)), nil, nil, true,|68: CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, @env, nil, si, pi);|30: CloseHandle(hPipeInputRead);|32: CloseHandle(hPipeOutputWrite);|32: CloseHandle(hPipeErrorsWrite);|0:|23: if not Res then begin|33: CloseHandle(hPipeInputWrite);|33: CloseHandle(hPipeOutputRead);|33: CloseHandle(hPipeErrorsRead);|18: hProcess := 0;|9: Exit;|6: end;|2: |41: hProcess := pi.hProcess; FRead := true;|72: hReadThread := CreateThread(nil,1024,@ReadFunc,Self,0,dwReadThreadID);|4:end;|0:|27:procedure THiAsmClass.Read;|63:var Total:dword; bWait:boolean; hWait:THandle; bError:boolean; |34: pBuffer: array[0..1024] of char;|5:begin|61: hWait := CreateEvent(nil,false,false,nil); bError := false;|37: while FRead and not bError do begin|18: bWait := true;|83: if not PeekNamedPipe(hPipeErrorsRead,nil,0,nil,@Total,nil) then bError := true;|25: if Total>0 then begin|21: bWait := false;|72: if ReadFile(hPipeErrorsRead, pBuffer, 1024, Total, nil) then begin|30: pBuffer[Total] := #0;|38: _hi_OnEvent(onError, pBuffer);|10: end;|8: end;|83: if not PeekNamedPipe(hPipeOutputRead,nil,0,nil,@Total,nil) then bError := true;|25: if Total>0 then begin|21: bWait := false;|72: if ReadFile(hPipeOutputRead, pBuffer, 1024, Total, nil) then begin|30: pBuffer[Total] := #0;|39: _hi_OnEvent(onOutput, pBuffer);|10: end;|8: end;|47: if bWait then WaitForSingleObject(hWait,1);|6: end;|21: CloseHandle(hWait);|22: if bError then begin|14: Terminate;|24: _hi_OnEvent(onExit);|6: end;|4:end;|0:|30:procedure THiAsmClass.doInput;|26:var Total:dword; s:string;|5:begin|26: if hProcess=0 then Exit;|22: s := ToString(Data);|63: WriteFile(hPipeInputWrite, PChar(s)^, Length(s), Total, nil);|4:end;|0:|32:procedure THiAsmClass.Terminate;|5:begin|27: if hProcess<>0 then begin|18: FRead := true;|34: TerminateProcess(hProcess, 1);|40: WaitForSingleObject(hProcess, 1000);|26: CloseHandle(hProcess);|33: CloseHandle(hPipeInputWrite);|33: CloseHandle(hPipeOutputRead);|33: CloseHandle(hPipeErrorsRead);|43: WaitForSingleObject(hReadThread, 1000);|29: CloseHandle(hReadThread);|18: hProcess := 0;|6: end;|4:end;|0:|30:procedure THiAsmClass.doClose;|5:begin|12: Terminate;|4:end;|0:|31:destructor THiAsmClass.Destroy;|5:begin|12: Terminate;|4:end;|0:|4:end.|
link(onOutput,7361595:doWork2,[])
link(onError,7361595:doWork3,[(214,111)])
link(onExit,11302843:doClose,[(204,118)(204,146)(72,146)(72,111)])
}
Add(HubEx,7361595,210,91)
{
link(onEvent,11302843:doSend,[(229,104)(229,81)(63,81)(63,118)])
}
Add(InlineCode,7883727,105,35)
{
@Hint=#22:GetEnvironmentVariable|
WorkPoints=#8:doGetVar|
EventPoints=#8:onGetVar|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|29:uses KOL,Share,Debug,Windows;|0:|4:type|28: THiAsmClass = class(TDebug)|9: public|24: onGetVar:THI_Event;|52: procedure doGetVar(var Data:TData; Index:word);|5: end;|0:|14:implementation|0:|31:procedure THiAsmClass.doGetVar;|26:var s:string; sLen: dword;|5:begin|35: sLen := 1024; SetLength(s, sLen);|69: sLen := GetEnvironmentVariable(PChar(ToString(Data)), @s[1], sLen);|22: if sLen>0 then begin|23: SetLength(s, sLen);|29: _hi_OnEvent(onGetVar, s);|6: end;|4:end;|0:|4:end.|
link(onGetVar,10490002:doStart,[(149,41)(149,104)])
}
Add(DoData,12040629,49,35)
{
Data=String(ComSpec)
link(onEventData,7883727:doGetVar,[])
}
END_SDK
Ответов: 1
Рейтинг: 0
|
|||
Telnet all bugs fixed!
|
|||
карма: 0 |
|