zoukankan      html  css  js  c++  java
  • VS2005 My.Computer.Registry 对象 操作注册表 简单示例

    本例将通过My.Computer.Registry 对象 对注册表的修改
    添加一个右键菜单项到IE浏览器
    通过该菜单项
    调用C:\a.html
    效果是弹出一个提示

    1.添加Microsoft.VisualBasic.dll引用
    2.创建vb页面 编码以实现对注册表的操作

    示例代码如下

        Protected Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click

            
    '创建注册表项
            'My.Computer.Registry.CurrentUser.CreateSubKey("Software\Microsoft\Internet Explorer\MenuExt\MyTestKey")
            '' Change MyTestKeyValue to This is a test value. 
            'My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\MyTestKey", _
            '"MyTestKeyValue", "This is a test value.")

            
    '确定值是否存在
            'If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\MyTestKey", "MyTestKeyValue", Nothing) Is Nothing Then
            '    MsgBox("Sorry,Value does not exist.")
            'Else
            '    MsgBox("OK,Value exist.")
            'End If

            
    '读取值
            'Dim readValue As String
            'readValue = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\MyTestKey", "MyTestKeyValue", Nothing)
            'MsgBox("The value is :" & readValue)

            
    '将值写入注册表项
            'a.html 内容
            '<script language="javascript" type="text/javascript">
            'alert("");
            '</script>

            
    'My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\MyTestKey", "", "C:\a.html")

            
    'My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\MyTestKey", "Contexts", "1", Microsoft.Win32.RegistryValueKind.DWord)

            
    '删除注册表项
            'My.Computer.Registry.CurrentUser.DeleteSubKey("Software\Microsoft\Internet Explorer\MenuExt\MyTestKey", False)

        
    End Sub
  • 相关阅读:
    google
    学习Linux第六天
    对比教学大纲
    周 记
    《世界是数字的》读后感
    《我是一只IT小小鸟》读后感
    前端小知识
    JavaScript 执行机制
    执行栈和任务队列
    支付宝前端员工培训手册
  • 原文地址:https://www.cnblogs.com/freeliver54/p/597886.html
Copyright © 2011-2022 走看看