i have a program that works as an nt task and i want to check if the program is working before nt starts it again
Printable View
i have a program that works as an nt task and i want to check if the program is working before nt starts it again
You mean if a program is running?
You can check if the classname already exists by using FindWindow API call.
If you need help, ask!
Before i Check this problem i have another problem
maybe you know what is "error 67 too many files" in VB
Perhaps this would help you.
Dump the code to your starting sub.
"Error 67 too many files" should mean that you haveCode:If App.PrevInstance Then
MsgBox "Application already running", vbInformation
End
End If
too many files opened.
reckus, that doesn't good enough. You should use the FindWindow as Jop mention. "coz you need to restore the running application to be active window.
Here juz a sample code. Assume your main form is call Form1 with caption set to Form1 as well.
Code:Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private xhwnd As Long
Public Sub Main()
Dim xAppName As String
If App.PrevInstance Then
xAppName = "Form1"
xhwnd = FindWindow(0&, xAppName)
If xhwnd <> 0 Then
AppActivate xAppName
xhwnd = ShowWindow(xhwnd, SW_SHOWNORMAL)
End
End If
End If
Load Form1
Form1.Show
End Sub
thank you all