CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2000
    Location
    Italy
    Posts
    5

    Process Information

    How is possible to know the end of a process?
    For example, I have n processes and I want to be advertised when a process has ended and which process has ended.
    Thanks

    Renzo

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Process Information

    private Declare Function CloseHandle Lib "kernel32" (byval hObject as Long) as Long
    private Declare Function WaitForSingleObject Lib "kernel32" (byval hHandle as Long, byval dwMilliseconds as Long) as Long
    private Declare Function OpenProcess Lib "kernel32" (byval dwDesiredAccess as Long, byval bInheritHandle as Long, byval dwProcessId as Long) as Long
    private Const SW_HIDE = 0
    private Const SW_SHOW = 5
    private Const STANDARD_RIGHTS_REQUIRED = &HF0000
    private Const SYNCHRONIZE = &H100000
    Const PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF
    Const WAIT_TIMEOUT = &H102

    public Sub ShellWait(byval FileName as string, optional WindowStyle as Variant)
    Dim idProc as Long
    Dim hProc as LongidProc = VBA.Shell(FileName, WindowStyle)
    hProc = OpenProcess(PROCESS_ALL_ACCESS, false, idProc)
    If hProc <> 0 then
    Do While WaitForSingleObject(hProc, 100) = WAIT_TIMEOUT
    DoEvents
    Loop
    CloseHandle hProc
    End If
    End Sub

    private Sub Command1_Click()
    Call ShellWait("notepad.exe", SW_SHOW)
    End Sub

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured