Getting feedback from shell


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Getting feedback from shell

  1. #1
    Join Date
    Dec 2004
    Location
    Porto - Portugal
    Posts
    42

    Getting feedback from shell

    Hi,

    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.

    Kind regards,

    Kepler

  2. #2
    Join Date
    Aug 2014
    Posts
    5

    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

Similar Threads

  1. Feedback on DevX
    By Brad Jones in forum Talk to the Editors
    Replies: 8
    Last Post: 04-12-2008, 10:31 PM
  2. How to compact .mdb and get feedback
    By SY Kim in forum VB Classic
    Replies: 1
    Last Post: 04-24-2002, 04:12 AM
  3. Looking for feedback
    By Randy Charles Morin in forum Enterprise
    Replies: 1
    Last Post: 07-13-2001, 02:49 PM
  4. some feedback on my design....
    By mgergZ in forum VB Classic
    Replies: 19
    Last Post: 02-09-2001, 09:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center