改变 HKEY_CLASSES_ROOT下的 * 这个子项的值 的问题。困惑!!请高手相助!!在线等待

yunxp 2003-05-10 01:39:33
我想改变 HKEY_CLASSES_ROOT下的 * 这个子项的值,系统默认的值为 (未设键值),我用
Call RegSetValueEx(hKey, "(默认)", 0, REG_SZ, ByVal "abcd", 26) 后,发现在*的子项下 又建立了一个名称为 (默认) 值为abcd的值. 请问如何改变或者删除这个系统自动建立的"(默认)"值?? (注:'RegDeleteValue hKey, "(默认)" 也是不行的。只能删除自己建立的值。却不能删除系统建立的。 但我在注册表中手工删除 系统建立的那个"(默认)" ,却可以删除。为什么呢?)
...全文
103 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
yunok 2003-05-10
还有没有人帮助我??
回复
yunok 2003-05-10
To sxs69() ( ) :
你说的方法我试过了.不能删除系统建立的默认值.不信你自己试试
回复
yunok 2003-05-10
好.我先看一下.终于有人回答了!!万分感谢.fishzone(阿愚-本ID已经消毒)
回复
sxs69 2003-05-10
RegDeleteValue hKey, "" ' 删除"默认值"
回复
fishzone 2003-05-10
'这里有一个例子你可以参照一下。
'它可以改变文件的打开方式,也就是你说的“默认”那个值

'打开文件关联的例子

Const ERROR_SUCCESS = 0&
Const REG_SZ = 1
Const HKEY_CLASSES_ROOT = &H80000000
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpszValueName As String, ByVal dwReserved As Long, lpdwType As Long, lpbData As Any, cbData As Long) As Long
Declare Function RegOpenKey Lib "advapi32" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpszSubKey As String, phkResult 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 ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long

Public Function RegSetStringValue(ByVal hKey As Long, ByVal strValueName As String, _
ByVal strData As String, Optional ByVal fLog) As Boolean
Dim lResult As Long
On Error GoTo 0
lResult = RegSetValueEx(hKey, strValueName, 0&, REG_SZ, ByVal strData, _
LenB(StrConv(strData, vbFromUnicode)) + 1)
If lResult = 0 Then
RegSetStringValue = True
Else
RegSetStringValue = False
End If
End Function

Public Function StripTerminator(ByVal strString As String) As String
Dim intZeroPos As Integer
intZeroPos = InStr(strString, Chr$(0))
If intZeroPos > 0 Then
StripTerminator = Left$(strString, intZeroPos - 1)
Else
StripTerminator = strString
End If
End Function

Public Sub SetFileType(ByVal strFileType As String, ExePathFile As String)
Dim Length As Integer

Dim KeyId As Long
Call RegCreateKey(HKEY_CLASSES_ROOT, "." & strFileType, KeyId)
Call RegSetValueEx(KeyId, "", 0&, REG_SZ, ByVal strFileType & "file", Len(strFileType & "file") + 1)
Dim KeyId1 As Long
Call RegCreateKey(HKEY_CLASSES_ROOT, strFileType & "file", KeyId1)
Call RegSetValueEx(KeyId1, "", 0&, REG_SZ, ByVal strFileType & "类型", LenB(strFileType & "类型") + 1)
Dim KeyId2 As Long
Call RegCreateKey(KeyId1, "DefaultIcon", KeyId2)
Call RegSetValueEx(KeyId2, "", 0&, REG_SZ, ByVal ExePathFile & ",0", Len(ExePathFile & ",0") + 1)
Dim KeyId3 As Long
Call RegCreateKey(KeyId1, "Shell", KeyId3)
Dim KeyId4 As Long
Call RegCreateKey(KeyId3, "Open", KeyId4)
Dim KeyId5 As Long
Call RegCreateKey(KeyId4, "command", KeyId5)
Call RegSetValueEx(KeyId5, "", 0&, REG_SZ, ByVal ExePathFile & " %1", Len(ExePathFile & " %1") + 1)
'MsgBox "创建自定义类型后缀名成功。", vbInformation, "系统提示"
End Sub

用法:
Call SetFileType("csp", strEXEPathFile)
“csp”是文件后缀名。
strEXEPathFile 是打开这个后缀名的 Exe 文件完整路径。
回复
yunpp 2003-05-10
晕死啊!!!
回复
yunpp 2003-05-10
晕~
回复
yunpp 2003-05-10
帮帮我啊!!高手呢?
回复
yunxp 2003-05-10
这个问题很很难吗???
回复
yunxp 2003-05-10
怎么没有人理我??
回复
yunxp 2003-05-10
没人理我??
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7492

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2003-05-10 01:39
社区公告
暂无公告