كود لتفعيل وتعطيل اداره المهام التاسك مانجر
كود
Option Explicit On
Option Strict On
Imports Microsoft.Win32
Public Class Form1
Private Structure RegistryValue
Public Path As String
Public Value As String
End Structure
Private rv As RegistryValue = New RegistryValue()
Private ReadOnly Property OpenRegistryKeyForWriting() As RegistryKey
Get
Const Path As String = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
Return Registry.CurrentUser.OpenSubKey(Path, True)
End Get
End Property
Private Sub EnableDisableTaskmanager(ByVal Index As String)
Dim hKey As RegistryKey = Nothing
Try
Select Case Index
Case "Disabled"
hKey = Me.OpenRegistryKeyForWriting()
If hKey Is Nothing Then
hKey = Registry.CurrentUser.CreateSubKey(rv.Path)
hKey.SetValue(rv.Value, 1, RegistryValueKind.DWord)
Else
hKey = Registry.CurrentUser.CreateSubKey(rv.Path)
hKey.SetValue(rv.Value, 1, RegistryValueKind.DWord)
End If
Case "Enabled"
hKey = Me.OpenRegistryKeyForWriting()
If hKey IsNot Nothing Then
hKey = Registry.CurrentUser.CreateSubKey(rv.Path)
hKey.SetValue(rv.Value, 0, RegistryValueKind.DWord)
End If
End Select
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Info")
Finally
If hKey IsNot Nothing Then
hKey.Close()
End If
End Try
End Sub
Private Function OSVersion() As Boolean
If System.Environment.OSVersion.Platform = PlatformID.Win32NT = True Then
Return True
Else
Return False
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
If Me.OSVersion = False Then
MessageBox.Show("This example works only under WinNT or higher…", "Info")
Application.Exit()
End If
Me.CenterToScreen()
With Me.rv
.Path = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
.Value = "DisableTaskMgr"
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Me.EnableDisableTaskmanager("Disabled")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button2.Click
Me.EnableDisableTaskmanager("Enabled")
End Sub
End Class
كود
Option Explicit On
Option Strict On
Imports Microsoft.Win32
Public Class Form1
Private Structure RegistryValue
Public Path As String
Public Value As String
End Structure
Private rv As RegistryValue = New RegistryValue()
Private ReadOnly Property OpenRegistryKeyForWriting() As RegistryKey
Get
Const Path As String = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
Return Registry.CurrentUser.OpenSubKey(Path, True)
End Get
End Property
Private Sub EnableDisableTaskmanager(ByVal Index As String)
Dim hKey As RegistryKey = Nothing
Try
Select Case Index
Case "Disabled"
hKey = Me.OpenRegistryKeyForWriting()
If hKey Is Nothing Then
hKey = Registry.CurrentUser.CreateSubKey(rv.Path)
hKey.SetValue(rv.Value, 1, RegistryValueKind.DWord)
Else
hKey = Registry.CurrentUser.CreateSubKey(rv.Path)
hKey.SetValue(rv.Value, 1, RegistryValueKind.DWord)
End If
Case "Enabled"
hKey = Me.OpenRegistryKeyForWriting()
If hKey IsNot Nothing Then
hKey = Registry.CurrentUser.CreateSubKey(rv.Path)
hKey.SetValue(rv.Value, 0, RegistryValueKind.DWord)
End If
End Select
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Info")
Finally
If hKey IsNot Nothing Then
hKey.Close()
End If
End Try
End Sub
Private Function OSVersion() As Boolean
If System.Environment.OSVersion.Platform = PlatformID.Win32NT = True Then
Return True
Else
Return False
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
If Me.OSVersion = False Then
MessageBox.Show("This example works only under WinNT or higher…", "Info")
Application.Exit()
End If
Me.CenterToScreen()
With Me.rv
.Path = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
.Value = "DisableTaskMgr"
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Me.EnableDisableTaskmanager("Disabled")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button2.Click
Me.EnableDisableTaskmanager("Enabled")
End Sub
End Class