Results 1 to 3 of 3

Thread: ID's ???

  1. #1

    Thread Starter
    Hyperactive Member mastermind94's Avatar
    Join Date
    Jun 2000
    Location
    Montréal, Canada
    Posts
    441

    Arrow

    Hey!

    How can I know when a Ms-DOS Application launch in by the shell command is done? In this example, I want the program PURGE accomplich is job then the will complete the FOR...NEXT instructions.

    Ex:

    [CODE]
    Private sub CmdOk_Click()
    for i = 0 to list1.listcount - 1
    cmd$ = "PURGE /DATA "+chr$(34)+list1.list(i)+chr$(34)
    shell cmd, vbhide
    next i
    msgbox "Done.", vbinformations
    end sub


    ------------
    ICQ: 65287451
    E-MAIL: [email protected]
    Homepage: http://www.sx3k.le-site.net
    AIM: MBR5520
    Running VB5 Enterprise Edition Service Pack 2
    ------------

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Try something like this:
    Code:
    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 WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
    Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, 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
    Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Const NORMAL_PRIORITY_CLASS = &H20&
    Private Const INFINITE = -1
    
    Public Sub ExecuteCommandLine(p_strCommandLine As String)
        Dim tProcInfo As PROCESS_INFORMATION
        Dim tStartInfo As STARTUPINFO
        Dim lngRet As Long
        
        tStartInfo.cb = Len(start)
    
        lngRet = CreateProcessA(0&, p_strCommandLine, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, tStartInfo, tProcInfo)
    
        'Wait while the shelled application is finished
        lngRet = WaitForSingleObject(tProcInfo.hProcess, INFINITE)
        lngRet = CloseHandle(tProcInfo.hProcess)
    End Sub
    Then you can use this sub routine like this:
    Code:
    Private Sub Command1_Click()
        Dim i As Integer
        Dim strCommandLine As String
        
        For i = 0 To List1.ListCount - 1
            strCommandLine = "PURGE /DATA " + Chr(34) + List1.List(i) + Chr(34)
            ExecuteCommandLine strCommandLine
        Next
        MsgBox "Done.", vbinformations
    End Sub

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