Discussion:
Example of ExitProcess
(too old to reply)
Alain
2004-01-06 01:27:37 UTC
Permalink
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
LiquidJ
2004-01-06 14:07:47 UTC
Permalink
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}
Post by 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
Alain
2004-01-06 15:14:53 UTC
Permalink
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
Post by 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}
Post by 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
LiquidJ
2004-01-06 16:52:19 UTC
Permalink
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 Alain
Hi 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 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}
Post by 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
Alain
2004-01-06 21:06:01 UTC
Permalink
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
Post by 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}
Post by Alain
Hi 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 LiquidJ
ExitProcess() is used only to exit the -=calling=- process.
You can use TerminateProcess() to terminate another process. If you
want to
Post by Alain
Post by LiquidJ
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 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
Continue reading on narkive:
Loading...