免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

vb.net刪除注冊表,vb注冊表清理

刪除注冊表項里的所有鍵值(除了指定一個)外,怎么寫?易語言編程

建議你使用VB.NET(VS2005+版本),操作注冊表非常容易: For Each name As String In My.Computer.Registry.LocalMachine.OpenSubKey("software\microsoft\windows\currentversion\run").GetValueNames

十載的洪洞網站建設經驗,針對設計、前端、開發、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都全網營銷推廣的優勢是能夠根據用戶設備顯示端的尺寸不同,自動調整洪洞建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優雅布局與設計,從而大程度地提升瀏覽體驗。成都創新互聯從事“洪洞網站設計”,“洪洞網站推廣”以來,每個客戶項目都認真落實執行。

If (name "1425") Then

My.Computer.Registry.LocalMachine.OpenSubKey("software\microsoft\windows\currentversion\run").DeleteValue(name)

End If

Next

VB.net注冊表操作問題

最簡單的辦法就是用shell

語句

添加和創建注冊表項

shell

"cmd

/c

reg

add

hklm\software\myco

/v

data

/t

reg_binary

/d

fe340ead"

刪除注冊表項

shell

"cmd

/c

reg

delete

hklm\software\myco\myapp\timeout"

刪除注冊表項

timeout

及其所有子項和值

具體語法請在cmd中輸入

reg/?

VB.NET如何刪除注冊表

請使用VB.NET的“My”功能: '添加

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue("running", "C:\myapp.exe") ' 刪除

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue("running")

vb.net 注冊表刪除操作 郁悶中……

這不是廢話嗎,DeleteSubKey只能刪除調用實例的子項,并不能直接刪除子子項。

vb 對注冊表的操作,詳細解說

赫赫,拿來主義

將下面代碼保存為CLS文件 ,然后在工程中引用就可以了。

Attribute VB_Name = "BasRegisty"

Option Explicit

'讀寫注冊表任何地方的函數

' 用法見下面

' 摘自楊光宏 (VB技巧手冊)

'用于操作注冊表的API函數定義 -begin-

Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long

Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long

Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long

Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long

Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long

Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long

Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long

Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long

'用于操作注冊表的API函數定義 -end-

'用于操作注冊表的常數定義 -begin-

'預定義的根結點

Public Const HKEY_CLASSES_ROOT = H80000000

Public Const HKEY_CURRENT_CONFIG = H80000005

Public Const HKEY_CURRENT_USER = H80000001

Public Const HKEY_DYN_DATA = H80000006

Public Const HKEY_LOCAL_MACHINE = H80000002

Public Const HKEY_PERFORMANCE_DATA = H80000004

Public Const HKEY_USERS = H80000003

'預定義的鍵值類型

Public Const REG_NONE = 0

Public Const REG_SZ = 1

Public Const REG_EXPAND_SZ = 2

Public Const REG_BINARY = 3

Public Const REG_DWORD = 4

Public Const REG_DWORD_LITTLE_ENDIAN = 4

Public Const REG_DWORD_BIG_ENDIAN = 5

Public Const REG_LINK = 6

Public Const REG_MULTI_SZ = 7

Public Const REG_RESOURCE_LIST = 8

Public Const REG_FULL_RESOURCE_DESCRIPTOR = 9

Public Const REG_RESOURCE_REQUIREMENTS_LIST = 10

#If WinNT Then

'打開注冊文件的方式

Public Const KEY_EVENT = H1

Public Const KEY_NOTIFY = H10

Public Const KEY_QUERY_VALUE = H1

Public Const KEY_SET_VALUE = H2

Public Const KEY_CREATE_SUB_KEY = H4

Public Const KEY_ENUMERATE_SUB_KEYS = H8

Public Const KEY_CREATE_LINK = H20

Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))

Public Const KEY_EXECUTE = (KEY_READ)

Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))

Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))

#End If

'注冊文件錯誤描述

Const ERROR_SUCCESS = 0

Const ERROR_BADDB = 1009

Const ERROR_BADKEY = 1010

Const ERROR_CANTOPEN = 1011

Const ERROR_CANTREAD = 1012

Const ERROR_CANTWRITE = 1013

Const ERROR_REGISTRY_RECOVERED = 1014

Const ERROR_REGISTRY_CORRUPT = 1015

Const ERROR_REGISTRY_IO_FAILED = 1016

Const ERROR_NOT_REGISTRY_FILE = 1017

Const ERROR_KEY_DELETED = 1018

Const ERROR_NO_LOG_SPACE = 1019

Const ERROR_KEY_HAS_CHILDREN = 1020

Const ERROR_CHILD_MUST_BE_VOLATILE = 1021

