LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect an external application close event?

Hum... LabVIEW crash when a call the DLL.

Maybe I don't call it the right way.

Here is the VI that I tried.
0 Kudos
Message 11 of 15
(1,616 Views)

Hi,

the problem is you use the wrong syntax. Try search for "GetMessageA function" in google. You will get an entry to MSDN.

Mike

0 Kudos
Message 12 of 15
(1,610 Views)
My experience with the 'Application Instance Close' event in a built file has also been that it is not fired
when the application is closed by the OS; from the (8.2) help:

When registered for in a VI running inside a LabVIEW project, generated when the application instance of the project is closed for any reason, such as when you close the Project Explorer window, when you select File»Close All or File»Quit, or when you run a VI that executes the Quit LabVIEW function. When registered for in a VI running outside a project, generated when you exit LabVIEW through the user interface or with the Quit LabVIEW function.


I think the 'for any reason' is actually incorrect; OS initiated closing is not trapped.

I am going to check out Mikes GetMessageA suggestion as well.

Matt
0 Kudos
Message 13 of 15
(1,601 Views)
Polling the messages with GetMessage sounds error prone, since the message
poll is emptied by the window handler. The "correct" way to do this is to
hook the message handler. This is tricky, and will probably cause more pain
that it resolves.

I think there are some OpenG tools to catch windows messages. Otherwise, a
custom dll is probably the easiest way to go. I did this sort of thing years
ago. I'll dig into it, and see if it will still work in 8.5.

The message that is send when windows closes could even be cancelled, to
prevent windows from shutting down, if I recall correctly...

Regards,

Wiebe.


0 Kudos
Message 14 of 15
(1,593 Views)

Hi,

here is a link from LAVA about this topic: http://forums.lavag.org/WM-QUERYENDSESSION-t1285.html

Mike

0 Kudos
Message 15 of 15
(1,575 Views)