将一个字符串写入注册表,怎末办,写在注册表何处合适?

run2028 2003-05-08 09:56:40
将一个字符串写入注册表,怎末办,写在注册表何处合适?怎样读出?给点源码了
...全文
8 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lfshf 2003-05-09
如果不是考虑加密,用2楼的方法
回复
run2028 2003-05-09
SaveSetting appname, section, key, setting语句总是写到"HKEY_CURRENT_USER\Software\VB and VBA Program Settings"目录下,怎样可以改变位置?
例如写到"HKEY_CURRENT_USER\Software"目录下
回复
hanzye 2003-05-09
RegSetValueEx(): 在打开的注册表关键字的值域中存储数据;

RegCloseKey(): 释放指定的关键字的句柄;

RegQueryValueEx(): 在注册表中查找与您指定的键值相关的值;

RegCreateKeyEx(): 建立并打开指定的关键字,若已存在则打开它;

RegEnumKeyEx(): 枚举指定的注册表关键字的子关键字(32位);

RegEnumValue(): 每次调用枚举指定的注册表关键字的值,复制一个带索引的值的名称和数据块;

RegDeletekey(): 删除一个关键字以及它的子关键字;

RegDeleteValue(): 在指定的注册表关键字中删除一个带名字的值。

用这几个api,想放哪,就放哪.
回复
hanzye 2003-05-08
http://www.gbnis.com/read_file.asp?type_id=&id=3654&left=
http://www.gbnis.com/read_file.asp?type_id=&id=2342&left=
这两篇文章几乎阐述了VB操作注册表的所有方法,不凡一看
至于你要把字符放哪里那是你的权力。如果是要做什么“隐蔽”的事,当然是把它混在系统的一些键中不易为人发现。
回复
seemknow 2003-05-08
最简单的程序:
Private Sub MDIForm_Load()
Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 500)
Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 1000)
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings", "MainLeft", Me.Left
SaveSetting App.Title, "Settings", "MainTop", Me.Top
SaveSetting App.Title, "Settings", "MainWidth", Me.Width
SaveSetting App.Title, "Settings", "MainHeight", Me.Height
End If
For i = Forms.Count - 1 To 1 Step -1
Unload Forms(i)
Next
End Sub

我的APP.Title=SerialDataTrans,写完注册表是
[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\SerialDataTrans\Settings]
"MainLeft"="1095"
"MainTop"="885"
"MainWidth"="8655"
"MainHeight"="7965"

回复
Sean918 2003-05-08
写在哪随你,只要是不会引起错误的地方就行

你搜索一下 "注册表",会有大把的帖子给你看
回复
rainstormmaster 2003-05-08
RegQueryValueEx读,RegSetValueEx写。或用vb自带的函数SaveSetting和GetSetting。
Private Sub Form_Load()
Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings", "MainLeft", Me.Left
SaveSetting App.Title, "Settings", "MainTop", Me.Top
SaveSetting App.Title, "Settings", "MainWidth", Me.Width
SaveSetting App.Title, "Settings", "MainHeight", Me.Height
End If
SaveSetting App.Title, "Settings", "ViewMode", lvListView.View
End Sub
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7490

社区成员

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