Click here to Skip to main content
15,914,013 members
Home / Discussions / C#
   

C#

 
GeneralRe: Oracle Parser Pin
Richard MacCutchan4-Sep-09 8:02
mveRichard MacCutchan4-Sep-09 8:02 
AnswerRe: Oracle Parser Pin
Pete O'Hanlon31-Aug-09 9:32
mvePete O'Hanlon31-Aug-09 9:32 
QuestionPictureBox Stretch Problem Pin
Muammar©31-Aug-09 5:09
Muammar©31-Aug-09 5:09 
QuestionConnect to VPN server Pin
yogesh_softworld12331-Aug-09 4:41
yogesh_softworld12331-Aug-09 4:41 
AnswerRe: Connect to VPN server Pin
stancrm31-Aug-09 8:16
stancrm31-Aug-09 8:16 
GeneralRe: Connect to VPN server Pin
yogesh_softworld12331-Aug-09 19:59
yogesh_softworld12331-Aug-09 19:59 
GeneralRe: Connect to VPN server Pin
stancrm31-Aug-09 20:31
stancrm31-Aug-09 20:31 
QuestionButton inside a textbox? Pin
SevM31-Aug-09 4:31
SevM31-Aug-09 4:31 
AnswerRe: Button inside a textbox? Pin
EliottA31-Aug-09 4:52
EliottA31-Aug-09 4:52 
AnswerRe: Button inside a textbox? Pin
monstale31-Aug-09 4:55
monstale31-Aug-09 4:55 
GeneralRe: Button inside a textbox? Pin
EliottA31-Aug-09 5:07
EliottA31-Aug-09 5:07 
AnswerRe: Button inside a textbox? Pin
Henry Minute31-Aug-09 5:34
Henry Minute31-Aug-09 5:34 
Questioninvoke event from diffrent class hierarchy Pin
Ronenb31-Aug-09 3:41
Ronenb31-Aug-09 3:41 
AnswerRe: invoke event from diffrent class hierarchy Pin
Henry Minute31-Aug-09 5:50
Henry Minute31-Aug-09 5:50 
QuestionHow to add the scroll bar Pin
Fired.Fish.Gmail31-Aug-09 2:44
Fired.Fish.Gmail31-Aug-09 2:44 
QuestionLog Off Computer Fails Pin
Abdul Rahman Hamidy31-Aug-09 2:11
Abdul Rahman Hamidy31-Aug-09 2:11 
AnswerRe: Log Off Computer Fails Pin
monstale31-Aug-09 2:56
monstale31-Aug-09 2:56 
GeneralRe: Log Off Computer Fails Pin
Abdul Rahman Hamidy1-Sep-09 18:25
Abdul Rahman Hamidy1-Sep-09 18:25 
GeneralRe: Log Off Computer Fails [modified] Pin
monstale1-Sep-09 22:55
monstale1-Sep-09 22:55 
Hi,

you're lucky, because I've got announcement for your post. Smile | :)
Okay, I have a way:
You may use
Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding);

and then
void SystemEvents_SessionEnding(object sender, Microsoft.Win32.SessionEndingEventArgs e)
{
    switch (e.Reason)
    {
        case Microsoft.Win32.SessionEndReasons.Logoff:
            break;
        case Microsoft.Win32.SessionEndReasons.SystemShutdown:
            break;
        default:
            break;
    }
}

you may omit the switch block, because you don't need it. Everytime the handler is called, Windows logs you off, or shuts down.

IMPORTANT: On Form_Closing (or Form_Closed) you MUST remove handler from SessionEnding-Event:
Microsoft.Win32.SystemEvents.SessionEnding -= new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding)


hope it helps Smile | :)
kind regards

modified on Wednesday, September 2, 2009 5:14 AM

GeneralRe: Log Off Computer Fails Pin
Abdul Rahman Hamidy1-Sep-09 23:48
Abdul Rahman Hamidy1-Sep-09 23:48 
GeneralRe: Log Off Computer Fails Pin
monstale2-Sep-09 0:51
monstale2-Sep-09 0:51 
GeneralRe: Log Off Computer Fails Pin
Abdul Rahman Hamidy2-Sep-09 0:55
Abdul Rahman Hamidy2-Sep-09 0:55 
GeneralRe: Log Off Computer Fails Pin
Vishwamr150619-Sep-09 9:04
Vishwamr150619-Sep-09 9:04 
QuestionRGB-Byte[] to BGR-Bitmap? Pin
blacksheep131-Aug-09 2:09
blacksheep131-Aug-09 2:09 
AnswerRe: RGB-Byte[] to BGR-Bitmap? Pin
Henry Minute31-Aug-09 2:22
Henry Minute31-Aug-09 2:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.