Example of ExitProcess

A

Alain

Hi,

Can someone give an example of how to use ExitProcess?

Help says is has one parameter: uExitCode. But how is the
process-to-be-stopped identified?

Thanks.

Alain
 
L

LiquidJ

ExitProcess() is used only to exit the -=calling=- process.

You can use TerminateProcess() to terminate another process. If you want to
end another process gracefully, you can try to send it's main window a
WM_CLOSE message (if it's a UI-based application).


{L}
 
A

Alain

Hi LiquidJ,

Thanks for your input.

I am trying to launch and stop MySQL from my Delphi application.

I used the CreateProcess to start it. Windows help says:

«The TerminateProcess function is used to unconditionally cause a
process to exit. Use it only in extreme circumstances. The state of
global data maintained by dynamic-link libraries (DLLs) may be
compromised if TerminateProcess is used rather than ExitProcess.»

That is why I was asking about ExitProcess...

From your answer, I understand that I cannot use ExitProcess to stop a
process; only the process itself can use this function. Right?

Happy New Year.

Alain

LiquidJ a écrit:
 
L

LiquidJ

Your understanding of ExitProcess() is correct.

But as I said before, you may not have to resort to TerminateProcess(). You
can try to send a WM_CLOSE or WM_QUIT message to the program you're trying
to end (WM_CLOSE is sent when you click on the little 'X' on top right
corner of a window for example).

I don't know how MySQL works in Windows, but if it's a service, you can use
ControlService(..., SERVICE_CONTROL_STOP, ...) to shutdown a service in a
proper and controlled manner (which is how it's done from the services MMC
plugin).


{L}
 
A

Alain

Hi,

Thanks for keeping helping me.

Could not get ControlService to stop MySQL.

I found that MySQL can be started from a batch file that calls
mysqld-nt CartesGPS
(where CartesGPS is the name of the database to be used)

BUT it must be unloaded by a batch file calling ANOTHER application:
mysqladmin shutdown
(calling mysqld-nt shutdown has no effect)

As you suggested, both batch files are called from my application
by ShellExecute.

....and it works fine!

Thanks.

Alain

LiquidJ a écrit:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top