-
Program List Help
I recently asked a question on how to get a current application list and have discovered a small problem with it for what I want to do.
http://www.vbforums.com/showthread.php?&p=2876018
The problem is when you find a program like in notepad its called something like
"name - notepad"
which makes a problem when you save it under another name making it called something like
"newname - notepad"
(not closing it or reopening it)
I'm wondering if I can make it when I click the app
"name - notepad"
it will stay with that app even if I save it under another name or if there is more than one notepad running.
Hope you understand what I mean.... :ehh:
And is there a way to check if an application is running using and if stament...?
Thanks, :)
-
Re: Program List Help
There is a way to check if an application is running, but you would need to use an API to do it. I have used them in the past, but can't find the projects that I used them in, try asking in the API forums.
-
Re: Program List Help
Hang on, this one looks useful:
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Load()
hWindow = FindWindow(vbNullString, "Notepad")
If IsWindow(hWindow) = 1 Then 'Code for if program is running.
End Sub
This requires a hardwired in set of apps though, there is an API for checking processes, which you could compare to a list of processes that you stored in a .TXT file for a more efficient and flexible solution.
-
Re: Program List Help
Don't forget to declare hWindow as Long ;)