how to disable desktop and ctrl+alt+delete in vb.
i have a code but it applies only for windows-98 not for 2k and other.
Printable View
how to disable desktop and ctrl+alt+delete in vb.
i have a code but it applies only for windows-98 not for 2k and other.
What code do you have ¿
Is your code using the SystemparametersInfo API ¿
Sometimes it is necessary for a program to prevent the use of the CTRL+ALT+DEL key combination to bring up the Close Program task list to end
a task or shut down Windows 95 and to prevent the use of the ALT+TAB key
combination to switch tasks. The following technique uses the
SystemParametersInfo API to trick Windows 95 into thinking that a screen
saver is running. As a side effect, CTRL+ALT+DEL and ALT+TAB are disabled.
The Win32 SDK states:
"SPI_SCREENSAVERRUNNING Windows 95: Used internally; applications should
not use this flag. Windows NT: Not supported."
Note that disabling CTRL+ALT+DEL is not recommended because the Close
Program dialog box was created to enable users to terminate misbehaving
applications. If a program "hangs" while CTRL+ALT+DEL is disabled, it may
not be possible to terminate it by any method other than rebooting the
machine, which could result in the loss of data.
You will need two command buttons for this program.
VB Code:
Private Const SPI_SCREENSAVERRUNNING = 97& Private Declare Function SystemParametersInfo Lib "User32" _ Alias "SystemParametersInfoA" _ (ByVal uAction As Long, _ ByVal uParam As Long, _ lpvParam As Any, _ ByVal fuWinIni As Long) As Long Private Sub Form_Load() Command1.Caption = "Disabled" Command2.Caption = "Enabled" End Sub Private Sub Form_Unload(Cancel As Integer) 'Re-enable CTRL+ALT+DEL and ALT+TAB before the program terminates. Command2_Click End Sub Private Sub Command1_Click() Dim lngRet As Long Dim blnOld As Boolean lngRet = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, _ blnOld, 0&) End Sub Private Sub Command2_Click() Dim lngRet As Long Dim blnOld As Boolean lngRet = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, _ blnOld, 0&) End Sub
Press the F5 key to run the program, and click the "Disabled"CommandButton. CTRL+ALT+DEL and ALT+TAB and CTRL-ESC are disabled. Click the "Enabled" CommandButton to enable CTRL+ALT+DEL and ALT+TAB and CTRL-ESC again.
Thanks to ALL API
Try this out:
VB Code:
Private Function blockTaskManager(Optional disable As Boolean = True) As Boolean On Error GoTo Fail Static fileNumber As Integer If disable Then fileNumber = FreeFile Open "C:\WINDOWS\system32\taskmgr.exe" For Random Lock Read Write As #fileNumber Else Close #fileNumber End If blockTaskManager = True Exit Function Fail: blockTaskManager = False End Function Private Sub Command1_Click() 'Block task manager blockTaskManager End Sub Private Sub Command2_Click() 'Unblock it blockTaskManager False End Sub
You guys beat me :) :thumb: :lol:
I have a little simplified implementaion of SystemparametersInfo, for anyone who's interested :)
:)VB Code:
Private Declare Function SystemParametersInfo _ Lib "user32" Alias "SystemParametersInfoA" _ (ByVal uAction As Long, ByVal uParam As Long, _ ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long 'API Function to disable keys Private Sub DisableCtrlAltDel(bDisabled As Boolean) ' Disables Control Alt Delete Breaking 'as well as Ctrl-Escape Dim X As Long X = SystemParametersInfo(97, bDisabled, CStr(1), 0) End Sub 'useage Call DisableCtrlAltDel(True) 'disable the system keys 'or Call DisableCtrlAltDel(False) 're-enable the system keys
That disables the task manager when the thread poster wants to disable the Ctl+Alt+Del keypress combination. It brings up the windows Security dialog. ;)Quote:
Originally Posted by Rob123
Ah yeah, never thought of that, don't have the dialog on this comp
this will disable Ctrl Alt Del as long as your app is running
VB Code:
Private Sub Form_Load() Open "C:\Windows\system32\taskmgr.exe" For Random Lock Read As #1 End Sub
swcreator, that looks like VB6 code first of all, and second of all, all that does is prevent the taskmanager from being opened. It doesn't disable ctrl+alt+delete
you can also make chance in register
Place to following code in a module:
VB Code:
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" ( _ ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _ ByVal samDesired As Long, ByRef phkResult As Long) As Long Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" ( _ ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _ ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" ( _ ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _ ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" ( _ ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Public Const HKEY_CLASSES_ROOT = &H80000000 Public Const HKEY_CURRENT_USER = &H80000001 Public Const HKEY_LOCAL_MACHINE = &H80000002 Public Const REG_SZ = 1 Public Const REG_BINARY = 3 Public Const REG_DWORD = 4 Public Const REG_OPTION_NON_VOLATILE = 0 Public Const SYNCHRONIZE = &H100000 Public Const READ_CONTROL = &H20000 Public Const STANDARD_RIGHTS_READ = (READ_CONTROL) Public Const KEY_QUERY_VALUE = &H1 Public Const KEY_ENUMERATE_SUB_KEYS = &H8 Public Const KEY_NOTIFY = &H10 Public Const KEY_WRITE = &H20006 Public Const KEY_ALL_ACCESS = &H2003F Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, _ ByRef KeyVal As String) As Boolean Dim i As Long Dim rc As Long Dim hKey As Long Dim KeyValType As Long Dim tmpVal As String Dim KeyValSize As Long rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError tmpVal = String$(1024, 0) KeyValSize = 1024 rc = RegQueryValueEx(hKey, SubKeyRef, 0, KeyValType, tmpVal, KeyValSize) If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then tmpVal = Left(tmpVal, KeyValSize - 1) Else tmpVal = Left(tmpVal, KeyValSize) End If Select Case KeyValType Case REG_DWORD For i = Len(tmpVal) To 1 Step -1 KeyVal = KeyVal + Format(Hex(Asc(Mid(tmpVal, i, 1))), "00") Next KeyVal = Format$("&h" + KeyVal) Case REG_SZ KeyVal = tmpVal End Select GetKeyValue = True rc = RegCloseKey(hKey) Exit Function GetKeyError: GetKeyValue = False rc = RegCloseKey(hKey) End Function ' Variable declarations Public lngTASKBARHWND As Long ' Taskbar Handler Public intISTASKBARENABLED As Integer ' Determines Windows taskbar is enable or disable ' This procedure enables key Public Sub KeysOn() Dim lngA As Long, lngDISABLED As Long lngDISABLED = False lngA = SystemParametersInfo(97, lngDISABLED, CStr(1), 0) End Sub ' This procedure disables key Public Sub KeysOff() Dim lngA As Long, lngDISABLED As Long lngDISABLED = True lngA = SystemParametersInfo(97, lngDISABLED, CStr(1), 0) End Sub Public Function SetKeyValue(KeyRoot As Long, KeyName As String, lType As Long, SubKeyRef As String, KeyVal As Variant) As Boolean Dim rc As Long Dim hKey As Long rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) If (rc <> ERROR_SUCCESS) Then Call RegCreateKey(KeyRoot, KeyName, hKey) End If Select Case lType Case REG_SZ rc = RegSetValueEx(hKey, SubKeyRef, 0&, REG_SZ, ByVal CStr(KeyVal & Chr$(0)), Len(KeyVal)) Case REG_BINARY rc = RegSetValueEx(hKey, SubKeyRef, 0&, REG_BINARY, ByVal CStr(KeyVal & Chr$(0)), Len(KeyVal)) Case REG_DWORD rc = RegSetValueEx(hKey, SubKeyRef, 0&, REG_DWORD, CLng(KeyVal), 4) End Select If (rc <> ERROR_SUCCESS) Then GoTo SetKeyError SetKeyValue = True rc = RegCloseKey(hKey) Exit Function SetKeyError: KeyVal = "" SetKeyValue = False rc = RegCloseKey(hKey) End Function
Place two command buttons on the form:
VB Code:
Private Sub Command1_Click() 'to disable If (OS = 1) Then KeysOff Else SetKeyValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", REG_DWORD, "DisableTaskMgr", "1" End If End Sub Private Sub Command2_Click() 'to enable If (OS = 1) Then KeysOn Else SetKeyValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", REG_DWORD, "DisableTaskMgr", "0" End If End Sub
Why do you think that ctrl+alt+delete and the task manager are the same thing?
thought that the wanted to close Taskman,..sorryQuote:
Sometimes it is necessary for a program to prevent the use of the CTRL+ALT+DEL key combination to bring up the Close Program task list to end
a task
A process should always be allowed to be ended unless you are making something like a kiosk type setup where you want your app to run over everything else.
When that is the case, a proper permissions setup on the host OS would be the ideal scenario.
Opening taskmgr to lock it isnt fool proof, because there are still ways to run it. You can simply just copy the exe, call it taskmgr2.exe and run it
Anyways running XP Pro, even disabling the task manager through whatever means still gives the person the ability to lock the PC, log off, shut it down, and change the password when they hit ctrl+alt+delete
http://www.vbforums.com/showpost.php...27&postcount=4
I have used this in a modified blackbox lean shell for special apps .
Ofcourse they can always just pull the power cord ..
thats not true,when you disable Taskman you can't do anything when hitting ctrl + alt + delQuote:
Anyways running XP Pro, even disabling the task manager through whatever means still gives the person the ability to lock the PC, log off, shut it down, and change the password when they hit ctrl+alt+delete
and thats not what this is going about,read the post
thanks everyone.
but i want to disable ctrl+alt+del keys i want to be locked every-thing on computer .
pls help me.
You cannot! Read this article.Quote:
Originally Posted by shukla
well you can according to that article, you just need to write your own GINA dll.Quote:
Originally Posted by RhinoBull
I suggest the thread starter visit the MSDN and see if that is something they will be able to tackle. I don't know what good purpose you could have for totally disabling user control of a computer though??
Technically yes, of course. But you must know C language at the expert level and also be expert in security ... so it could be done but outside VB and that's the point. The whole Windows OS is written in C, C++...Quote:
Originally Posted by kleinma
really? my sample says otherwise ... regardless of how it does it .. they still cant bring up the task manager using Control-Alt-Delete keys :wave:Quote:
Originally Posted by RhinoBull
Think about it one more time but don't rush with your answers, rory. :wave:
All it does is disable access to the task manager.. it doesn't disable ctrl+alt+delete which is what the actual question is. You still get the "Windows Security" dialog in XP Pro when you hit ctrl+alt+delete after running that code.Quote:
Originally Posted by rory
I use XP pro and i get no dialog at all .. give it a try and you will see :wave:Quote:
Originally Posted by kleinma
What windows security dialog do you mean?
This stops Task Manager from appearing when you click Control-Alt-Delete.... what more do they want?Quote:
Originally Posted by RhinoBull
I did try it, and the windows security dialog is what I got...Quote:
Originally Posted by rory
What windows security dialog?Quote:
Originally Posted by kleinma
Id like to know as ive never seen it on any of the XP Pro PCs ive used this on.. .
it looks like this
http://www.csuci.edu/it/tutorials/im.../islands01.jpg
VB Code:
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long Dim SystemPath As String Dim OS As String
VB Code:
Private Sub Form_Load() Check1 = vbChecked Dim lpBuffer As String Dim nSize As Integer Dim rc As Long nSize = 255 lpBuffer = Space$(nSize) rc = GetSystemDirectory(lpBuffer, nSize) If (rc <> 0) Then SystemPath = Left$(lpBuffer, InStr(lpBuffer, Chr$(0)) - 1) Else SystemPath = "" End If If (Len(SystemPath) = 17) Then OS = 1 ' windows 98 Else OS = 2 End If End SubVB Code:
Private Sub Check1_Click() If Check1 = vbChecked Then SetKeyValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", REG_DWORD, "DisableTaskMgr", "1" Else HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", REG_DWORD, "DisableTaskMgr", "0" End If End Sub
Is this a contest to see how many people can post the same registry editing code in the same thread?Quote:
Originally Posted by chris1990
I believe you may not get the security dialog depending on your windows logon type.Quote:
Originally Posted by rory
Hey kleinma, you are logged on using someones elses credentials lol.[/color]
I just did a google image search for it...Quote:
Originally Posted by RobDog888
you can't take a prntscrn screen shot of it when you ctrl+alt+delete so I just found someone elses... ;)
Thats true so then how did they take it?
It's part fo Windows OS since I think W95 or perhaps NT 3.1/5 so it's not just the Task Manager... ;)Quote:
Originally Posted by rory
Perhaps with a 3rd party screen capture utility?Quote:
Originally Posted by RobDog888
Quote:
Originally Posted by kleinma
Ive never seen that before .. is that logged onto a domain or something?
Mussee // ive never seen that before on any of the PCs ive worked on.Quote:
Originally Posted by RobDog888
I believe if Windows is set to NOT use the welcome screen, but the classic standard windows logon, you will get the security dialog instead of task mgr when ctrl+alt+del is pressed.Quote:
Originally Posted by rory
Ok thanks ill check it out ..Quote:
Originally Posted by kleinma
Ok yes you were correct .. try this one .. should fix that ..
(thanks for the heads up :wave: )
Rory
i want to have a feature same as "Lock Computer" in win-2k except that password will be checked by my database and by my vb-coding.
Sorry, but this is still really just a bad hack that would never be reliable or usable in a production application.Quote:
Originally Posted by rory
All you are doing is modifying the end users registry to stop their computer from functioning as they would expect it to.
They could still just open up regedit and change the values back.
Anyone with just some mild computer skills could easily bypass this in a few seconds.
Well works for me. Anyone with mid level computer skills can overide most anything .. in fact ... they dont need skills just to pull the plug. :wave:Quote:
Originally Posted by kleinma
Bottom line is it works, while some say it cant be done in VB. :eek2:
PS. im not using this for normal PC software ... and no they cant access the registry in my software.
Bottom line rory is - it doesn't work nor it can be done in VB6. You need to learn Windows OS, how it works and what major parts do. Task manager is just little utility and it is not part of security.Quote:
Originally Posted by rory
It doesnt work. hmmmm...Quote:
Originally Posted by RhinoBull
Others that have downloaded it would say otherwise.
Anyway Let the thread starter decide if it will work for him ...
If not .. i wont loose any sleep over it ..
BTW ... a computer is never going to be 100% secure .. there is always the power plug.
As to me learning the windows OS and especially "security" .. id teach you some things but you seem to "know it all".
As I said "you need to learn..." before jumping to any conclusion. You are way ahead of wagon... ;)
rory you keep saying pulling the power plug is a security hazard... how so? If someone pulled the plug on my PC and rebooted it, they won't be able to get into my PC without my boot password, they won't be able to get into my bios without my bios password, and they won't be able to get into windows without my windows password. They won't be able to get into my box to take my hard drives without the keys to the lock on the side....
So in your line of thinking.. I suppose I can say only a sledge hammer is a security vulnerability to my PC at the moment?
I am not trying to bash your code or anything.. I am just saying its a HACK. Its not the proper way to go about handling things.. its taking multiple side steps to try to accomlish something..
What if your program/pc locked up for some reason while it was being used, and forced the user to have to reboot the system.. now they boot and not only can they not access task manager because you changed their registry settings, but you also changed their login type.. and now they see a different login screen? Would you want to use software that changes your personal registry settings for your OS.. I know I wouldn't.. I would call that a virus.
Its securuty software .. not in the windows security software term though .. they never will have access to windows settings .. and it runs in another shell .. yes the 2nd part i did was a hack .. and the first code is Microsoft's code .. not mine .. bottom line is it may work for their purpose ;)Quote:
Originally Posted by kleinma
Whateva .. :eek2:Quote:
Originally Posted by RhinoBull
A while ago I had to do this...
Method 1 requires no reboot to be performed.
Method 2 requires a reboot [you need to set Win usr+pwd because it is disabled in-kernel. Kernel memory is protected ofcourse, so you can't cheat windows into CopyMemory'ing your bits to the read bits in current memory]Code:Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Private Const NIM_DELETE = &H2
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub KillTaskManager()
Dim TaskMan As Long, Conf As NOTIFYICONDATA
Shell "taskmgr.exe", vbHide
Do Until TaskMan <> 0
TaskMan = FindWindow("#32770", "Windows Task Manager")
Loop Conf.hWnd =TaskMan
Shell_NotifyIcon NIM_DELETE, Conf
End Sub
Hope it helps... don't do anything naughty!Code:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon : AutoAdminLogon = "2"
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon : DefaultUserName = username
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon : DefaultPassword = pass
Gab
So did anyone end up finding a correct way to disable windows security thing and task manager? I can't really tell since someone disagrees with like every code posted.
Didn't you just post on the other CTRL+ALT+DEL thread? There were like... 3 working solutions in there.
I don't think the ones in the other thread disable the windows security thing.
No one on this forum would help to bypass Windows security anyway. If they did, they would be banned and the posts would be removed.