|
-
Aug 8th, 2000, 06:48 AM
#1
Thread Starter
Lively Member
How do I find out if another program is running from within my program. IE. Is excel currently active and if not then I'll start it.
I know how to start Excel etc... but how do I detect if it is already running.
Thanks in advance,
Steve.
-
Aug 8th, 2000, 07:07 AM
#2
transcendental analytic
I just can't remeber what classname you have to pass but you could find out. Anyway if you know the classname you can use findwindow that will return the handle if there is at least one instance of excel running. otherways it will return 0
Code:
'in declarations
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'in code
wnd = FindWindow(classname,vbnullstring)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 8th, 2000, 08:36 AM
#3
Try this:
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Sub Command1_Click()
Retval = FindWindow("XLMAIN", 0&)
If Retval = 0 Then
MsgBox ("Excel is not running")
Else
MsgBox ("Excel is running")
End If
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|