hello
i made a Project to check if notepad.exe is not running then will wait until its running :)
actually someone helped me with this code :)
module
what i need is to make the Project work without timer can you help me please ?
i made a Project to check if notepad.exe is not running then will wait until its running :)
actually someone helped me with this code :)
Code:
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 100
If Not IsProcessRunning("notepad.exe") Then
Me.Caption = "Waiting for notepad to open"
Timer1.Enabled = True
End If
End Sub
Code:
Private Sub Timer1_Timer()
If IsProcessRunning("notepad.exe") = True Then
Timer1.Enabled = False
Form2.Caption = "notepad has opend"
Form2.Show
Unload Me
End If
End Sub
Code:
'Check If Process Is Running
'Coded by stoopid/goodhigh
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, th32ProcessID As Long) As Long
Private Const TH32CS_SNAPPROCESS As Long = 2
Public Type PROCESSENTRY32
dwSize As Long
cntUseage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
swFlags As Long
szExeFile As String * 1024
End Type
Public Function IsProcessRunning(Filename As String) As Boolean
Dim hSnapShot As Long
Dim pe32 As PROCESSENTRY32
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) 'create snapshot of process
pe32.dwSize = Len(pe32) 'get size of processentry32
Process32First hSnapShot, pe32 'get info about first process
Do While Process32Next(hSnapShot, pe32) <> 0 'loop through all processes
If InStr(1, LCase(pe32.szExeFile), LCase(Filename)) > 0 Then 'process found
IsProcessRunning = True
End If
Loop
CloseHandle (hSnapShot) 'close snapshot
End Function