I call an external application, run the interface would appear, I want to read the operation interface in the progress and time, don't know how to read, the second is if the VB in the call, programs run general collapse, want to appear in VB prompt box, such as "your output data is wrong please recalculate", finally in form2 returns to the main interface to input data in the calling program calculation, if perfect solution can be paid or additional points,
CodePudding user response:
Are you run CMD window above the interface, pipeline communication technology can be used if it is,
CodePudding user response:
Consider what I use this: https://bbs.csdn.net/topics/396125019
CodePudding user response:
refer to the second floor pearl response: consult my use of this: https://bbs.csdn.net/topics/396125019 I read it out now, but the content of the entire screen is appeared, I just want to read the schedule and time, can don't know CodePudding user response:
reference zhuifeng juvenile de-ming Yang reply: 3/f Quote: refer to the second floor of the Orient reply: consult my use of this: https://bbs.csdn.net/topics/396125019 I read it out now, but the content of the entire screen is appeared, I just want to read the schedule and time, do not know can Can capture time and schedule, other don't, CodePudding user response:
Option Explicit Private Declare Function CreatePipe Lib "kernel32" (phWritePipe phReadPipe As Long, As Long, lpPipeAttributes As SECURITY_ATTRIBUTES, ByVal nSize) As Long As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long Private Type SECURITY_ATTRIBUTES NLength As Long The lpSecurityDescriptor As Long BInheritHandle As Long End Type Private Type STARTUPINFO Cb As Long LpReserved As String LpDesktop As String LpTitle As String DwX As Long DwY As Long DwXSize As Long DwYSize As Long DwXCountChars As Long DwYCountChars As Long DwFillAttribute As Long DwFlags As Long WShowWindow As Integer CbReserved2 As Integer LpReserved2 As Long HStdInput As Long HStdOutput As Long HStdError As Long End Type Private Type PROCESS_INFORMATION HProcess As Long HThread As Long DwProcessId As Long DwThreadId As Long End Type Private Declare Function CreateProcessAsUser Lib "advapi32.dll" Alias "CreateProcessAsUserA" (ByVal hToken As Long, ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As SECURITY_ATTRIBUTES, ByVal lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As String, ByVal lpCurrentDirectory As String, ByVal lpStartupInfo As STARTUPINFO, ByVal lpProcessInformation As PROCESS_INFORMATION) As Long Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Const NORMAL_PRIORITY_CLASS=& amp; H20 Private Const STARTF_USESTDHANDLES=& amp; H100 Private Const STARTF_USESHOWWINDOW=& amp; H1 Private Function ExecuteCommandLineOutput (commandline As String, Optional BufferSize As Long=256, Optional TimeOut) As Long As the String Dim Proc As PROCESS_INFORMATION Dim Start As STARTUPINFO Dim sa As SECURITY_ATTRIBUTES Dim hReadPipe As Long Dim hWritePipe As Long Dim lBytesRead As Long Dim sBuffer As String If VBA. Len (commandline) & gt; 0 Then Sa. NLength=Len (sa) 'sa. NLength=vba. Len (sa) Sa. The bInheritHandle=1 & amp; Sa. The lpSecurityDescriptor=0 & amp; If CreatePipe (hReadPipe hWritePipe, sa, 0) & gt; 0 Then Start. Cb=Len (Start) Start. DwFlags=STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW Start. HStdOutput=hWritePipe Start. HStdError=hWritePipe If CreateProcessA (0 & amp; Commandline, sa, sa, 1 & amp; , NORMAL_PRIORITY_CLASS, 0 & amp; , 0 & amp; , Start, Proc)=1 Then The CloseHandle hWritePipe SBuffer=VBA. String (BufferSize, VBA. CRH (0)) If the TimeOut & gt; 0 Then Dim BeginTime As Date BeginTime=VBA. Now End the If Do Until ReadFile (hReadPipe sBuffer, BufferSize, lBytesRead, 0 & amp;)=0 DoEvents If the TimeOut & lt; 0 Then If DateDiff (" s "BeginTime, VBA. Now) & gt; The TimeOut Then ExecuteCommandLineOutput="Timeout" The Exit Do End the If End the If ExecuteCommandLineOutput=ExecuteCommandLineOutput & amp; VBA. Trim (Replace (Left (sBuffer lBytesRead), VBA. The CRH (0), "")) Text1. Text=ExecuteCommandLineOutput Loop nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull