|
-
Nov 26th, 2008, 03:35 AM
#1
Thread Starter
Lively Member
[RESOLVED] Runing processes and checking them
Hello.
I'm a beginner so I need some help with Visual basic.
1.
I need some example on how to work and create a system icons on taskbar.
These system icons are icons shown where the clock is shown on taskbar at the bottom right.
Then how to create popup messages and etc.
2.
Then I need some example how to check if the process is running. For example every 10 sek could check if the process in task manager is still working .
So I would like to make a program witch will run some ???.exe file, actualy a working program witch I need for printing... And then I would show a icon on taskbars system window that everything is ok. And so the program would check every some seconds if the program is still running and if so then everything would stay as it is, but if the program is not running anymore then the popup window would come out with some message and the icon in taskbars system window would change into some other icon. And than you could click on that system icon and some button options would show up like Run proces, stop proces, exit .... and etc...
So this is what I want to do and if you just can help me with some examples or just tell me where can I find some examples witch are showing how to work with system icons on taskbar and how to check if the process is still running.
Thank you !!!
-
Nov 26th, 2008, 05:32 AM
#2
Re: Runing processes and checking them
I'd recommend you start by using the search feature of this forum. For example I searched on "system icons" and got quite a few hits.
Then try writing the program first. I can guarantee if you do that and then have issues someone will help you.
-
Nov 26th, 2008, 07:38 AM
#3
Hyperactive Member
-
Nov 27th, 2008, 02:20 AM
#4
Thread Starter
Lively Member
Re: Runing processes and checking them
Thanks. jp
I think it is a loot easyer if I yust start with some sample demos how to do something. So I'm just looking for some demo examples to start with.
-
Nov 27th, 2008, 09:50 AM
#5
Hyperactive Member
Re: Runing processes and checking them
 Originally Posted by alessy
