| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1004 人关注过本帖
标题:[求助]求助VB修改注册表的问题
只看楼主 加入收藏
cqzxc
Rank: 2
等 级:论坛游民
帖 子:8
专家分:10
注 册:2006-11-13
收藏
 问题点数:0 回复次数:5 
[求助]求助VB修改注册表的问题

Private Sub Command1_Click()
'建立键值
CreateNewKey HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx"
CreateNewKey HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound"
'MySamples\Samples1下建立一个字符串值和一个整数值
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "AppID1", 101, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "AppID2", 102, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "AppID3", 103, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "AutoRefresh", 1, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Background", 1, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "BuddyIP", "127.0.0.1", REG_SZ
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "ChannelName", 0, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Effect3D", 2, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "EffectVolume", 95, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "GameName", 0, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "IP", "127.0.0.1", REG_SZ
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Language", 1, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "LastID", 0, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Location", fname & App.Path, REG_SZ
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "MidiMode", 1, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "MouseSpeed", 50, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "MusicVolume", 95, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "port", 8372, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Screen", fname & App.Path, REG_SZ
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "ShootingMode", 0, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Version", 312, REG_DWORD


End Sub

Private Sub Form_Load()
strPath = App.Path
Text1 = strPath
Dim fname As String
If Right(App.Path, 1) = "\" Then
fname = App.Path
Else
fname = App.Path & "\"
End If
'建立键值
CreateNewKey HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx"
CreateNewKey HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound"
'MySamples\Samples1下建立一个字符串值和一个整数值
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "AppID1", 101, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "AppID2", 102, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "AppID3", 103, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "AutoRefresh", 1, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Background", 1, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "BuddyIP", "127.0.0.1", REG_SZ
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "ChannelName", 0, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Effect3D", 2, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "EffectVolume", 95, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "GameName", 0, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "IP", "127.0.0.1", REG_SZ
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Language", 1, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "LastID", 0, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Location", Text1 & App.Path, REG_SZ
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "MidiMode", 1, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "MouseSpeed", 50, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "MusicVolume", 95, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "port", 8372, REG_DWORD
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "ShootingMode", 0, REG_BINARY
SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Version", 312, REG_DWORD
End Sub

Private Sub Label1_Click()

End Sub


谁能帮帮忙啊~~修改不注册表路径不支持中文啊~~~

文件路径如果是中文的话显示就不完全啊~~~

各位大哥大姐帮帮啊

SetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\SoftNyx\GunBound", "Location", Text1 & App.Path, REG_SZ
就是这一项是修改文件路径的~~~

我已经把源代码传上来了~~~

mEIffVQN.rar (7.29 KB) [求助]求助VB修改注册表的问题


搜索更多相关主题的帖子: 注册表 MACHINE SOFTWARE HKEY 
2006-11-13 08:52
flyly
Rank: 1
等 级:新手上路
帖 子:254
专家分:0
注 册:2006-11-13
收藏
得分:0 

简单!

4tWVEjTZ.rar (333.45 KB)

[此贴子已经被作者于2006-11-13 9:23:09编辑过]


2006-11-13 09:17
cqzxc
Rank: 2
等 级:论坛游民
帖 子:8
专家分:10
注 册:2006-11-13
收藏
得分:0 
哈哈谢谢
2006-11-13 09:24
cqzxc
Rank: 2
等 级:论坛游民
帖 子:8
专家分:10
注 册:2006-11-13
收藏
得分:0 
晕死啊~~~不是VB的~~你能不能搞个VB的啊
2006-11-13 09:25
flyly
Rank: 1
等 级:新手上路
帖 子:254
专家分:0
注 册:2006-11-13
收藏
得分:0 
不好意思,发错了

Public Declare Function RegCloseKey Lib \"advapi32.dll\" (ByVal Hkey As Long) As Long
Public Declare Function RegCreateKey Lib \"advapi32.dll\" Alias \"RegCreateKeyA\" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public 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
Public Const REG_SZ = 1
Public Const REG_DWORD = 4
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const ERROR_SUCCESS = 0&




然后写个函数
[code]
Public Sub savestring(Hkey As Long, strPath As String, strValue As String, strdata As String)

Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hkey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
r = RegCloseKey(keyhand)
End Sub
[/code]
有问题找我 xx5865@163.com

[此贴子已经被作者于2006-11-13 10:42:00编辑过]


2006-11-13 10:41
cqzxc
Rank: 2
等 级:论坛游民
帖 子:8
专家分:10
注 册:2006-11-13
收藏
得分:0 

兄弟能否给我一个完整的代码呢~~~~

2006-11-13 20:53
快速回复:[求助]求助VB修改注册表的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035870 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved