-
Nov 24th, 2013, 07:13 AM
#1
Thread Starter
Member
[RESOLVED] please help on check if process "notepad.exe" exist then wait to end
hello
i need help on check if process "notepad.exe" running then wait "notepad.exe" until it is closed then
Code:
MsgBox "Just terminated.", vbInformation, "Shelled Application"
End If
End Sub
i use this code to wait but the codes to shell and wait
Code:
Option Explicit
Const SYNCHRONIZE = &H100000
Const INFINITE = &HFFFF 'Wait forever
Const WAIT_OBJECT_0 = 0 'The state of the specified object is signaled.
Const WAIT_TIMEOUT = &H102 'The time-out interval elapsed, and the
'object’s state is nonsignaled.
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Form_Load()
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
lPid = Shell("notepad.exe", vbNormalFocus) ' here i need to check if process "notepad.exe" exists then wait "notepad.exe"to end
If lPid <> 0 Then
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid) 'Get a handle to the shelled process.
If lHnd <> 0 Then 'If successful, wait for the
lRet = WaitForSingleObject(lHnd, INFINITE) ' application to end.
CloseHandle (lHnd) 'Close the handle.
End If
MsgBox "Just terminated.", vbInformation, "Shelled Application"
End If
End Sub
here anther code i use to check if process "notepad.exe" exist
Code:
Private Sub Form_Load()
If IsProcessRunning("notepad.exe") = True Then
MsgBox "Process running!"
Else
MsgBox "Process running!"
end if
end sub
module
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
can someone please fix it to check if process "notepad.exe" exist then wait "notepad.exe"to end not "sheel and wait"
thank you guys
Last edited by sam-of; Nov 24th, 2013 at 09:35 PM.
-
Nov 24th, 2013, 07:15 AM
#2
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
i forgot to say i'm new here and it's my first post
-
Nov 24th, 2013, 06:22 PM
#3
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
-
Nov 24th, 2013, 07:31 PM
#4
Re: please help on check if process "notepad.exe" exist then wait to end
Check posts #12 or #13 in the Detect if program is not responding! thread.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Nov 24th, 2013, 08:17 PM
#5
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by Nightwalker83
i checked it out, it's not what i need bro
-
Nov 24th, 2013, 08:39 PM
#6
Re: please help on check if process "notepad.exe" exist then wait to end
You want to see if Notepad.exe is running and if it is you want to wait until it is closed then continue on in your app? You are going to need a timer which checks every so many nnn ms.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Nov 24th, 2013, 09:28 PM
#7
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by jmsrickland
You want to see if Notepad.exe is running and if it is you want to wait until it is closed then continue on in your app? You are going to need a timer which checks every so many nnn ms.
i don't thank so its that hard bro
i use this code to open notepad.exe and wait until it is closed then
Code:
MsgBox "Just terminated.", vbInformation, "Shelled Application"
End If
End Sub
the code is
Code:
Option Explicit
Const SYNCHRONIZE = &H100000
Const INFINITE = &HFFFF 'Wait forever
Const WAIT_OBJECT_0 = 0 'The state of the specified object is signaled.
Const WAIT_TIMEOUT = &H102 'The time-out interval elapsed, and the
'object’s state is nonsignaled.
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Form_Load()
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
lPid = Shell("notepad.exe", vbNormalFocus) ' here i need to check if process "notepad.exe" exists then wait "notepad.exe"to end
If lPid <> 0 Then
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid) 'Get a handle to the shelled process.
If lHnd <> 0 Then 'If successful, wait for the
lRet = WaitForSingleObject(lHnd, INFINITE) ' application to end.
CloseHandle (lHnd) 'Close the handle.
End If
MsgBox "Just terminated.", vbInformation, "Shelled Application"
End If
End Sub
i need to check if process "notepad.exe" running then wait
Last edited by sam-of; Nov 24th, 2013 at 09:31 PM.
-
Nov 24th, 2013, 09:41 PM
#8
Re: please help on check if process "notepad.exe" exist then wait to end
I'm under the impression you do not want to Shell and Wait from your statement in post #1
.....if process "notepad.exe" exist then wait "notepad.exe"to end not "shell and wait"
What will the titlebar say on Notepad? Will it say Untitled - Notepad or something else?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Nov 24th, 2013, 09:42 PM
#9
Re: please help on check if process "notepad.exe" exist then wait to end
@ Sam-of,
You mean like this?
Code:
Option Explicit
'
' Assumes a Timer Control is drawn on the Form named Timer1
' On clicking on the Form, this Program will start C:\Project1.Exe
' and monitor it until it terminates
'
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As String, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private proc As PROCESS_INFORMATION
Private start As STARTUPINFO
Private Function ExecCmd(cmdline$)
Dim ret As Long
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
' Start the application:
ret = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)
ExecCmd = ret
End Function
Sub Form_Click()
Dim retval As Long
Dim lngResult As Long
Dim lngReturnValue As Long
'Replace the path and name with that of the application you want to use
retval = ExecCmd("C:\Project1.exe")
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim lngResult As Long
Dim lngReturnValue As Long
Dim ret As Long
ret = WaitForSingleObject(proc.hProcess, 500)
If ret = 0 Then
'Do something here
MsgBox "hello"
Timer1.Enabled = False
End If
End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Nov 24th, 2013, 10:22 PM
#10
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by Nightwalker83
@ Sam-of,
You mean like this?
Code:
Option Explicit
'
' Assumes a Timer Control is drawn on the Form named Timer1
' On clicking on the Form, this Program will start C:\Project1.Exe
' and monitor it until it terminates
'
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As String, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private proc As PROCESS_INFORMATION
Private start As STARTUPINFO
Private Function ExecCmd(cmdline$)
Dim ret As Long
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
' Start the application:
ret = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)
ExecCmd = ret
End Function
Sub Form_Click()
Dim retval As Long
Dim lngResult As Long
Dim lngReturnValue As Long
'Replace the path and name with that of the application you want to use
retval = ExecCmd("C:\Project1.exe")
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim lngResult As Long
Dim lngReturnValue As Long
Dim ret As Long
ret = WaitForSingleObject(proc.hProcess, 500)
If ret = 0 Then
'Do something here
MsgBox "hello"
Timer1.Enabled = False
End If
End Sub
thank you so much bro, its also to open and wait i will try edit codes to check if the process is running then wait till it closes i hope i can do it
-
Nov 24th, 2013, 10:28 PM
#11
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by jmsrickland
I'm under the impression you do not want to Shell and Wait from your statement in post #1
.....if process "notepad.exe" exist then wait "notepad.exe"to end not "shell and wait"
What will the titlebar say on Notepad? Will it say Untitled - Notepad or something else?
sorry i mint check if process "notepad.exe" running then wait "notepad.exe" until it is closed
-
Nov 25th, 2013, 12:33 AM
#12
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
still i did not resolve the problem can someone help please on "check if process "notepad.exe" running then wait "notepad.exe" until it is closed "
-
Nov 25th, 2013, 04:42 AM
#13
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by sam-of
thank you so much bro, its also to open and wait i will try edit codes to check if the process is running then wait till it closes i hope i can do it
Not sure what you mean?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Nov 25th, 2013, 08:14 AM
#14
Re: please help on check if process "notepad.exe" exist then wait to end
Duplicate threads merged.
One topic, one thread please.
-
Nov 25th, 2013, 04:59 PM
#15
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by Nightwalker83
Not sure what you mean?
Code:
Option Explicit
'
' Assumes a Timer Control is drawn on the Form named Timer1
' On clicking on the Form, this Program will start C:\Project1.Exe
' and monitor it until it terminates
'
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As String, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private proc As PROCESS_INFORMATION
Private start As STARTUPINFO
Private Function ExecCmd(cmdline$)
Dim ret As Long
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
' Start the application:
ret = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)
ExecCmd = ret
End Function
Sub Form_Click()
Dim retval As Long
Dim lngResult As Long
Dim lngReturnValue As Long
'Replace the path and name with that of the application you want to use
retval = ExecCmd("C:\Project1.exe")
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim lngResult As Long
Dim lngReturnValue As Long
Dim ret As Long
ret = WaitForSingleObject(proc.hProcess, 500)
If ret = 0 Then
'Do something here
MsgBox "hello"
Timer1.Enabled = False
End If
End Sub
this code to open C:\Project1.exe and wait until closed.
what i need is to check if Project1.exe running then wait until it is closed
-
Nov 25th, 2013, 06:17 PM
#16
Re: please help on check if process "notepad.exe" exist then wait to end
You are asking how to do something and at the same time showing code that does what you are asking.
I don't understand where you are coming from.
First you say:
this code to open C:\Project1.exe and wait until closed.
OK, I run the code. It shells Project1.exe then when user closes Project1.exe the code will display Msgbox "hello"
Second you say:
what i need is to check if Project1.exe running then wait until it is closed
That is exactly what the sample code does.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Nov 25th, 2013, 07:33 PM
#17
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by sam-of
what i need is to check if Project1.exe running then wait until it is closed
I don't think that is possible since you won't be monitoring the program before hand such as in the code above.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Nov 25th, 2013, 08:20 PM
#18
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by jmsrickland
You are asking how to do something and at the same time showing code that does what you are asking.
I don't understand where you are coming from.
First you say:
this code to open C:\Project1.exe and wait until closed.
OK, I run the code. It shells Project1.exe then when user closes Project1.exe the code will display Msgbox "hello"
Second you say:
what i need is to check if Project1.exe running then wait until it is closed
That is exactly what the sample code does.
sir the sample code to shell and wait i know, i don't want to shells Project1.exe.
here is example sir
http://rghost.net/50452947
-
Nov 25th, 2013, 08:51 PM
#19
Re: please help on check if process "notepad.exe" exist then wait to end
If you don't want to shell then you want to run Notepad outside of your program and wait till it is no longer running.
I would think something like a Task Manager application would have the code you need. I have one. I'll take a look at it
Doesn't that example you posted a link to give you what you need?
Like I said post 6 you will need a timer
Last edited by jmsrickland; Nov 25th, 2013 at 11:18 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Nov 25th, 2013, 11:20 PM
#20
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by jmsrickland
If you don't want to shell then you want to run Notepad outside of your program and wait till it is no longer running.
yes sir that wait i need
I would think something like a Task Manager application would have the code you need. I have one. I'll take a look at it
Doesn't that example you posted a link to give you what you need?
yes sir, but i need for wait code can you help me to add the wait code in the example i posted
Like I said post 6 you will need a timer
its OK i will add timer but wait is the wait code can you posted please
Last edited by sam-of; Nov 25th, 2013 at 11:25 PM.
-
Nov 26th, 2013, 12:11 AM
#21
Re: please help on check if process "notepad.exe" exist then wait to end
How about a simple loop with a sleep statement inside where you check to see if the process exists, if yes then sleep 100 milliseconds or so and check again loop while true
-
Nov 26th, 2013, 01:41 AM
#22
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by DataMiser
How about a simple loop with a sleep statement inside where you check to see if the process exists, if yes then sleep 100 milliseconds or so and check again loop while true
sir sleeping wont work, it has to be wait until it closes
-
Nov 26th, 2013, 01:47 AM
#23
Re: please help on check if process "notepad.exe" exist then wait to end
why not?
Do while ProcessExist
Sleep 100
loop
Would wait until the process is gone before it would execute the code following the loop
you may need a doevents in there as well to keep the program from showing as not responding and allow the UI to refresh
If that is not what you are trying to do then perhaps you should try an explain a bit more clearly.
-
Nov 26th, 2013, 01:48 AM
#24
Re: please help on check if process "notepad.exe" exist then wait to end
From what I can see, the code you need is in Post#1 'IsProcessRunning'
Code:
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 100
If Not IsProcessRunning("notepad.exe") Then
Form2.Caption = "notepad is not running"
Form2.Show
Unload Me
Else
Me.Caption = "Waiting for notepad to terminate"
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
If Not IsProcessRunning("notepad.exe") Then
Timer1.Enabled = False
Form2.Caption = "notepad has terminated"
Form2.Show
Unload Me
End If
End Sub
EDIT: BTW your code in Post#1
Code:
Private Sub Form_Load()
If IsProcessRunning("notepad.exe") = True Then
MsgBox "Process running!"
Else
MsgBox "Process running!"
end if
end sub
has an obvious error.......
Last edited by Doogle; Nov 26th, 2013 at 02:31 AM.
Reason: spelling
-
Nov 26th, 2013, 02:20 AM
#25
Re: please help on check if process "notepad.exe" exist then wait to end
The problem is not so much waiting until the process stops as it is in getting the process in the first place. Because he does not want to shell then he needs to get a handle on an existing process (like it is done in task manager type applications) then using a timer check if process has closed (like when you refresh the task manager application). That should be fairly straight forward and not too complicated. There should be some task manager code in the Code Bank and I have one myself I just have to find it.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Nov 26th, 2013, 02:29 AM
#26
Re: please help on check if process "notepad.exe" exist then wait to end
From what I understand, OP doesn't need the PID or Handle - just an indication as to whether a particular Application is running or not and if it is running to 'wait' until it's terminated.
The 'IsProcessRunning' routine takes a snap-shot of all running processes and returns True if the one being searched for is in that snap-shot, otherwise it returns False. My example just takes a snap-shot every 100 mS until 'IsProcessRunning' returns False.
Of course, I may have got the wrong end of the stick as the actual problem is not very clearly defined.
EDIT: The 'CreateToolhelp32Snapshot' API used by 'IsProcessingRunning' returns a structure that includes the Process ID. OP could use that and OpenProcess to get a Handle to it (given they have appropriate Security permissions), but I don't see why it's necessary.
Last edited by Doogle; Nov 26th, 2013 at 02:50 AM.
-
Nov 26th, 2013, 02:59 AM
#27
Re: please help on check if process "notepad.exe" exist then wait to end
Then I don't see any problems for the OP.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Nov 26th, 2013, 03:46 AM
#28
Thread Starter
Member
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by Doogle
From what I can see, the code you need is in Post#1 'IsProcessRunning'
Code:
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 100
If Not IsProcessRunning("notepad.exe") Then
Form2.Caption = "notepad is not running"
Form2.Show
Unload Me
Else
Me.Caption = "Waiting for notepad to terminate"
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
If Not IsProcessRunning("notepad.exe") Then
Timer1.Enabled = False
Form2.Caption = "notepad has terminated"
Form2.Show
Unload Me
End If
End Sub
EDIT: BTW your code in Post#1
Code:
Private Sub Form_Load()
If IsProcessRunning("notepad.exe") = True Then
MsgBox "Process running!"
Else
MsgBox "Process running!"
end if
end sub
has an obvious error.......
that's what i'm looking for , thank you sooooo much sir I really appreciate that
thank you guys
Reputation + for
Doogle, Nightwalker83, jmsrickland
close please
Last edited by sam-of; Nov 26th, 2013 at 03:55 AM.
-
Nov 26th, 2013, 03:58 AM
#29
Re: please help on check if process "notepad.exe" exist then wait to end
Originally Posted by sam-of
close please
Just follow the instructions in my sig to resolve the thread.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
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
|