TheBugSlayer
Programmer
Hello.
I need to determine if an application is already running before I can execute it. Remotely is my interest but if I have a local solution I can take it from there.
I had actually written a VB function to do just that some time. I am just not sure how to use the same APIs in Delphi. I am investigating, in the meantime if anyone can help me I'd appreciate it very much.
Below is a snippet of my VB app:
Thanks for your help.
I need to determine if an application is already running before I can execute it. Remotely is my interest but if I have a local solution I can take it from there.
I had actually written a VB function to do just that some time. I am just not sure how to use the same APIs in Delphi. I am investigating, in the meantime if anyone can help me I'd appreciate it very much.
Below is a snippet of my VB app:
Code:
Function IsWordRunning() As Boolean
Dim CurrWnd As Long
Dim Length As Long
Dim TaskName As String
Dim Parent As Long
IsWordRunning = False
CurrWnd = GetWindow(frmMain.hwnd, GW_HWNDFIRST)
While CurrWnd <> 0 'While it's not my app's window
Parent = GetParent(CurrWnd)
Length = GetWindowTextLength(CurrWnd)
TaskName = Space$(Length + 1)
Length = GetWindowText(CurrWnd, TaskName, Length + 1)
TaskName = Left$(TaskName, Len(TaskName) - 1)
If Length > 0 Then
If InStr(TaskName, "Microsoft Word") > 0 Then
IsWordRunning = True
Exit Function
End If
End If
CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
DoEvents
Wend
End Function
Thanks for your help.