Click to See Complete Forum and Search --> : Serge... Or anyone else who migh know
Inhumanoid
Nov 16th, 1999, 09:11 PM
Serge,
Do you remember the code you provided a short while back to detect if a program was being loaded?
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
MartinLiss
Nov 16th, 1999, 09:43 PM
Use a timer. Put the Shell command (without the loop) in the timer event.
------------------
Marty
Inhumanoid
Nov 16th, 1999, 10:02 PM
That works too. Has about the same result as Serge's code...
Yet it still halts the program, so the problem is the same...
Inhumanoid
Nov 17th, 1999, 03:29 PM
Somebody ???? Anybody ??????
:(
MartinLiss
Nov 17th, 1999, 09:30 PM
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
Serge
Nov 17th, 1999, 09:49 PM
Let me ask you this:
What do you use for your animation? Timer control? Or something else?
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Inhumanoid
Nov 17th, 1999, 10:03 PM
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...
Aaron Young
Nov 18th, 1999, 11:50 AM
Try this:
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
aarony@redwingsoftware.com
adyoung@win.bright.net
Inhumanoid
Nov 18th, 1999, 07:39 PM
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...
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.