How to Close a External Window Started With WinExec(...) ?
John K.
Bacau,

Apr 27, 2011
55 Posts

How to close a external window started with WinExec(...) ?

Hi there! I have to build an application that runs a specified program from ATEasy and after some events occure, that external application has to be closed. I guess I have to use WinExec procedure, but I don't know how to close the application. Can anyone help me with this, please?

DrATEasy (Ron Y.)
Mission Viejo,

Apr 28, 2011
235 Posts

Re: How to close a external window started with WinExec(...) ?

You can terminate it using kernel32 TerminateProcess API ( http://msdn.microsoft.com/en-us/library/ms686714(v=vs.85).aspx ):

hProcess=WinExe(...
TerminateProcess(hProcess...)

This will abnormally terminate it. If you want to let the application respond to a close message you can use the .NET method in System.Diagnostics.Process.CloseMainWindow. See http://msdn.microsoft.com/en-us/library/s9tkk4a3(VS.71).aspx for more information.

Ronnie





Solution Available
John K.
Bacau,

Sep 15, 2011
55 Posts

Re: How to close a external window started with WinExec(...) ?

I can't import kernel32.dll :(. I don't find a proper .h file. I've tried with winbase.h and windows.h from Microsoft SDK 7.1. No use! Can anyone please help me with good .h file or files?

DrATEasy (Ron Y.)
Mission Viejo,

Sep 15, 2011
235 Posts

Re: How to close a external window started with WinExec(...) ?

Don't need or want header file since it will contains thousands of functions. All you need is insert a library, DLL (kernel32,dll). and click OK. Than go to procedures under the library and define the function and parameters as in the API link above.The process is documented in the getting started manual (working with external libraries).

John K.
Bacau,

Sep 15, 2011
55 Posts

Re: How to close a external window started with WinExec(...) ?

Thank you very, very much for your help, Ronnie! You sure are a doctor in ATEasy! ;). Have a good day!



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]