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}
Post by AlainHi LiquidJ,
Thanks for your input.
I am trying to launch and stop MySQL from my Delphi application.
«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
Post by LiquidJExitProcess() 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}
Post by AlainHi,
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