Results 1 to 9 of 9

Thread: Serge... Or anyone else who migh know

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    Serge,

    Do you remember the code you provided a short while back to detect if a program was being loaded?

    Code:
    Dim dblID As Double
    '--------------------------
    'Show your animation here
    '--------------------------
    
    dblID = Shell("C:\YourExternalProgram.exe",vbNormalNoFocus)
    Do Until dblID <> 0
      DoEvents
    Loop
    
    '------------------------
    'Hide your animation here
    '------------------------
    On the one hand it was exactly what I was looking for. On the other it created another problem : The program halted until dblID was not 0.

    Question:
    Could there be a way to detect if a program was running and make the program not halt ??

    If you can't find out how to do this:
    Would you know how to do about the same stuff that your current code does but then with CreateProcess instead of Shell....

    If anyone else can help... please don't keep your silence

    thnx

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Use a timer. Put the Shell command (without the loop) in the timer event.

    ------------------
    Marty

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    That works too. Has about the same result as Serge's code...

    Yet it still halts the program, so the problem is the same...

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    Somebody ???? Anybody ??????


  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Just to be sure I understand. Are you 1)trying to determine if a program is already running, 2) trying to start another program within your program and you want to be able to do ther stuff while it's starting, or 3) something else?

    ------------------
    Marty

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Let me ask you this:
    What do you use for your animation? Timer control? Or something else?

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    MartinLiss:
    It's to start another program within my program, and the program wich is starting another program should detect when the program it started is completely loaded (or active). The programs wich are being started are not made by me so I can't put any code in there (like StopAnimation in form_activate event or something).

    Serge:
    I'm not using any animation yet because no animation can take place when I execute the code. The app is completely dead untill the program it started is fully active (I want the program not to be dead/hung).
    I want it to be small led in the statusbar going on and off... So it could be two bitmap's and a timer, a two frame avi, a two frame gif etc...

  8. #8
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Try 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 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 Any, lpProcessInformation As PROCESS_INFORMATION) As Long
    Private Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
    
    Private Sub Command1_Click()
        Dim tSI As STARTUPINFO
        Dim tPI As PROCESS_INFORMATION
        Dim tTimer As Single
        
        If CreateProcess("C:\Program Files\Microsoft Office\Office\Winword.exe", "", ByVal 0&, ByVal 0&, 0&, 0&, ByVal 0&, "C:\Program Files\Microsoft Office\Office", tSI, tPI) Then
            tTimer = Timer
            While WaitForInputIdle(tPI.hProcess, 1)
                If (Timer - tTimer) > 0.1 Then
                    Caption = IIf(Caption = "Waiting..", "", "Waiting..")
                    tTimer = Timer
                End If
            Wend
            Caption = "Done."
        End If
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    This is the best one yet, thnx....
    I also got it to change bitmaps in my statusbar.....

    The program i still unusable/dead for the time the execuatble, that was started, takes to load...

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