Disable Exiting

Make it impossible to exit form without password

Page 1 of 1

9 Replies - 1741 Views - Last Post: 02 June 2010 - 02:06 PM Rate Topic: -----

#1 danielair  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 22
  • View blog
  • Posts: 118
  • Joined: 12-July 09

Disable Exiting

Posted 16 May 2010 - 05:33 PM

Okay well I'm trying to make a secondary security system to use on my computer. I made a form with a password field in the middle, the size of the form cover the entire screen and there is no border. But now I'm trying to find a way to remove all possible ways to exit the form without enter the correct password like CTRL+ALT+Del, ALT+F4, CTRL+ESC, CTRL+TAB, WIN KEY, or any of the short keys. I'm using Windows Vista Ultimate and everything I've found is for 98 and XP and won't seem to work. So in other-words I want it to be impossible to exit the form without entering the correct password. If you could help that would be wonderful.

Thanks in advance,
Daniel

Is This A Good Question/Topic? 0
  • +

Replies To: Disable Exiting

#2 JynxRD  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 78
  • Joined: 06-November 08

Re: Disable Exiting

Posted 16 May 2010 - 05:44 PM

View Postdanielair, on 16 May 2010 - 04:33 PM, said:

Okay well I'm trying to make a secondary security system to use on my computer. I made a form with a password field in the middle, the size of the form cover the entire screen and there is no border. But now I'm trying to find a way to remove all possible ways to exit the form without enter the correct password like CTRL+ALT+Del, ALT+F4, CTRL+ESC, CTRL+TAB, WIN KEY, or any of the short keys. I'm using Windows Vista Ultimate and everything I've found is for 98 and XP and won't seem to work. So in other-words I want it to be impossible to exit the form without entering the correct password. If you could help that would be wonderful.

Thanks in advance,
Daniel



On load have the application disable ctrl alt del

    Private Property AwY As Object

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
    Public Const SPI_SCREENSAVERRUNNING = 97

    Public Sub Disable_Ctrl_Alt_Del()

        'Disables the Crtl+Alt+Del
        Dim AyW As Integer
        Dim TurFls As Boolean
        AwY = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, TurFls, 0)
    End Sub



And then disable the task bar as well.

This post has been edited by JynxRD: 16 May 2010 - 05:45 PM

Was This Post Helpful? 0
  • +
  • -

#3 danielair  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 22
  • View blog
  • Posts: 118
  • Joined: 12-July 09

Re: Disable Exiting

Posted 16 May 2010 - 06:11 PM

I had to change it to the following to remove errors, but it still won't work.

    Private Property AwY() As Object
        Get
        End Get
        Set(ByVal value As Object)
        End Set
    End Property
    Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Boolean, ByVal fuWinIni As Long) As Long
    Public Const SPI_SCREENSAVERRUNNING = 97

    Public Sub Disable_Ctrl_Alt_Del()

        'Disables the Crtl+Alt+Del
        Dim AyW As Integer
        Dim TurFls As Boolean
        AwY = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, TurFls, 0)
    End Sub



Thanks,
Daniel

This post has been edited by danielair: 16 May 2010 - 06:16 PM

Was This Post Helpful? 0
  • +
  • -

#4 JynxRD  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 78
  • Joined: 06-November 08

Re: Disable Exiting

Posted 16 May 2010 - 06:41 PM

Yea I was thinking XP only. Should be different for Vista, Windows7.
-

Actually the more I think about it, it may be more difficult then I'm thinking due to the security in newer versions of Windows. I don't know if I'd want to do it via code honestly. But you'd probably have to create source to edit/create security profiles..etc. But honestly, how is this any different than locking your PC when you leave? Or setting the lock to occur if idle for so long.

This post has been edited by JynxRD: 16 May 2010 - 07:07 PM

Was This Post Helpful? 0
  • +
  • -

#5 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Disable Exiting

Posted 17 May 2010 - 11:24 PM

OK, Here's some code which you might find useful...

The code to disable task manager:
Shell("REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /t REG_DWORD /d 1 /f", AppWinStyle.Hide)



And in turn to enable it:
Shell("REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /t REG_DWORD /d 1 /f", AppWinStyle.Hide)




Now, create a new timer on your form, and set the tick to 100. Put this code in the timer_tick event:
For each P as Process in Process.GetProcesses
'You can add any other processes you don't want here, just remember to start them again when the application exits
If P.ProcessName = "explorer" then P.Kill
Next
'Clip the cursor so it will be confined to the form...
Cursor.Clip = Me.RectangleToScreen(Me.ClientRectangle)
'Make sure the form is always topmost...
Me.TopMost = True



Now, go to the FormClosing event of your login form, and add this code:
  If e.CloseReason = Not CloseReason.WindowsShutDown Then
            e.Cancel = True
  End If





If you need any more code for anything else, just ask...
Was This Post Helpful? 0
  • +
  • -

#6 danielair  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 22
  • View blog
  • Posts: 118
  • Joined: 12-July 09

Re: Disable Exiting

Posted 26 May 2010 - 02:27 PM

Everything works great I just have one question, how can I protect against someone pressing ALT + F4 and closing the currently open window?

Thanks,
Daniel
Was This Post Helpful? 0
  • +
  • -

#7 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1031
  • View blog
  • Posts: 4,013
  • Joined: 02-July 08

Re: Disable Exiting

Posted 26 May 2010 - 03:38 PM

Set the form's KeyPreview to True and then:

Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    If e.Modifiers = Keys.Alt AndAlso e.KeyCode = Keys.F4 Then
      MessageBox.Show("I caught it!")
      e.Handled = True
    End If
End Sub

Was This Post Helpful? 0
  • +
  • -

#8 danielair  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 22
  • View blog
  • Posts: 118
  • Joined: 12-July 09

Re: Disable Exiting

Posted 26 May 2010 - 05:06 PM

This works fine thanks :) But I tried changing the keycode thing to work for CTRL + ALT + DELETE and for some reason it won't work... Any ideas why?

Thanks,
Daniel
Was This Post Helpful? 0
  • +
  • -

#9 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1031
  • View blog
  • Posts: 4,013
  • Joined: 02-July 08

Re: Disable Exiting

Posted 26 May 2010 - 05:37 PM

There are a lot of people helping you here, think about adding some thanks their way! Especially since you never provided some code initially - which is kind of a rule here.
Was This Post Helpful? 0
  • +
  • -

#10 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Disable Exiting

Posted 02 June 2010 - 02:06 PM

It won't work with CTRL + ALT + DEL because it is a global system hook. CTRL + ALT + DEL cannot be intercepted, disabled or tampered with in any way, except by digging deep into your system32 and re-writing a load of MS files. Take a look at this as well. It might be helpfull, but I don't think it will work in Win7 or Vista. Please give some thanks for my posts, as I have spent quite a while on them. If you like someone's post, or it helps you, press the + buton! Thanks!
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1