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
  • 相关阅读:
    vi、vim选中区域(矩形块)visual block(块模式)批量删注释
    [网页设计]CSS之浮动float
    [网页设计]前端工程师应该具备的三种思维
    [网页设计]auto的使用
    [网页设计]模仿某网站招聘列表
    [网页设计]前端知识查漏补缺篇(一)
    [网页设计]c ss高效开发实战看完了,Bootstrap学习是关键
    [网页设计]前端优化还可以这么优化!
    [网页设计]HTML DOM(学习笔记一)
    [网页设计]HTML DOM(学习笔记二)
  • 原文地址:https://www.cnblogs.com/freeliver54/p/597886.html
Copyright © 2011-2022 走看看