English
Source / code snippets

spending Console Erfassen Konsole Pipe

 

CompileMarkSeparation
/*
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

 
11/09/08  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

4.172 Views

Untitledvor 0 min.
Thomas Zielinski02/17/24
E.T.12/09/22
Torsten Boo08/30/22
H.Brill10/26/21
More...

Themeninformationen

this Topic has 1 subscriber:

iF (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie