2
Answers

How to respond to system shutdown??

Jia En

Jia En

18y
2.9k
1

I have created a console application, and I used the code below to get the respond from the system shutdown.. But it don't seems to be working.. And I owaz get this error

c:\jia en\tcp\client_standalone\client.cs(96,27): error CS0115: 'Client.Client.WndProc(ref System.Windows.Forms.Message)': no suitable method found to override


Please HELP me.. Thankz..

protected
override void WndProc(ref System.Windows.Forms.Message m)

{

if(m.Msg==WM_QUERYENDSESSION)

{

isShuttingDown=true;

}

base.WndProc(ref m);

}

private void Client_Closing(object sender, System.ComponentModel.CancelEventArgs e)

{

if(isShuttingDown)

{

e.Cancel=false;

isShuttingDown = false;

string endTime = GetTime();

#region Display client's machine name

System.Security.Principal.WindowsPrincipal wp = new

System.Security.Principal.WindowsPrincipal

(System.Security.Principal.WindowsIdentity.GetCurrent());

c.machName = wp.Identity.Name;

Console.WriteLine(c.machName);

#endregion

#region List all the processes running in client machine

Process[] procs = Process.GetProcesses( Environment.MachineName );

foreach (Process process in procs)

{

// Store all the processes in procName

c.procName = process.ProcessName + "\n";

Console.WriteLine(c.procName);

}

#endregion

writeToFile();

}

}

Answers (2)