moonkop
moonkop

Reputation: 29

How to gracefully close other program that do not have a main window?

I want to close another program that does not have a main window. It runs in background.

So process.CloseMainWindow() will not work, And using process.kill() will lose some data.

Is there a graceful way to close this kind of program without losing data for example by means of SendMessage or something else?

Upvotes: 1

Views: 319

Answers (1)

user585968
user585968

Reputation:

It's just a small program puts a tray icon in task bar not a windows service

In that case it must have a message pump and so you can post a Windows WM_QUIT message to the process. When the target process processes it message pump and encounters this message, it will gracefully quit. Alternatively, you may post WM_CLOSE but then you need to know which window (it still works if the window is invisible).

Upvotes: 1

Related Questions