Thanks. jp
I think it is a loot easyer if I yust start with some sample demos how to do something. So I'm just looking for some demo examples to start with.
http://www.vb6.us/tutorials/display-...-apis-tutorial
"More Heads are Better than One"
-
Nov 28th, 2008, 02:26 AM
#6
Thread Starter
Lively Member
Re: Runing processes and checking them
Thanks JP ...
I've completed my program and works perfectly.
I've created an icon to show in taskbar system and when the process is stoped or terminated, than that icon becomes diferent color and a message shows that the process has been terminated.
But this message is to interrupting. I want the message to popup from taskbar system, like it does when you get new email or when you get message that windows has done some updates and so... I want the message to come slowly at the right botom corner to show for a few seconds and then disapper...
Is that possible in VB ? I think it is, I yust dont find any sample or code how to do it...
If somebody know, please can you send me some link or. code how to do it.
Thank you !
-
Nov 28th, 2008, 05:39 AM
#7
Re: Runing processes and checking them
Create a form for displaying your message, and show it when you want - using whatever effects you like (eg: scroll upwards from the bottom of the screen until it is just above the taskbar).
-
Nov 28th, 2008, 09:36 AM
#8
Re: Runing processes and checking them
Wokawidget has made a pop-up form like that, you can find it in the VB6.0 codebank, have a look.
-
Dec 2nd, 2008, 05:56 AM
#9
Thread Starter
Lively Member
Re: Runing processes and checking them
Thanks ...
I have another question...
At the bottom I'm gona paste the code that you can see, what I've got..
Now the problem with this code is because I run and control wrk.exe process.
But I realized that I'm doing wrong here, because I have to run run.exe witch does some things and then run.exe itself starts wrk.exe and closes itself... So in processes I have to control wrk.exe, but I have to start run.exe...
So how can I tell that I want to control some other process and not this one witch I run .
And importaint info is that run.exe and wrk.exe are some other programs witch I cannot change. They are fixed exe files.
Here is the code :
lPid = Shell("c:\working\wrk.exe", vbNormalFocus)
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
txt = "Wrk not working !!!"
End if
Thanks for any help...
-
Dec 2nd, 2008, 01:58 PM
#10
Re: Runing processes and checking them
You want to run the 2 exe at the same time?
-
Dec 3rd, 2008, 01:25 AM
#11
Thread Starter
Lively Member
Re: Runing processes and checking them
No.
I want to run only run.exe ... Then in the processing task I have to control wrk.exe and not run.exe ... Because run.exe does some importaint things before it self runs wrk.exe and then run.exe closes it self and only wrk.exe stays working .
So I have to control wrk.exe witch is not process witch I started .
So to ask you different, how to control a process witch I didnt run, but is already running ?
Thanks
-
Dec 3rd, 2008, 01:32 AM
#12
Re: Runing processes and checking them
What sort of control do you need with wrk.exe?
-
Dec 4th, 2008, 01:24 AM
#13
Thread Starter
Lively Member
Re: Runing processes and checking them
Sorry for delay.
What sort of control do I need.
Ok , to explain one more time.
I want to controll or. with other words I want to know if the wrk.exe is still running. But the problem is because I dont know how to check or. controll process witch is already running ...
I pasted example on how you start and control process witch I started it, but I need a tip or. code how to control a process witch is already running. Witch I didnt started.
So if you look at the code one more time .
With first sentence I start wrk.exe . And some data is wroten into IPid.
If i skip fist IF sentence and go to second one " If lHnd <> 0 " here I just control or. check if the process is still running. If not, then it goes on and does some stuff, but what I need now is that I want to controll some other process . I dont know how to get IHnd from already working process, that I can then go into IF sentence to control or check if process is running. If not, then it would do some things...
lPid = Shell("c:\working\wrk.exe", vbNormalFocus)
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
txt = "Wrk not working !!!"
...
-
Dec 5th, 2008, 01:16 AM
#14
Thread Starter
Lively Member
Re: Runing processes and checking them
I realize it is tough one.
It can be some other way too to control already running process. It doesent have to be like I have in my example. It is only importaint that it works.
I'll try to come along with your example how to manage that if anybody knows how. I'd really appreciate that.
Thanks for your help.
-
Dec 6th, 2008, 05:27 PM
#15
Re: Runing processes and checking them
There is a code in this thread that lists running processes, perhaps you could filter the exe you need.
-
Dec 8th, 2008, 05:13 AM
#16
Thread Starter
Lively Member
Re: Runing processes and checking them
thx dee-u ...
I'm trying to solve this puzzle.
I just canot get right "lPid" ....
If i only knew how to get LPid from already running proces then it would do the job....
help !!!
-
Dec 8th, 2008, 10:43 AM
#17
Re: Runing processes and checking them
Ok, here it is. (in a module)
Code:
Option Explicit
Public Const TH32CS_SNAPPROCESS As Long = 2&
Public Const MAX_PATH As Long = 260
Public Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Public Declare Function CreateToolhelp32Snapshot Lib "kernel32" _
(ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Public Declare Function ProcessFirst Lib "kernel32" _
Alias "Process32First" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Public Declare Function ProcessNext Lib "kernel32" _
Alias "Process32Next" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Public Declare Sub CloseHandle Lib "kernel32" _
(ByVal hPass As Long)
Public Function GetProgramPID(ByVal strProgram As String) As Long
Dim hSnapShot As Long
Dim uProcess As PROCESSENTRY32
Dim success As Long
Dim a As Long
Dim ExeName As String
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapShot = -1 Then Exit Function
uProcess.dwSize = Len(uProcess)
success = ProcessFirst(hSnapShot, uProcess)
If success = 1 Then
Do
ExeName = UCase$(Trim$(uProcess.szExeFile))
a = InStr(ExeName, vbNullChar)
ExeName = Mid$(ExeName, 1, a - 1)
'if matches the get is PID
If LCase$(Trim$(ExeName)) = LCase$(Trim$(strProgram)) Then
GetProgramPID = uProcess.th32ProcessID
Exit Do
End If
Loop While ProcessNext(hSnapShot, uProcess)
End If
Call CloseHandle(hSnapShot)
End Function
Sample usage:
Code:
Private Sub Command1_Click()
MsgBox GetProgramPID("Opera.exe")
End Sub
-
Dec 10th, 2008, 06:31 AM
#18
Thread Starter
Lively Member
Re: Runing processes and checking them
Thank you very much dee-u !!!
You really helped me a lot !
Respect
-
Dec 10th, 2008, 07:22 AM
#19
Re: Runing processes and checking them
Is your problem solved? If yes then you could mark this thread as Resolved using the Thread Tools menu.
-
Dec 11th, 2008, 01:22 AM
#20
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
I have one more question.
When i come to this point, everything stops. I cannot do anything else.
So it waits until my process is still running.
lRet = WaitForSingleObject(lHnd, INFINITE) ' application to end.
I saw that I have some code for mouse and if I put mouse over my icon than the code starts to run nomather if he waits for process failure.
But I tried to open form1 to get some basic controll buttons. Like stoping the process etc, but I cannot get it to work and even show up...
So the question is how to pause or stop this WaitForSingleObject ???
I'd like to pause or stop the checking that i can work with form1, but when i'm done id like to continue the checking or. just start again.
It is not problem to start again I think, my problem is only how to stop this checking or pause it , that I can do some other stuff ....
-
Dec 11th, 2008, 01:36 AM
#21
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
I forgot one more thing...
This is declaration of this function if helps somehow??? So how to pause or stop this function for a while ...
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
-
Dec 11th, 2008, 02:12 AM
#22
Re: [RESOLVED] Runing processes and checking them
Are you doing it with something like this?
Code:
Do
DoEvents
RetVal = WaitForSingleObject(sei.hProcess, 0)
Loop While RetVal = WAIT_TIMEOUT
-
Dec 11th, 2008, 02:38 AM
#23
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
Well I tried to put 0 where in my case is infinite and it passes on. Like the process had stoped...
I dont use Do sentence and Loop back . I just have infinite and it waits there for process to stop...
So should I do it with something like you pasted ? With Do sentence and loop...
-
Dec 11th, 2008, 02:46 AM
#24
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
I tried to do with DO sentence now , like you showed me, but it gets other problem, because my processor gets stuffed with 100% of CPU usage, so with Do sentence si not so good idea.
It is beter with infinite like I have and no DO and LOOP ...
-
Dec 11th, 2008, 02:56 AM
#25
Re: [RESOLVED] Runing processes and checking them
Could you show us some code?
-
Dec 11th, 2008, 03:08 AM
#26
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
Ok, here you got whole my code ... I had to delete some texts because it has too much characters and i couldnt post it...
It is everything...
I hope you'll get to solve this one...
I appriciate your time and kindnes.
Thank you.
Code:
Option Explicit
Private Const TH32CS_SNAPPROCESS As Long = 2&
Private Const MAX_PATH As Long = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" _
(ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" _
Alias "Process32First" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" _
Alias "Process32Next" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Dim txt As String
Const MAX_TOOLTIP As Integer = 64
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIP = &H4
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_LBUTTONDBLCLK = &H203
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205
Const WM_RBUTTONDBLCLK = &H206
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _
(ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Const GW_HWNDNEXT = 2
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Private nfIconData As NOTIFYICONDATA
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Private Sub Form_Load()
If App.PrevInstance = True Then
MsgBox "Program WINPS že deluje !"
End
End If
txt = "WINPISI deluje !!!"
Form1.Hide
With nfIconData
.hwnd = Form1.hwnd
.uID = Form1.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Form1.Icon.Handle
.szTip = txt & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
Dim txtapp As String
lPid = Shell("c:\winpisi\winpiss.exe", vbNormalFocus)
lPid = GetProgramPID("winpisi.exe")
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
txt = "WINPISI ne deluje !!!"
Form1.Icon = LoadPicture("c:\WINPISI\TRFFC10C.ICO")
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
With nfIconData
.hwnd = Form1.hwnd
.uID = Form1.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Form1.Icon.Handle
.szTip = txt & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
MsgBox "Težava ! WINPISI je prenehal delovati !!! Poizkusite ga ponovno pognati z ikono v opravilni vrstici ...", vbInformation, "Shelled Application"
End If
'------------------------------------------------------------------
End Sub
Private Sub cmdAdd_Click()
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
Dim txtapp As String
'
' Add this application's icon to the system tray.
'
' Parm 1 = Handle of the window to receive notification messages
' associated with an icon in the taskbar status area.
' Parm 2 = Icon to display.
' Parm 3 = Handle of icon to display.
' Parm 4 = Tooltip displayed when cursor moves over system tray icon.
'
's With nfIconData
's .hwnd = Me.hwnd
's .uID = Me.Icon
's .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
's .uCallbackMessage = WM_MOUSEMOVE
's .hIcon = Me.Icon.Handle
's .szTip = "System Tray Example" & vbNullChar
's .cbSize = Len(nfIconData)
's End With
's Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Form1.Hide
Form1.Icon = LoadPicture("c:\WINPISI\TRFFC10A.ICO")
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
With nfIconData
.hwnd = Me.hwnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
.szTip = txt & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
lPid = Shell("c:\winpisi\winpiss.exe", vbNormalFocus)
lPid = GetProgramPID("winpisi.exe")
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
txt = "WINPISI ne deluje !!!"
Form1.Icon = LoadPicture("c:\WINPISI\TRFFC10C.ICO")
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
With nfIconData
.hwnd = Me.hwnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
.szTip = txt & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
MsgBox "Težava ! WINPISI se je prenehal delovati !!! Poizkusite ga ponovno pognati z ikono v opravilni vrstici ...", vbInformation, "Shelled Application"
End If
End Sub
Private Sub cmdQuit_Click()
Call cmdRemove_Click
Unload Me
End Sub
Private Sub cmdRemove_Click()
'
' Remove this application from the System Tray.
'
Form1.Hide
's Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
'
' Determine the event that happened to the System Tray icon.
' Left clicking the icon displays a message box.
' Right clicking the icon creates an instance of an object from an
' ActiveX Code component then invokes a method to display a message.
'
lMsg = X / Screen.TwipsPerPixelX
Select Case lMsg
Case WM_LBUTTONUP
' MsgBox "This message was shown from the System Tray Icon", vbInformation, "System Tray Example"
Case WM_RBUTTONUP
'Timer1.Enabled = True
cmdAdd_Click
Case WM_MOUSEMOVE
Case WM_LBUTTONDOWN
Case WM_LBUTTONDBLCLK
Case WM_RBUTTONDOWN
Form1.Show
' cmdAdd_Click
Case WM_RBUTTONDBLCLK
Case Else
End Select
End Sub
Private Sub Timer1_Timer()
Dim oObj As Object
Timer1.Enabled = False
Set oObj = CreateObject("Sample.Class1") 'Create an object.
oObj.ActiveXMsg 'Display the message.
Set oObj = Nothing 'Kill the object
End Sub
Public Function GetProgramPID(ByVal strProgram As String) As Long
Dim hSnapShot As Long
Dim uProcess As PROCESSENTRY32
Dim success As Long
Dim a As Long
Dim ExeName As String
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapShot = -1 Then Exit Function
uProcess.dwSize = Len(uProcess)
success = ProcessFirst(hSnapShot, uProcess)
If success = 1 Then
Do
ExeName = UCase$(Trim$(uProcess.szExeFile))
a = InStr(ExeName, vbNullChar)
ExeName = Mid$(ExeName, 1, a - 1)
'if matches the get is PID
If LCase$(Trim$(ExeName)) = LCase$(Trim$(strProgram)) Then
GetProgramPID = uProcess.th32ProcessID
Exit Do
End If
Loop While ProcessNext(hSnapShot, uProcess)
End If
Call CloseHandle(hSnapShot)
End Function
-
Dec 11th, 2008, 06:48 AM
#27
Re: [RESOLVED] Runing processes and checking them
Instead of INFINITE could you try WAIT_OBJECT_0 instead?
-
Dec 12th, 2008, 01:18 AM
#28
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
I tried, but it fals out ...
I think that infinite is right. I just need something to stop waiting. To terminate waiting.
Because when hi is in waiting I can jump to Private Sub Form_MouseMove with no problem. But if I put in normal way code when you click with left mouse button that it has to do : FORM1.SHOW then it shows only background of form1. Not all buttons and etc. on this form.
But imediatly if I terminate process in my case : winpisi.exe by hand in window task manager, then the waiting is released and shows complete form1.
I could do that, when I want to go to form1, I could stop the process, etc, but it is very bad solution. If only I could terminate this waiting and not working process in my case winpisi it self.
-
Dec 12th, 2008, 01:46 AM
#29
Re: [RESOLVED] Runing processes and checking them
Using the snippet in post #22 works for me, it lets your program continue even while the target application is still open. What exactly is your problem in that snippet?
-
Dec 12th, 2008, 01:57 AM
#30
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
In #22 is problem because my CPU gets 100 % working.
Or i did something wrong ?
Can you paste here how you used it in my code ?
Please !
-
Dec 12th, 2008, 02:01 AM
#31
Re: [RESOLVED] Runing processes and checking them
This is how I am using it in my own code
Code:
Dim RetVal As Long
RetVal = ShellExecuteEx(sei)
If RetVal > 0 Then
' Wait for the opened process to close before continuing. Instead
' of waiting once for a time of INFINITE, this example repeatedly checks to see if the
' is still open. This allows the DoEvents VB function to be called, preventing
' our program from appearing to lock up while it waits.
Do
DoEvents
RetVal = WaitForSingleObject(sei.hProcess, 0)
Loop While RetVal = WAIT_TIMEOUT
End If
-
Dec 12th, 2008, 02:40 AM
#32
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
Im not so good in Vb, so i dont know what is what.
your RetVal is same as my lRet ?
I dont know what is sei ? Is sei same as my lPid ?
Can you make same copy with my lRet, Lpid, lHnd ... I dont know what is what...
-
Dec 12th, 2008, 02:53 AM
#33
Re: [RESOLVED] Runing processes and checking them
Could you try it like this?
Code:
If lHnd <> 0 Then 'If successful, wait for the
Do
DoEvents
lRet = WaitForSingleObject(lHnd, 0) ' application to end.
Loop While lRet = WAIT_TIMEOUT
CloseHandle (lHnd) 'Close the handle.
End If
-
Dec 12th, 2008, 03:18 AM
#34
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
Yes it is the same like i tried it before... My CPU or. computer processor gets stuffed out to 100 % . It keeps cirkling on and on so it takes to much cpu just to control some process...
The code works ok, but the problem is because this program should run in windows all the time in the background and I'd like to do some other stuff on my computer too. So it works but not as good as infinite version witch takes 0% of cpu ...
I really like to update infinite version of this program, if i only knew how to terminate waiting when ever I want...
-
Dec 12th, 2008, 03:20 AM
#35
Re: [RESOLVED] Runing processes and checking them
What does winpisi is doing exactly?
-
Dec 12th, 2008, 03:25 AM
#36
Re: [RESOLVED] Runing processes and checking them
I believe the INFINITE is more apt in processes that will auto-close after it is finished with what it is doing. And you may want to remove the RESOLVED mark so others may know that you still have an issue.
-
Dec 12th, 2008, 03:51 AM
#37
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
Dont know how to remove resolved...
winpisi is a program to print from ms-dos to laser printers . It is still very useful and sometimes just happens that it gets somehow terminated so I just want to do simple control witch is visible and that informes you if something goes wrong that you wouldnt loose so much time quesing what is wrong...
From a simple thinking to a really complicated program that just controls other process. I didnt know that it is such a problem creating one...
I'm mostly programing in netexpress so im not so good in visual basic. But in netexpress is not possible to control process like in visual basic. You can do it like you showed me in non infinite version #22 , witch is not useful for me...
So if it is just not possible to do in infinite version then i will just have to except that I will not be able to get to form1 between waiting.
Only when process is terminated...
-
Dec 12th, 2008, 01:00 PM
#38
Re: [RESOLVED] Runing processes and checking them
If you only want to determine if a certain app is still running then you may want to have a look at this.
-
Dec 15th, 2008, 03:48 AM
#39
Thread Starter
Lively Member
Re: [RESOLVED] Runing processes and checking them
Thank you ...
A new solution is very welcome...
I see that for notepad it works really great.
But i dont know how to change to control other process. Ill try with exepid like it is mentioned at the end of the topic...
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
|