Click here to Skip to main content
15,891,316 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: RGB-Byte[] to BGR-Bitmap? Pin
blacksheep131-Aug-09 2:51
blacksheep131-Aug-09 2:51 
GeneralRe: RGB-Byte[] to BGR-Bitmap? Pin
Henry Minute31-Aug-09 5:08
Henry Minute31-Aug-09 5:08 
QuestionVisual Studio 2005 - Create Cubes with Analysis Services Pin
Mschauder31-Aug-09 1:37
Mschauder31-Aug-09 1:37 
AnswerRe: Visual Studio 2005 - Create Cubes with Analysis Services Pin
monstale31-Aug-09 2:09
monstale31-Aug-09 2:09 
QuestionHow to create MimeFilter in c# Pin
svt gdwl31-Aug-09 1:21
svt gdwl31-Aug-09 1:21 
QuestionEncrypt and Decrypt an assembly Pin
Member 444864731-Aug-09 1:19
Member 444864731-Aug-09 1:19 
AnswerRe: Encrypt and Decrypt an assembly Pin
Henry Minute31-Aug-09 2:24
Henry Minute31-Aug-09 2:24 
GeneralRe: Encrypt and Decrypt an assembly Pin
Member 444864731-Aug-09 17:31
Member 444864731-Aug-09 17:31 
QuestionOCR Pin
abbd31-Aug-09 0:18
abbd31-Aug-09 0:18 
AnswerRe: OCR Pin
monstale31-Aug-09 0:35
monstale31-Aug-09 0:35 
AnswerRe: OCR Pin
Rajesh R Subramanian31-Aug-09 0:50
professionalRajesh R Subramanian31-Aug-09 0:50 

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.