Ich versuche, Vbox vor dem lokalen Herunterfahren/Neustart/Abmelden etc. Herunterfahren Ich versuche etwas, aber nicht funktionieren. Mein Code ist:Wie kann ich Shutdown verzögern, bis virtualbox geschlossen
private void VMStarter_Load(object sender, EventArgs e)
{
...
...
ShutDownHandle.StopShutdown(this.Handle, "Virtual Box is shutting down...");
}
private void tmr_doWork_tick(object sender, EventArgs e)
{
tmr_doWork.Enabled = false;
Controller.closeVM(); //for
while (!ShutDownHandle.ResetShutdown(this.Handle))
{
Thread.Sleep(10);
}
ShutDownHandle.Shutdown();
this.Close();
}
//[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
if (!systemShutdown)
if (m.Msg == (int)EnumClass.WindowsMessageCodes.SM_SHUTTINGDOWN ||
m.Msg == (int)EnumClass.WindowsMessageCodes.WM_ENDSESSION ||
m.Msg == (int)EnumClass.WindowsMessageCodes.WM_QUERYENDSESSION)
{
tmr_Check.Enabled = false;
//Message MyMsg = new Message();
//MyMsg.Msg = (int)EnumClass.WindowsMessageCodes.WM_CANCELMODE;
//base.WndProc(ref MyMsg);
systemShutdown = true;
tmr_doWork.Enabled = true;
return;
}
base.WndProc(ref m);
}
ShutDownHandle Klasse: include StopShutdown und ResetShutdown Methode. Ich verwende ShutdownBlockReasonCreate
und ShutdownBlockReasonDestroy
, um das Schließen des Fensters zu beenden.
public static bool StopShutdown(IntPtr hWdn, string strMessage)
{
try
{
if (ShutdownBlockReasonCreate(hWdn, strMessage))
{
return true;
}
}
catch (Exception ex)
{
Writer.errorWrite(ex);
}
return false;
}
public static bool ResetShutdown(IntPtr hWdn)
{
try
{
return ShutdownBlockReasonDestroy(hWdn);
}
catch (Exception ex)
{
return false;
Writer.errorWrite(ex);
}
return false;
}
I Shutdown klicken, während App läuft und bekommen diese
Wie kann ich tun? Was ist los mit dir?
Ich habe eine .bat-Datei zum Herunterfahren von VirtualMachine. Es muss laufen. Aber es ist nicht bis zum Abbrechen Schaltfläche, die auf dem Bild angezeigt wird. Wenn ich auf "Abbrechen" klicke, wird normalerweise die virtuelle Maschine heruntergefahren. Irgendeine Idee für diese Situation. –