Click here to Skip to main content
15,923,389 members
Home / Discussions / C#
   

C#

 
GeneralRe: textbox in a webpage problem Pin
Dave Kreskowiak23-Sep-04 0:32
mveDave Kreskowiak23-Sep-04 0:32 
GeneralRe: textbox in a webpage problem Pin
sreejith ss nair23-Sep-04 0:38
sreejith ss nair23-Sep-04 0:38 
GeneralRe: textbox in a webpage problem Pin
shambho23-Sep-04 4:21
shambho23-Sep-04 4:21 
GeneralMinimizing a form Pin
exhaulted22-Sep-04 23:25
exhaulted22-Sep-04 23:25 
GeneralRe: Minimizing a form Pin
sreejith ss nair23-Sep-04 1:15
sreejith ss nair23-Sep-04 1:15 
GeneralRe: Minimizing a form Pin
eggie523-Sep-04 2:16
eggie523-Sep-04 2:16 
GeneralPlease Help Pin
exhaulted22-Sep-04 23:13
exhaulted22-Sep-04 23:13 
GeneralRe: Please Help Pin
sreejith ss nair23-Sep-04 1:35
sreejith ss nair23-Sep-04 1:35 
hi,
I am trying to help you out. But we can see upto what level i can.;)

You Wrote :

When the user logs windows off the program asks for the password, there will be times when the users at the ahop need to log off / shut down the pc and they don't know the password so the pc wil just hang or wait for an end task. This is the problem, how can i allow the system to shut the program down when the user logs off but at the same time stop the user from closing the program using alt + F4 or the cross in the corner of the form unless they have the password. .


Here if the user is is trying to logoff then you don't want to ask the user to enter password. Am i right ?


See here You can use members in Win32. I will explain how. We have microsoft.Win32 namespace in .NET. Which provides two types of classes,
those that handle events raised by the operating system and those that manipulate the system registry. Here SessionEndReasons is an enum which give you the information that how the current logon session is ending(please see MSDN for more help). You can test this on the closeing event of your form. That means you need to override the oncloseing event in your application.

Eg.

Using Microsoft.Win32.


namespace xx
{
class form
{
//This is not full source code. Only the core part.
protected override void OnClosing(CancelEventArgs e)
{
if(SessionEndReasons.Logoff)
{
//don't ask your user for password

e.Cancel=false;// This will help you to deside whether you want to close or not.
}
else
{
//Ask for password
e.Cancel =true;//This will cancel the closeing event.
}
base.OnClosing (e);
}
}}Is it fine or you want some more explanation

**************************
S r e e j i t h N a i r
**************************;)

GeneralRe: Please Help Pin
exhaulted23-Sep-04 3:09
exhaulted23-Sep-04 3:09 
GeneralRe: Please Help Pin
sreejith ss nair23-Sep-04 3:24
sreejith ss nair23-Sep-04 3:24 
GeneralRe: Please Help Pin
Stefan Troschuetz23-Sep-04 3:39
Stefan Troschuetz23-Sep-04 3:39 
GeneralRe: Please Help Pin
Stefan Troschuetz23-Sep-04 3:44
Stefan Troschuetz23-Sep-04 3:44 
GeneralRe: Please Help Pin
exhaulted23-Sep-04 4:00
exhaulted23-Sep-04 4:00 
GeneralRe: Please Help Pin
Stefan Troschuetz23-Sep-04 4:11
Stefan Troschuetz23-Sep-04 4:11 
GeneralRe: Please Help Pin
exhaulted23-Sep-04 5:37
exhaulted23-Sep-04 5:37 
Generallast focusd event Pin
Sakkijha22-Sep-04 23:12
Sakkijha22-Sep-04 23:12 
GeneralRe: last focusd event Pin
Dave Kreskowiak23-Sep-04 0:29
mveDave Kreskowiak23-Sep-04 0:29 
GeneralRe: last focusd event Pin
sreejith ss nair23-Sep-04 0:44
sreejith ss nair23-Sep-04 0:44 
Generalabout conecting c# with oracle database Pin
ydderf222-Sep-04 21:14
ydderf222-Sep-04 21:14 
GeneralRe: about conecting c# with oracle database Pin
Heath Stewart22-Sep-04 22:00
protectorHeath Stewart22-Sep-04 22:00 
GeneralUsing C# treeview of compact framework problem Pin
ting66822-Sep-04 20:54
ting66822-Sep-04 20:54 
GeneralCasting A String to a control Pin
Nick Price22-Sep-04 13:37
Nick Price22-Sep-04 13:37 
GeneralRe: Casting A String to a control Pin
Xenther22-Sep-04 13:40
Xenther22-Sep-04 13:40 
GeneralRe: Casting A String to a control Pin
Nick Parker22-Sep-04 14:47
protectorNick Parker22-Sep-04 14:47 
GeneralRe: Casting A String to a control Pin
Nick Price23-Sep-04 6:24
Nick Price23-Sep-04 6:24 

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.