Discussion:
VB6 application in XP Mode, Host computer issues shutdown
(too old to reply)
Gabriel Knight
2012-04-26 14:27:00 UTC
Permalink
Greetings,

Not sure if this is something I can resolve in my VB application, or
if it is something that needs to be addressed at the Windows level.

My application runs a dir() query every x minutes. The computer runs
this in XP Mode and it stays running from startup. This application
was made in order to resolve some connectivity problems they were
having with two DOS applications that run in XP Mode.

The problems are resolved by this application, but when the user
issues a shutdown of the Windows 7 host computer, if my application is
still running they get a transparent screen overlay offering them to
force close the application.

If my application is shutdown in advance, everything is fine, but this
would be a nuisance to the users.

Is there a way for me to detect that there is a shutdown requested?
I'm not even sure if this gets passed to the XP Mode guest virtual
computer. This may be something that needs to be handled in more than
one scope; I'm not sure how - or even if - an application running in
XP Mode will receive notification that the host is attempting to
shutdown.

Any advice or reference would be appreciated.



--- Posted via news://freenews.netfront.net/ - Complaints to ***@netfront.net ---
Mayayana
2012-04-26 14:40:18 UTC
Permalink
The QueryUnload Event? The unloadmode parameter returns
the source of an unload order, which can be from the OS.
Gabriel Knight
2012-04-27 09:15:30 UTC
Permalink
On Thu, 26 Apr 2012 10:40:18 -0400, "Mayayana"
Post by Mayayana
The QueryUnload Event? The unloadmode parameter returns
the source of an unload order, which can be from the OS.
I can give it a try, thanks!

--- Posted via news://freenews.netfront.net/ - Complaints to ***@netfront.net ---
Gabriel Knight
2012-04-28 08:53:13 UTC
Permalink
On Thu, 26 Apr 2012 10:40:18 -0400, "Mayayana"
Post by Mayayana
The QueryUnload Event? The unloadmode parameter returns
the source of an unload order, which can be from the OS.
This didn't work. I already had some code in the QueryUnload event to
test what triggered the unload. Because I have no min or max button on
my form, only the X, which actually just minimizes to the systray.
I put an event condition for Windows Shutdown which ended the
application (would not be necessary anyway since the test would let it
close), but anyway this didn't work.

Evidently, XP Mode virtual machine doesn't receive the shutdown
message from the host computer.

:(

--- Posted via news://freenews.netfront.net/ - Complaints to ***@netfront.net ---
Karl E. Peterson
2012-04-30 18:58:54 UTC
Permalink
Post by Gabriel Knight
On Thu, 26 Apr 2012 10:40:18 -0400, "Mayayana"
Post by Mayayana
The QueryUnload Event? The unloadmode parameter returns
the source of an unload order, which can be from the OS.
This didn't work. I already had some code in the QueryUnload event to
test what triggered the unload. Because I have no min or max button on
my form, only the X, which actually just minimizes to the systray.
I put an event condition for Windows Shutdown which ended the
application (would not be necessary anyway since the test would let it
close), but anyway this didn't work.
Evidently, XP Mode virtual machine doesn't receive the shutdown
message from the host computer.
:(
Time to "show us the code", I think. You're over-riding the Unload to
minimize to the tray. How?

I just put this code in a form that lacked min/max buttons:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As
Integer)
Open "C:\QueryUnload.txt" For Append As #1
Print #1, Now, UnloadMode; " - ";
Select Case UnloadMode
Case vbFormControlMenu
Print #1, "vbFormControlMenu"
Case vbFormCode
Print #1, "vbFormCode"
Case vbAppWindows
Print #1, "vbAppWindows"
Case vbFormOwner
Print #1, "vbFormOwner"
End Select
Close #1
End Sub

Compiled it, copied it to an XP VM, and ran it twice. First time, I
closed the form with the [x] button. Second time, I logged off the VM.
Here's the output file:

4/30/2012 11:56:03 AM 0 - vbFormControlMenu
4/30/2012 11:56:18 AM 2 - vbAppWindows

Clearly, Windows is sending the shutdown message.
--
.NET: It's About Trust!
http://vfred.mvps.org
Ulrich Korndoerfer
2012-04-30 22:14:16 UTC
Permalink
... Second time, I logged off the VM.
4/30/2012 11:56:03 AM 0 - vbFormControlMenu
4/30/2012 11:56:18 AM 2 - vbAppWindows
Clearly, Windows is sending the shutdown message.
Hm, perhaps his users simply close the virtual machine. This would be
like pulling the plug out of the PC.
--
Ulrich Korndoerfer

VB tips, helpers, solutions -> http://www.prosource.de/Downloads/
MS Newsgruppen Alternativen -> http://www.prosource.de/ms-ng-umzug.html
David Youngblood
2012-05-01 07:52:22 UTC
Permalink
... Second time, I logged off the VM. 4/30/2012 11:56:03 AM 0 -
vbFormControlMenu
4/30/2012 11:56:18 AM 2 - vbAppWindows
Clearly, Windows is sending the shutdown message.
Hm, perhaps his users simply close the virtual machine. This would be like
pulling the plug out of the PC.
I would assume (from what the OP has said) that the OP wants his app
(running in a VM) to be notified that windows is closing when the *host* PC
is shut down *without* logging off of the VM.

David
Karl E. Peterson
2012-05-01 16:28:33 UTC
Permalink
... Second time, I logged off the VM. 4/30/2012 11:56:03 AM 0 -
vbFormControlMenu
4/30/2012 11:56:18 AM 2 - vbAppWindows
Clearly, Windows is sending the shutdown message.
Hm, perhaps his users simply close the virtual machine. This would be like
pulling the plug out of the PC.
Heh, okay, no way to trap that! VM or otherwise!
I would assume (from what the OP has said) that the OP wants his app (running
in a VM) to be notified that windows is closing when the *host* PC is shut
down *without* logging off of the VM.
Y'know, I have no idea how various VM products would handle that. I
would think most would likely put the VM into hibernation, if that were
enabled, eh? But, I see by re-reading the OP, that's apparently the
correct interpretation.
--
.NET: It's About Trust!
http://vfred.mvps.org
Karl E. Peterson
2012-05-01 16:29:49 UTC
Permalink
Post by Gabriel Knight
Greetings,
Not sure if this is something I can resolve in my VB application, or
if it is something that needs to be addressed at the Windows level.
My application runs a dir() query every x minutes. The computer runs
this in XP Mode and it stays running from startup. This application
was made in order to resolve some connectivity problems they were
having with two DOS applications that run in XP Mode.
The problems are resolved by this application, but when the user
issues a shutdown of the Windows 7 host computer, if my application is
still running they get a transparent screen overlay offering them to
force close the application.
If my application is shutdown in advance, everything is fine, but this
would be a nuisance to the users.
Is there a way for me to detect that there is a shutdown requested?
I'm not even sure if this gets passed to the XP Mode guest virtual
computer. This may be something that needs to be handled in more than
one scope; I'm not sure how - or even if - an application running in
XP Mode will receive notification that the host is attempting to
shutdown.
Any advice or reference would be appreciated.
What does Windows do with the XPMode VM when the host is shutting down?
Does it attempt to hibernate it? Does it send a shutdown signal?
Does it simply "pull the plug"? If we can understand that, there's an
answer to be found.
--
.NET: It's About Trust!
http://vfred.mvps.org
Loading...