''' <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. CentOS 6.5 3.0.4安装agentd

    更改主机名为test3 [root@localhost ~]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=test3 关闭selinux [ ...

  2. hexo问题篇(偶尔抽抽疯)

    hexo安安稳稳的跑了很久,然后 ....让人心碎的hexo问题,华丽丽的摔倒在坑里,只因update了hexo version最是哪一句 hexo server让人欲哭无泪 -问题场景 设备: Ma ...

  3. 为在韶大痛苦而不能用手机、Pad等上网的同志造福!

    目标:共享咱们校园网,让更多的人或更多的设备冲浪去! 基本条件:一台带无线功能的笔记本,一个可以上网的账号与pwd,最好为Windows7以上的操作系统,如果是XP,则需要打个.net framewo ...

  4. Unity手游之路<八>自动寻路Navmesh之入门

    http://blog.csdn.net/janeky/article/details/17457533 在的大部分mmo游戏都有了自动寻路功能.点击场景上的一个位置,角色就会自动寻路过去.中间可能会 ...

  5. << CocoaPods安装和使用教程 >>github code4app以及cocoachina 苹果官方文档

    developer.apple.com 英文搜索各个技术的官方介绍文档, 前提是英文过关 cocoachina ios最新新闻, 信息 code4app上有许多组件 http://www.code4a ...

  6. 使用 Intel HAXM 为 Android 模拟器加速,媲美真机

    http://www.cnblogs.com/beginor/archive/2013/01/13/2858228.html

  7. 27 GroupSock概述(一)——live555源码阅读(四)网络

    27 GroupSock概述(一)——live555源码阅读(四)网络 27 GroupSock概述(一)——live555源码阅读(四)网络 简介 1.网络通用数据类型定义 2.Tunnel隧道封装 ...

  8. 26 BasicUsageEnvironment基本使用环境——Live555源码阅读(三)UsageEnvironment

    26 BasicUsageEnvironment基本使用环境--Live555源码阅读(三)UsageEnvironment 26 BasicUsageEnvironment基本使用环境--Live5 ...

  9. 大数据热点问题TOP K

    1单节点上的topK (1)批量数据 数据结构:HashMap, PriorityQueue 步骤:(1)数据预处理:遍历整个数据集,hash表记录词频 (2)构建最小堆:最小堆只存k个数据. 时间复 ...

  10. ndk学习11: linux内存管理

        1. 进程地址空间   2.内存管理     栈上分配空间 alloca()       栈上分配大小 strdupa()    拷贝一个字符串到栈上(显然这个函数不安全)           ...