Const ERROR_RXACT_INVALID_STATE = 1369

' 自定義注冊文件錯誤

Const REGAGENT_NOKEY = -1002

Const REGAGENT_NOSUBKEY = -1003

Public glStatus As Long

'用于操作注冊表的常數定義 -end-

Function gfsGetKeyStringValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String) As String

'功 能:從注冊表中取得串值

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' psSubKey String 子鍵名

' 輸出: gfsGetKeyStringValue String 取得的注冊表串值

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '打開鍵的ID

Dim llBufferSize As Long '需讀取串的串值長度

Dim lsKeyValue As String '存放讀取的串值

'預先置為空

gfsGetKeyStringValue = Empty

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置(子鍵未設置則讀默認值)

glStatus = REGAGENT_NOKEY

Exit Function

End If

'首先打開主鍵

glStatus = RegOpenKey(plKey, psKey, llKeyID)

If glStatus = ERROR_SUCCESS Then '成功則取需讀取字串的串值大小

glStatus = RegQueryValueEx(llKeyID, psSubKey, 0, REG_SZ, 0, llBufferSize)

If llBufferSize 2 Then '空值

glStatus = RegCloseKey(llKeyID)

Else '有值,正式讀取串值

lsKeyValue = String(llBufferSize + 1, " ")

glStatus = RegQueryValueEx(llKeyID, psSubKey, 0, REG_SZ, ByVal lsKeyValue, llBufferSize)

If glStatus = ERROR_SUCCESS Then

gfsGetKeyStringValue = Left$(lsKeyValue, llBufferSize - 1)

End If

glStatus = RegCloseKey(llKeyID)

End If

End If

End Function

Function gflGetKeyBinaryValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String) As Long

'功 能:從注冊表中取得二進制值

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' psSubKey String 子鍵名

' 輸出: gflGetKeyBinaryValue Long 取得的注冊表二進制值

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '打開鍵的ID

Dim llKeyValue As Long '存放讀取的二進制值

'預先置為空

gflGetKeyBinaryValue = Empty

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置(子鍵未設置則讀默認值)

glStatus = REGAGENT_NOKEY

Exit Function

End If

'首先打開主鍵

glStatus = RegOpenKey(plKey, psKey, llKeyID)

If glStatus = ERROR_SUCCESS Then '成功則取二進制值

glStatus = RegQueryValueEx(llKeyID, psSubKey, 0, REG_BINARY, llKeyValue, Len(llKeyValue))

If glStatus = ERROR_SUCCESS Then

gflGetKeyBinaryValue = llKeyValue

End If

glStatus = RegCloseKey(llKeyID)

End If

End Function

Function gflGetKeyDwordValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String) As Long

'ok

'功 能:從注冊表中取得雙字值

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' psSubKey String 子鍵名

' 輸出: gflGetKeyDwordValue Long 取得的注冊表雙字值

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '打開鍵的ID

Dim llKeyValue As Long '存放讀取的雙字值

'預先置為空

gflGetKeyDwordValue = Empty

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置(子鍵未設置則讀默認值)

glStatus = REGAGENT_NOKEY

Exit Function

End If

'首先打開主鍵

glStatus = RegOpenKey(plKey, psKey, llKeyID)

If glStatus = ERROR_SUCCESS Then '成功則取雙字值

glStatus = RegQueryValueEx(llKeyID, psSubKey, 0, REG_DWORD, llKeyValue, Len(llKeyValue))

If glStatus = ERROR_SUCCESS Then

gflGetKeyDwordValue = llKeyValue

End If

glStatus = RegCloseKey(llKeyID)

End If

End Function

Sub gpvSetKeyStringValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String, ByVal psKeyValue As String)

'ok

'功 能:設置注冊表中的串值

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' psSubKey String 子鍵名

' psKeyValue String 要設置的串值

' 輸出: 無

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '打開鍵的ID

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置(子鍵未設置則讀默認值)

glStatus = REGAGENT_NOKEY

Exit Sub

End If

'首先打開主鍵

glStatus = RegOpenKey(plKey, psKey, llKeyID)

If glStatus = ERROR_SUCCESS Then '成功則設置值

If Len(psKeyValue) = 0 Then '設為空值

glStatus = RegSetValueEx(llKeyID, psSubKey, 0, REG_SZ, 0, 0)

Else '設為正常值

glStatus = RegSetValueEx(llKeyID, psSubKey, 0, REG_SZ, ByVal psKeyValue, Len(psKeyValue) + 1)

End If

glStatus = RegCloseKey(llKeyID)

End If

End Sub

