''' <summary>
''' 注册表设置值
''' </summary>
''' <param name="strKey"></param>
''' <param name="strName"></param>
''' <param name="strValue"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function SetRegistry(ByVal strKey As String, ByVal strName As String, ByVal strValue As String) As Boolean
Try
Dim Key_LocalMachine As Microsoft.Win32.RegistryKey
Key_LocalMachine = My.Computer.Registry.LocalMachine 'get the key path of HKEY_LOCAL_MACHINE
Dim Key_Created As Microsoft.Win32.RegistryKey
Key_Created = Key_LocalMachine.OpenSubKey(strKey, True) 'set the true for can write
If Key_Created Is Nothing Then
Key_Created = Key_LocalMachine.CreateSubKey(strKey) 'careat the key
End If
Key_Created.SetValue(strName, strValue) 'set the values of the key
Return True
Catch ex As Exception
Return False
End Try
End Function
''' <summary>
''' 获取注册表值
''' </summary>
''' <param name="strKey"></param>
''' <param name="strName"></param>
''' <param name="strValue"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function GetValueFromRegistry(ByVal strKey As String, ByVal strName As String, ByRef strValue As String) As Boolean
Try
Dim Key_LocalMachine As Microsoft.Win32.RegistryKey
Key_LocalMachine = My.Computer.Registry.LocalMachine 'get the key path of HKEY_LOCAL_MACHINE
Dim Key_Get As Microsoft.Win32.RegistryKey
Key_Get = Key_LocalMachine.OpenSubKey(strKey)
If Key_Get Is Nothing Then
Return False
End If
strValue = Key_Get.GetValue(strName) 'get the values of the key
Return True
Catch ex As Exception
Return False
End Try
End Function
''' <summary>
''' 判断值是否存在
''' </summary>
''' <param name="strKey"></param>
''' <param name="strName"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function RegistryExist(ByVal strKey As String, ByVal strName As String) As Boolean
Try
Dim Key_LocalMachine As Microsoft.Win32.RegistryKey
Key_LocalMachine = My.Computer.Registry.LocalMachine 'get the key path of HKEY_LOCAL_MACHINE
Dim Key_Exist As Microsoft.Win32.RegistryKey
Key_Exist = Key_LocalMachine.OpenSubKey(strKey, True) 'set the true for can write
If Key_Exist Is Nothing Then
Return False
End If
If Key_Exist.GetValue(strName) Is Nothing Then
Return False
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
''' <summary>
''' 删除注册表对应值
''' </summary>
''' <param name="strKey"></param>
''' <param name="strName"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function DeleteRegistry(ByVal strKey As String, ByVal strName As String) As Boolean
Try
Dim Key_LocalMachine As Microsoft.Win32.RegistryKey
Key_LocalMachine = My.Computer.Registry.LocalMachine 'get the key path of HKEY_LOCAL_MACHINE
Dim Key_Del As Microsoft.Win32.RegistryKey
Key_Del = Key_LocalMachine.OpenSubKey(strKey, True) 'set the true for can write
If Key_Del Is Nothing Then
Return False
End If
Key_Del.DeleteValue(strName) 'delete the values of the key'name
Return True
Catch ex As Exception
Return False
End Try
End Function

调用:

 SetRegistry("SOFTWARE\XXXX\DIS-ESS\FTP", "User", "")
Dim temvalue As String = ""
GetValueFromRegistry("SOFTWARE\XXXX\DIS-ESS\FTP", "User", temvalue) 'DeleteRegistry("SOFTWARE\Unisys\DIS-ESS\FTP", "User") RegistryExist("SOFTWARE\XXXX\DIS-ESS\FTP", "User")

