| |
|
|
| KompilierenMarkierenSeparieren/*
Autor: Andreas Miethe
https://www.rgh-soft.de/forum01/read.php?f=6&i=5310&t=5305
Beispiel :
*/
$H Windows.ph
$H Structs.ph
Struct PROCESS_INFORMATION = ~PROCESS_INFORMATION
Struct SECURITY_ATTRIBUTES = ~SECURITY_ATTRIBUTES
Struct STARTUPINFO = ~STARTUPINFO
DEF &NORMAL_PRIORITY_CLASS $20
DEF &STARTF_USESTDHANDLES $100
DEF &STARTF_USESHOWWINDOW $1
CLS ~GetSysColor(~COLOR_BTNFACE)
SetDialogFont ~GetStockObject(~ANSI_VAR_FONT)
Var Ende& = 0
Var Multi& = Create("MultiEdit",%hwnd,"",1,10,500,400)
Var Button& = Create("Button",%hwnd,"Start",540,10,80,24)
Var Button1& = Create("Button",%hwnd,"Ende",540,40,80,24)
Whilenot Ende&
Waitinput
If Clicked(Button1&)
Ende& = 1
ElseIf Clicked(Button&)
Beispiel mit Ping
DirektDosOutputToMultiedit("", "ping localhost",255,Multi&)
DirektDosOutputToMultiedit("avrdude.exe", "",255,Multi&)
Endif
EndWhile
End
Proc DirektDosOutputToMultiedit
Parameters Progname$,Command$,MemBuffer&,Multiedit&
Declare hRPipe&,hWPipe&,pRBytes&,Result&
Declare PI#,SI#,SA#
Dim PI#,PROCESS_INFORMATION
Dim SI#,STARTUPINFO
Dim SA#,SECURITY_ATTRIBUTES
Declare StringBuffer$
StringBuffer$ = Space$(MemBuffer&)
SA#.nLength& =SizeOf(SA#)
SA#.bInheritHandle& = 1
SA#.lpSecurityDescriptor& = 0
Result& = ~CreatePipe(Addr(hRPipe&), Addr(hWPipe&), SA#, 0)
If Result& = 0
MessageBox("Pipe konnte nicht gestartet werden","",0)
End
Endif
If Progname$ <> ""
Command$ = " " + Command$
Endif
SI#.cb& = SizeOf(SI#)
SI#.dwFlags& = &STARTF_USESHOWWINDOW | &STARTF_USESTDHANDLES
SI#.hStdOutput& = hWPipe&
SI#.hStdError& = hWPipe&
If Progname$ = ""
Result& = ~CreateProcess(0, Addr(Command$), SA#, SA#, 1, &NORMAL_PRIORITY_CLASS, 0, 0, SI#,PI#)
Else
Result& = ~CreateProcess(Addr(Progname$), Addr(Command$),SA#,SA#,1,&NORMAL_PRIORITY_CLASS, 0, 0,SI#,PI#)
Endif
If Result& <> 1
MessageBox("Datei nicht gefunden","",0)
End
Else
Endif
Result& = ~CloseHandle(hWPipe&)
Var out$ = ""
While Result& <> 0
Result& = ~ReadFile(hRPipe&,Addr(StringBuffer$),MemBuffer&,Addr(pRBytes&), 0)
If pRBytes& > 0
Out$ = Left$(StringBuffer$,pRBytes&)
~OemToChar(Addr(Out$),Addr(Out$))
Settext Multiedit&,GetText$(Multiedit&)+Out$
Endif
Endwhile
~CloseHandle(PI#.hProcess&)
~CloseHandle(PI#.hThread&)
~CloseHandle(hRPipe&)
Dispose PI#,SI#,SA#
EndProc
|
|
|
| |
|
|