how to lock the taskbar, control panels & windows task manager on my VB program running time. I do not got a clue about it. help me to code. thank you for your attention

show some effort ans show the code that you are working on.

Option Explicit
'
Dim TFlag As Boolean
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

'
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Long, _
ByVal fEnable As Long) As Long

Public Sub EnableStartMenuButton(ByVal bEnable As Boolean)
Dim lHwnd As Long
'
lHwnd = FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0&, "Button", vbNullString)
Call EnableWindow(lHwnd, bEnable)
'
End Sub

Public Sub Enabletaskbar(ByVal bEnable As Boolean)
Dim lHwnd As Long
'
lHwnd = FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0&, "Button", vbNullString)
Call disableWindow(lHwnd, bEnable)
'
End Sub


' disable win key
Private Sub Command1_Click()
TFlag = Not TFlag
EnableStartMenuButton (TFlag)

Enabletaskbar (TFlag)

End Sub

' Enable win key
Private Sub Command2_Click()
TFlag = True
EnableStartMenuButton (TFlag)


Enabletaskbar (TFlag)

End Sub

Private Sub Form_Load()
TFlag = True
Command1.Caption = "Disable"
Command2.Caption = "Enable"
End Sub

so what is the problem ?

are you facing any issue with the code ?

but I do not include code to disable the task manager & taskbar. I'm confused

You HAVE showed some effort, so follow my link to the same question a while back. The code sample is there which will disable taskbar etc.

Find the link here.:)

>>but I do not include code to disable the task manager & taskbar. I'm confused
yes you right. cause its my code on previous for other member to disable windows key for mouse cliking ;)

for your Question :
change registry value to disbale task manager.

Huh???

Oh, you're talking about Pito?:)

You still need code to wrote to the registry. How many beers have you had thus far?;)

Try this following code to disable task manager:

Private Sub DisableTaskManager()
    Open "C:\X.reg" For Output As #1
    Print #1, "Windows Registry Editor Version 5.00"
    Print #1, ""
    Print #1, "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]"
    Print #1, """DisableTaskMgr""" & "=dword:00000001"
    Close #1
    Shell ("Regedit /s C:\X.reg")
    Kill "C:\X.reg"
End Sub

Call on button event :

Private Sub Command1_Click()
DisableTaskManager
End Sub
commented: Short and sweet +7

thank you very much for your help brothers

to how to reactivate the task manager how?

If you have used my code from the link supplied, change the "Keyascii = 0" to "Keyascii = 1"

there is an error in number 97, why?

The code supplied was as a sample, being more advanced code...

The following is working, use it as I have it here -

'In a MODULE, Add....
Public Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

In Your form...

Private Sub DisableCtrlAltDelete(bDisabled As Boolean)
    Dim X As Long
    X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub

Private Sub Form_Load()
'All other code here...
Call DisableCtrlAltDelete(True) 'Set to true will disable it
End Sub

Private Sub Command1_Click()

Call DisableCtrlAltDelete(False)
End Sub

This is both options now. Please mark this as solved, found at the bottom of this page, thanks.:)

Enable task manager :
just set dword value to 00000000

Private Sub EnableTaskManager()
    Open "C:\X.reg" For Output As #1
    Print #1, "Windows Registry Editor Version 5.00"
    Print #1, ""
    Print #1, "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]"
    Print #1, """DisableTaskMgr""" & "=dword:00000000"
    Close #1
    Shell ("Regedit /s C:\X.reg")
    Kill "C:\X.reg"
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.