Getting feedback from shell
I've already know how to call an external program with the shell command in vb6.
But is there a way of getting a result/feedback to the memory, for instance, of that external program back into vb?
Writing to a file is complicated if the program is running in a cd/dvd.
Yes, it is possible
However, the program you are calling needs to return an exit code. And your programm must wait until the other program closes (using a loop) to capture the exit code.
Instead of using the VB Shell, you use the following API functions to start the programm, and get the exit code:
'Open the program
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any,
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
'Wait for all to be loaded
Private Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
'Wait for program to close
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
'Get the exit code
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
'Close the thread and process handles
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
By Brad Jones in forum Talk to the Editors
Last Post: 04-12-2008, 09:31 PM
By SY Kim in forum VB Classic
Last Post: 04-24-2002, 03:12 AM
By Randy Charles Morin in forum Enterprise
Last Post: 07-13-2001, 01:49 PM
By mgergZ in forum VB Classic
Last Post: 02-09-2001, 08:01 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center