VB.NET 注册表基本操作的更多相关文章

  1. VB的写法,关于版本写入注册表

    VB的写法,关于版本写入注册表   '软件都有一个关于我们的菜单,单单实现这个功能并不难,困难的是能够将这些信息写入注册表中,这样每次只要弹出这样的窗口,就从注册表里去搜索.这样是不是极大的节省了资源 ...

  2. C#操作注册表——读、写、删除、判断等基本操作

    一.引入命名空间: using Microsoft.Win32; 二.创建注册表项:CreateSubKey(name)方法 添加SubKey时候首先要打开一个表项,并设置参数为true,才能成功创建 ...

  3. VB - 修改注册表

    Vbs中修改注册表的语句主要有: 1.读注册表的关键词和值: 可以通过把关键词的完整路径传递给wshshell对象的regread方法.例如: set ws=wscript.createobject( ...

  4. 入侵检测中需要监控的注册表路径研究(Windows Registry Security Check)

    1. Windows注册表简介 注册表(Registry,繁体中文版Windows称之为登录档)是Microsoft Windows中的一个重要的数据库,用于存储系统和应用程序的设置信息.早在Wind ...

  5. delphi 注册表操作(读取、添加、删除、修改)完全手册

    DELPHI VS PASCAL(87)  32位Delphi程序中可利用TRegistry对象来存取注册表文件中的信息. 一.创建和释放TRegistry对象 1.创建TRegistry对象.为了操 ...

  6. c# asp.net 鼠标改变控件坐标位置,更改控件坐标,注册表保存读取,打印,查找局域网内打印机等等收集

    界面虽然被我弄的很难看,但功能还可以 里边注册表的路径自己设置一下,或者加一个创建注册表的语句,不然会报错 前台: <%@ Page Language="C#" AutoEv ...

  7. C#读取注册表信息

    注册表是视窗系统的一个核心的数据库,在这个数据库中存放中与系统相关的各种参数,这些参数直接控制中系统的启动.硬件的驱动程序安装信息以及在视窗系统上运行的各种应用程序的注册信息等.这就意味着,如果注册表 ...

  8. 64位WINDOWS系统环境下应用软件开发的兼容性问题(CPU 注册表 目录)

    应用软件开发的64 位WINDOWS 系统环境兼容性 1. 64 位CPU 硬件 目前的64位CPU分为两类:x64和IA64.x64的全称是x86-64,从名字上也可以看出来它和 x86是兼容的,原 ...

  9. Delphi的注册表操作

    转帖:Delphi的注册表操作 2009-12-21 11:12:52 分类: Delphi的注册表操作 32位Delphi程序中可利用TRegistry对象来存取注册表文件中的信息.     一.创 ...

随机推荐

  1. 随鼠标移动tab

    <script language="javascript">         function tabChange(obj, id) {             var ...

  2. jQuery Ajax无刷新操作一般处理程序 ashx

    //前台实例代码 aspx文件 <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="ser ...

  3. webpack 教程 那些事儿04-webpack项目实战分析

    这节主要讲解真正项目用用到的 webpack配置问题,项目实战篇 就像我们不会完全做一个项目,不用别人的轮子一样.这个配置我们借用 vue-cli 搭建的配置来研究,因为它已经足够优秀. 有了前面的基 ...

  4. mongodb 释放磁盘空间

    db.copyDatabase("from","to","127.0.0.1:16161"); 将127.0.0.1上的from库.拷贝到t ...

  5. BZOJ4514——[Sdoi2016]数字配对

    有 n 种数字,第 i 种数字是 ai.有 bi 个,权值是 ci. 若两个数字 ai.aj 满足,ai 是 aj 的倍数,且 ai/aj 是一个质数, 那么这两个数字可以配对,并获得 ci×cj 的 ...

  6. 搞明白这八个问题,Linux系统就好学多了

    导读 正在犹豫入坑Linux学习的同学或者已经入坑的同学,经常会问到这样八个问题.今天,这些问题我都会一一解答,希望我的看法能帮助各位同学.常言道“好的开始是成功的一半”,如果你明白了以下八个问题,就 ...

  7. phpstorm的调试工具xdebug

    1.需求 知道xdebug的使用方法 2.安装xdebug http://www.awaimai.com/1290.html 3.配置phpstorm http://www.awaimai.com/1 ...

  8. jquery常用

    获取元素宽度 .innerWidth() // 包含padding .outerWidth() // 包含padding, border .outerWidth(true)//包含padding, b ...

  9. Sqli-LABS通关笔录-16

    这个关卡之前我还使用了一下工具跑,发现居然跑不出来.这就尴尬了.行吧手工试试. payload admin") and If(ascii(substr(database(),1,1))=11 ...

  10. SQL 多表一起查询的语句总结

    sql 同时查询多个表 可以使用连表查询比如使用join sql 同时查询多个表 可以使用连表查询 比如 使用join select s1.*,s2.* from s1 left join s2 on ...