This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Thursday, January 22, 2009

Deactivate or Reactivate the Task Manager(VB.NET)

Deactivate or Reactivate the Task Manager(VB.NET)

Version: VB 2005
Compatibility: VB 2005
Category: Windows Registry

This example deactivates or reactivates the Windows Task Manager. The example needs two buttons: Button1 and Button2.

Declarations:
Option Explicit On
Option Strict On

Imports Microsoft.Win32


Code:
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

0 comments:

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Blog Archive

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger