How to test if PID is used 
Author Message
 How to test if PID is used

Hi all

I am using the shell function in VB 5.0 to start another program,
which is ftp, however shell returns before the program terminates
and it returns the process id of the program started.

How can I use this process id to cause my program to wait untill
the process started by shell has terminated and then my program
is to continue.

----------------------------------------------------------------------------
---
Edward Mifsud                   Bureau of Meteorology

                                              Melbourne  vic  3000
Tel: 03 9669 4118                 AUSTRALIA
Fax: 03 96694128
----------------------------------------------------------------------------
--



Wed, 18 Jun 1902 08:00:00 GMT  
 How to test if PID is used
Use the following routine. It waits till the process is complete and the
continues. Pass your shell command to
Runshell routine. eg. RunShell("c:\readme.txt").   Hope this helps.

Nilesh Hejib

Private Declare Function OpenProcess Lib "kernel32" _
    (ByVal dwDesiredAccess As Long, _
     ByVal bInheritHandle As Long, _
     ByVal dwProcessId As Long) As Long

Private Declare Function GetExitCodeProcess Lib "kernel32" _
    (ByVal hProcess As Long, lpExitCode As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" _
    (ByVal hObject As Long) As Long

Private Const PROCESS_QUERY_INFORMATION = &H400
Private Const STATUS_PENDING = &H103&

Private Sub RunShell(strCmdline As String)

    Dim hProcess As Long
    Dim ProcessId As Long
    Dim exitCode As Long

    ProcessId = Shell(cmdline, vbHide)
    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId)

    Do

        Call GetExitCodeProcess(hProcess, exitCode)
        DoEvents

    Loop While exitCode = STATUS_PENDING

    Call CloseHandle(hProcess)

End Sub

Quote:

> Hi all

> I am using the shell function in VB 5.0 to start another program,
> which is ftp, however shell returns before the program terminates
> and it returns the process id of the program started.

> How can I use this process id to cause my program to wait untill
> the process started by shell has terminated and then my program
> is to continue.

> ----------------------------------------------------------------------------
> ---
> Edward Mifsud                   Bureau of Meteorology

>                                               Melbourne  vic  3000
> Tel: 03 9669 4118                 AUSTRALIA
> Fax: 03 96694128
> ----------------------------------------------------------------------------
> --

       The contents of this message express only the sender's opinion.
       This message does not necessarily reflect the policy or views of
       my employer, Merck & Co., Inc.  All responsibility for the statements
       made in this Usenet posting resides solely and completely with the
       sender.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

2. How to tie the dllhost.exe PID to COM+ Application PID programmatically

3. I am trying to update a record, i am not using data control

4. I am trying to update a record, i am not using data control

5. I am after some cheap testing

6. I am looking for a product test (how to write) template

7. * * * I am Creating an Encryption Program , hobby Crackers needed to test * * *

8. TEST TEST TEST TEST

9. alt.test,comp.test,misc.test,news.test

10. TEST TEST TEST

11. TEST TEST TEST

12. Testing,testing,testing

 

 
Powered by phpBB® Forum Software