English
Source / code snippets

Direktdosoutputtomultiedit Dos reading Konsole MultiEdit output Pipe

 
Fundstück of Andreas Miethe circa spending of Konsolenanwendungen einzulesen: DirektDosOutputToMultiedit

Andreas Miethe (30.05.2010 18:52)
XProfan11 - code

greeting
Andreas
CompileMarkSeparation
 $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&)

        SetText Multi&,""
        Beispiel mit "dir"
        DirektDosOutputToMultiedit("",GetComspec()+" /c dir C:\xprofan11\*.* /r",255,Multi&)

    Endif

EndWhile

End

Proc GetComspec

    Commandshell ermitteln
    Return SubStr$(GetEnv$("COMSPEC"), -1, "\")

EndProc

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$))
            statt in ein Multiedit kann der Output natürlich auch in eine Datei geschrieben werden
            Settext Multiedit&,GetText$(Multiedit&)+Out$

        Endif

    Endwhile

    ~CloseHandle(PI#.hProcess&)
    ~CloseHandle(PI#.hThread&)
    ~CloseHandle(hRPipe&)
    Dispose PI#,SI#,SA#

ENDPROC




Kürzeres
CompileMarkSeparation
winexecWait("command.com /c you >nfo.txt",0)
shell "notepad nfo.txt"
power detour over a File nfo.txt.
 
05/30/10  
 



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.946 Views

Untitledvor 0 min.
Thomas Zielinski02/17/24
Uwe Starke11/17/23
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