LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Catch logout or shutdown event

Hi all,

is there a way to catch a Windows log off or/and shutdown event in LV? For me it's totally anoying that with a running DSC Engine a first log off/shutdown does only stop the DSC Engine and then forgets about it. Further on I have a second "background" process running that looks at the DSC Engine. As it doesn't know about the shutdown/log off it's just registering the DSC Engine stop (that's fine so far), but needs an additional log off event to be stopped.

I found a promising thread http://forums.ni.com/ni/board/message?board.id=170&message.id=89988 identifying the problem. What I would like to do now, is catching the WM_QUERYENDSESSION message of windows using the nevertheless running backgroud process of mine, wait for the shutdown of the DSC Engine (or shutting down it explicitely) and then call the shutdown/log off again (that means I'll have to know whether a shutdown or a log off was requested). But that will soon be annyoing, if there are some more LabVIEW apps running.

Better would be a bug fix by NI which doesn't kill the WM_QUERYENDSESSION...

So far,
Carsten
0 Kudos
Message 1 of 8
(5,826 Views)
Hi Carsten,

how do you close your VI. Have you tried something like in the attached file yet?

Kai Kratt
0 Kudos
Message 2 of 8
(5,806 Views)
Hi Kai,

actually I'm not closing the VI at all. It's running all the time as well as the DSC engine.

The problem is not really, that the DSC engine and the VI don't close, *but* that they seam to tell Windows "hey - we don't want to quit" by setting WM_QUERYENDSESSION to 0 (as the thread mentioned above states). By that Windows simply "forgets" to procede with the shutdown or log off. The funny thing is, that almost anytime the DSC Engine seems to be the first of my two problematic LabVIEW programs getting the WM_QUERYENDSESSION message.

So I don't want to shutdown Windows directly from my VI at all. It's just a "dirty" hack I hope to accomplish:

* catch WM_QUERYENDSESSION
* shutdown the DSC Engine deliberately to be sure
* call a shutdown program wich will wait some seconds in the background
* exit my program

So the problem is how I got knowledge of the requested shutdown and how I can distinguish beetween log off and shutdown (poweroff, restart). Maybe I'll have to write a small C program and communicate with my LabVIEW program :-(... Maybe it's a task to do in LabWindows/CVI?

Carsten
0 Kudos
Message 3 of 8
(5,800 Views)
To catch WM_QUERYENDSESSION isn't that hard. A C program will do it.

However, you could make your VI as a window server so that it won't stopped when user log out.

George Zou
http://gtoolbox.yeah.net
George Zou
0 Kudos
Message 4 of 8
(5,781 Views)

@zou wrote:
However, you could make your VI as a window server so that it won't stopped when user log out.




For this VI it could definitly be a solution. What I'm worrying most about is: wouldn't I just postpone the problem to shutdown? Or is a service stopped/killed another (more unfriendly) way?

And I'll think about a small C program anyway -- if it's just to solve the DSC Engine problem...

Thanks,
Carsten
0 Kudos
Message 5 of 8
(5,760 Views)
See http://zone.ni.com/devzone/cda/epd/p/id/4394 for windows_messaging_que.zip and use it to listen for WM_POWERBROADCAST, but, note this DOES NOT WORK UNLESS THE LabVIEW APPLICATION IS COMPILED INTO AN EXECUTABLE (.exe)!  When running within the development environment, the message is never caught.
 
0 Kudos
Message 6 of 8
(4,984 Views)
Ummmm. Just FYI: you're responding to a thread that's over 3 and half years old, so it's likely the situation has changed since then.
0 Kudos
Message 7 of 8
(4,979 Views)

Hi kbulgrien,

What version of LabVIEW are you using to do this? 

Stephen S.
National Instruments
1 Test is worth 1000 expert opinions
0 Kudos
Message 8 of 8
(4,948 Views)