Monday, 28 August 2017

Redirectstandardoutput Waitforexit Vb


Eseguire un processo e Fetch la sua produzione mai chiesti come Visual Studio esegue un processo - come ad esempio un compilatore - e visualizza il testo torna in una finestra Il suo in realtà molto semplice - Ed ecco un semplice esempio di come. Shared GetProcessText funzione (processo di ByVal come stringa, ByVal param As String, ByVal WORKINGDIR come stringa) come String Dim p come un processo nuovo processo questo è il nome del processo che vogliamo eseguire il processo p. StartInfo. FileName If Not (WORKINGDIR) Poi linea p. StartInfo. WorkingDirectory WORKINGDIR End If. StartInfo. Arguments param necessità di impostare questo a false per reindirizzare l'uscita p. StartInfo. UseShellExecute false p. StartInfo. RedirectStandardOutput vero avviare il processo di p. Start leggere tutto l'output qui abbiamo potuto appena letto per linea e visualizzarla in una finestra di output Dim uscita come stringa p. StandardOutput. ReadToEnd attendere che il processo di interrompere p. WaitForExit Return Funzione uscita fine si potrebbe anche like. System. Diagnostics. Process: reindirizzare StandardInput, StandardOutput, StandardError 82218217 InputAndOutputToEnd : un modo pratico per utilizzare reindirizzato su un inputoutputerror p. 82218217 ltparam name8221p8221gtThe p reindirizzare. Deve avere UseShellExecute insieme a false. ltparamgt stringa 82218217 ltparam name8221StandardInput8221gtThis verrà inviato come input per il p. (Deve essere nulla se non StartInfo. RedirectStandardInput) ltparamgt 82.218.217 ltparam name8221StandardOutput8221gtThe p8217s uscita saranno raccolti in questa stringa ByRef. (Deve essere nulla se non StartInfo. RedirectStandardOutput) ltparamgt 82.218.217 ltparam errore name8221StandardError8221gtThe p8217s saranno raccolti in questa stringa ByRef. (Deve essere nulla se non StartInfo. RedirectStandardError) Funzione ltparamgt 82218217 ltremarksgtThis risolve il problema stallo accennato msdn. microsoften-uslibrarysystem. diagnostics. p.standardoutput. aspxltremarksgt ltRuntimepilerServices. Extension () gt Sub InputAndOutputToEnd (ByVal p Come Diagnostics. Process, ByVal StandardInput As String. ByRef StandardOutput As String. ByRef StandardError As String) Se p è niente allora throw new ArgumentException (8220p deve essere non null8221) 8216 supponga p è iniziata. Ahimè there8217s alcun modo di controllare. Se p. StartInfo. UseShellExecute poi gettare nuova ArgumentException (8220Set StartInfo. UseShellExecute a false8221) Se (p. StartInfo. RedirectStandardInput ltgt (StandardInput IsNot niente)) poi gettare nuova ArgumentException (8220Provide un ingresso non nullo solo quando StartInfo. RedirectStandardInput8221) Se (p. StartInfo. RedirectStandardOutput ltgt (StandardOutput IsNot niente)) poi gettare nuova ArgumentException (8220Provide una uscita non nullo solo quando StartInfo. RedirectStandardOutput8221) Se (p. StartInfo. RedirectStandardError ltgt (StandardError IsNot niente)) poi gettare nuova ArgumentException (8220Provide un errore non nullo solo quando StartInfo. RedirectStandardError8221) Dim OutputData come nuovo InputAndOutputToEndData Dim ErrorData come nuovo InputAndOutputToEndData Se p. StartInfo. RedirectStandardOutput Poi

No comments:

Post a Comment