Sub gpvSetKeyDwordValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String, ByVal plKeyValue As Long)

'ok

'功 能:設置注冊表中的雙字值

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' psSubKey String 子鍵名

' plKeyValue Long 要設置雙字值

' 輸出: 無

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '打開鍵的ID

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置(子鍵未設置則讀默認值)

glStatus = REGAGENT_NOKEY

Exit Sub

End If

'首先打開主鍵

glStatus = RegOpenKey(plKey, psKey, llKeyID)

If glStatus = ERROR_SUCCESS Then '成功則設置值

glStatus = RegSetValueEx(llKeyID, psSubKey, 0, REG_DWORD, plKeyValue, Len(plKeyValue))

glStatus = RegCloseKey(llKeyID)

End If

End Sub

Sub gpvSetKeyBinaryValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String, ByVal plKeyValue As Long)

'ok

'功 能:設置注冊表中的二進制值

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' psSubKey String 子鍵名

' plKeyValue Long 要設置的二進制值

' 輸出: 無

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '打開鍵的ID

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置(子鍵未設置則讀默認值)

glStatus = REGAGENT_NOKEY

Exit Sub

End If

'首先打開主鍵

glStatus = RegOpenKey(plKey, psKey, llKeyID)

If glStatus = ERROR_SUCCESS Then '成功則設置值

glStatus = RegSetValueEx(llKeyID, psSubKey, 0, REG_BINARY, plKeyValue, Len(plKeyValue))

glStatus = RegCloseKey(llKeyID)

End If

End Sub

Function gflCreateKey(ByVal plKey As Long, ByVal psKey As String) As Long

'ok

'功 能:創建注冊表中的主鍵

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' 輸出: gflCreateKey Long 創建的主鍵ID

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '鍵ID

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置

glStatus = REGAGENT_NOKEY

Exit Function

End If

'創建主鍵

glStatus = RegCreateKey(plKey, psKey, llKeyID)

If glStatus = ERROR_SUCCESS Then

gflCreateKey = llKeyID

End If

End Function

Sub gpvDeleteKey(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String)

'ok

'功 能:刪除注冊表中的主鍵

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' psSubKey String 子鍵名

' 輸出: 無

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '鍵ID

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置

glStatus = REGAGENT_NOKEY

Exit Sub

End If

'利用創建主鍵判斷是否存在主鍵

glStatus = RegCreateKey(plKey, psKey, llKeyID)

glStatus = RegDeleteKey(llKeyID, ByVal psSubKey)

End Sub

Sub gpvDeleteKeyValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String)

'ok

'功 能:刪除注冊表中的鍵值

'參 數:

' 輸入: plKey Long 根鍵名

' psKey String 主鍵名

' psSubKey String 子鍵名

' 輸出: 無

' 影響: glStatus Long 狀態值

Dim llKeyID As Long '鍵ID

glStatus = ERROR_SUCCESS '假設成功

'確定參數有效

If Len(psKey) = 0 Then '主鍵未設置

glStatus = REGAGENT_NOKEY

Exit Sub

End If

'利用創建主鍵判斷是否存在主鍵

glStatus = RegCreateKey(plKey, psKey, llKeyID)

glStatus = RegDeleteValue(llKeyID, ByVal psSubKey)

End Sub

'Function gfsGetKeyStringValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String) As String

'功 能:從注冊表中取得串值

'Function gflGetKeyBinaryValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String) As Long

'功 能:從注冊表中取得二進制值

'Function gflGetKeyDwordValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String) As Long

'功 能:從注冊表中取得雙字值

'Sub gpvSetKeyStringValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String, ByVal psKeyValue As String)

'功 能:設置注冊表中的串值

'Sub gpvSetKeyDwordValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String, ByVal plKeyValue As Long)

'功 能:設置注冊表中的雙字值

'Sub gpvSetKeyBinaryValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String, ByVal plKeyValue As Long)

'功 能:設置注冊表中的二進制值

'Function gflCreateKey(ByVal plKey As Long, ByVal psKey As String) As Long

'功 能:創建注冊表中的主鍵

'Sub gpvDeleteKey(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String)

'功 能:刪除注冊表中的主鍵

'Sub gpvDeleteKeyValue(ByVal plKey As Long, ByVal psKey As String, ByVal psSubKey As String)

'功 能:刪除注冊表中的鍵值

網頁名稱:vb.net刪除注冊表,vb注冊表清理
文章出自:http://m.newbst.com/article8/hsepop.html

成都網站建設公司_創新互聯,為您提供電子商務網站設計網站排名營銷型網站建設App開發ChatGPT

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都seo排名網站優化