-
Jul 14th, 2006, 02:18 PM
#1
Thread Starter
Hyperactive Member
How to know it's running?
Is there a way to know if a specific exe is currently running and (of course) to know if it's not running?
Something like
VB Code:
isRunning = '...
Do While isRunning
isRunning = '...
Sleep(500)
Loop
Last edited by blizarr; Jul 14th, 2006 at 02:36 PM.
-
Jul 14th, 2006, 02:36 PM
#2
Thread Starter
Hyperactive Member
Re: How to know it's running?
-
Jul 14th, 2006, 02:38 PM
#3
Re: How to know it's running?
Yes, there is allot of code for this already on the Forums.
Search for CreateToolhelp32Snapshot or EnumProcesses APIs. Or even "Running Process"(es)
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jul 14th, 2006, 03:36 PM
#4
Re: How to know it's running?
Here's a one-liner. Although it's pretty damn ugly:
VB Code:
Private Sub Form_Load()
Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE")
Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\NotRunning.EXE")
End Sub
Private Function IsProcessRunning(ByVal sPath As String) As Boolean
On Error Resume Next
IsProcessRunning = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ExecutablePath = '" & Replace(sPath, "\", "\\") & "'").Count
End Function
-
Aug 7th, 2006, 07:39 AM
#5
Fanatic Member
Re: How to know it's running?
hello bush.But it is showing flase value though the program is running
Dont rely only on your luck. Work hard until You get success.
vb Code:
Private sub Time_ispassing
While Me.Notgetsuccess
trygain=tryagain+1
Me.workhard
wend
end sub
-
Aug 7th, 2006, 07:46 AM
#6
Fanatic Member
Re: How to know it's running?
Remember i have windows 98 se. i think istead on win32 it will be some other thing.
Dont rely only on your luck. Work hard until You get success.
vb Code:
Private sub Time_ispassing
While Me.Notgetsuccess
trygain=tryagain+1
Me.workhard
wend
end sub
-
Aug 7th, 2006, 08:01 AM
#7
Re: How to know it's running?
remove the On Error Resume Next and see what you get.
WMI does not come preinstalled on 98, so you may have to install it yourself.
-
Aug 7th, 2006, 08:01 AM
#8
Re: How to know it's running?
VB Code:
If App.PrevInstance = True Then
MsgBox "This Software Is Already Running", vbInformation + vbOKOnly, "Already Running"
Else
MDIForm1.Show
End If
You can use this property in a Load event procedure to specify whether a user is already running an instance of an application. Depending on the application, you might want only one instance running in the Microsoft Windows operating environment at a time.
Note Since a computer running Windows NT can support multiple desktops, if you use a component designed to work with distributed COM, it can result in the following scenario:
A client program in a user desktop requests one of the objects the component provides. Because the component is physically located on the same machine, the component is started in the user desktop.
Subsequently, a client program on another computer uses distributed COM to request one of the objects the component provides. A second instance of the component is started, in a system desktop.
There are now two instances of the component running on the same NT computer, in different desktops.
This scenario is not a problem unless the author of the component has placed a test for App.PrevInstance in the startup code for the component to prevent multiple copies of the component from running on the same computer. In this case, the remote component creation will fail.
-
Aug 7th, 2006, 08:17 AM
#9
Fanatic Member
Re: How to know it's running?
Hi bush. the link is not working. please give correct link to download wmi. i will serach for wmi in google.
Dont rely only on your luck. Work hard until You get success.
vb Code:
Private sub Time_ispassing
While Me.Notgetsuccess
trygain=tryagain+1
Me.workhard
wend
end sub
-
Aug 7th, 2006, 08:21 AM
#10
Re: How to know it's running?
vivek: the link wasn't to a download, it was to the WMI documentation - i suggest you have a read up and make an informed decision rather than downloading and installing something without knowing what it is.
-
Jan 25th, 2007, 03:07 PM
#11
Member
Re: How to know it's running?
Originally Posted by bushmobile
Here's a one-liner. Although it's pretty damn ugly:
VB Code:
Private Sub Form_Load()
Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE")
Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\NotRunning.EXE")
End Sub
Private Function IsProcessRunning(ByVal sPath As String) As Boolean
On Error Resume Next
IsProcessRunning = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ExecutablePath = '" & Replace(sPath, "\", "\\") & "'").Count
End Function
is there any other ways?
-
Jan 25th, 2007, 04:09 PM
#12
Re: How to know it's running?
Originally Posted by Dark Byte
is there any other ways?
yup, here's a much better way: http://www.vbforums.com/showpost.php...82&postcount=2
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
|