03-12-2010 08:57 PM
Zou,
Well in that case I could run a command line VLC and then end it after 10 seconds. Seems like the easiest way right now. I think user32.dll in windows will let you kill tasks. i know there is an easy way in .net to start an app and keep the process id so you can kill it later. I used that once to spawn off a bunch of ghostsrvr apps for imaging multiple pc's 🙂
Anyways, thanks. I think this is my major blocking point for a fully automated video encoder test application.
03-13-2010 01:02 AM - edited 03-13-2010 01:04 AM
03-14-2010 04:15 PM
Corey,
.net way is the best to terminate a process. But don't "kill" the process, you can use the id to get the main window handle. Close the main window to terminate the process gracefully. No worry about memory leak, and re-start the application again without trouble.
This method is just a wrap around the C/WinAPI method (Rolf used in his VIs) I think. I used C/WinAPI method five years ago to torture to test Intel chips: start/stop an application repeatedly, and in multiple instance.
I moved on to VLM now. It can handle multiple instance of VLC, and for multiple source.
03-23-2010 08:40 PM
Thanks for the LvUtils.zip file. I'm am getting back to this and thought, maybe i should just get a working run and kill process working. Then i noticed you posted this file 🙂
I've setup a simple vi, using your files, with:
"c:\program files\VideoLan\vlc\vlc.exe" rtsp://192.168.1.28/stream1 --sout=#transcode{vcodec=h264,vb=800,scale=1,acodec=mp3,ab=128,channels=1,samplerate=44100}:std{access=file,mux=mp4,dst=c:\test.mpg}
And that starts the vlc no problem. But if i use the kill process then it does not close the file or something and i dont get video from test.mpg? If i run from command line and click on the X or stop or file/close then the file saves correctly. There has to be a way to maybe use "findwindow" and "sendmessage" to tell VLC to close? I think i have those already put together for labview somewhere 🙂
-Corey
03-23-2010 09:05 PM
Okay user32.dll findwindow and sendmessage seem to work. Here is a snippet. also used your create function. I was hoping the PID and the hwnd would be the same and then i wouldn't need findwindow...but they are different. I may need the PID to verify the process closed...Not sure yet.
p.s. ignore the &H112 that was hex command for the sendmessage to close window. shown above as 112
-Corey
03-24-2010 03:48 AM
No the PID is the process ID. It is a unique Windows kernel ID for a process. But a process can have MANY windows, so there is no way they could be the same. Also processes are very low level kernel objects, almost at the basic of the Windows kernel together with events, semaphores, threads and memory. Windows are GDI (Graphics Device Interface) objects, at least 2 layers higher, that make use of many kernel services too but also of other subssytems, one of them being the graphics output system, and handling the basic user input such as mouse, keyboard and such too.
There are functions to enumerate the windows of a given process but they use callback functions and are therefore not feasable to use directly in LabVIEW without some small C wrapper.
02-10-2012 04:50 AM
Thanks for posting the solution.
I'm having problem with user32.dll: labview crashes the moment I run my vi that uses that dll. (WIN7 normal user account)
Could you tell what setting do you use for the call library function? Mine are attached to this post.
02-10-2012 05:22 AM
Could you post the code for the solution please??
05-01-2017 08:24 PM
Kind of late 🙂 like 5 years late. but hey, maybe this will help someone.