| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 879 人关注过本帖
标题:[求助]请教!VB.NET CE环境中注册表读写问题
只看楼主 加入收藏
美妙人生
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-5-10
收藏
 问题点数:0 回复次数:4 
[求助]请教!VB.NET CE环境中注册表读写问题

提示出错,好像这个语法不能使用的,哪位能提供一个完整的注册表读写代码?

win32编写环境下代码正常,但是到sp手机程序环境里无法使用!使用的代码是msdn上提供的注册表读写代码


搜索更多相关主题的帖子: 注册表 NET 手机 环境 
2007-05-10 09:17
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
你的代码呢?

飘过~~
2007-05-10 09:31
美妙人生
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-5-10
收藏
得分:0 

Imports Microsoft.VisualBasic
Imports System
Imports System.Security.Permissions
Imports Microsoft.Win32

'<Assembly: RegistryPermissionAttribute( _
SecurityAction.RequestMinimum, ViewAndModify := "HKEY_CURRENT_USER")>

Public Class RegKey
Shared Sub Main()
Dim rk As RegistryKey = Registry.Users

' Create a subkey named Test9999 under HKEY_CURRENT_USER.
Dim test9999 As RegistryKey = _
rk.CurrentUser.CreateSubKey("Test9999")

' Create two subkeys under HKEY_CURRENT_USER\Test9999.
test9999.CreateSubKey("TestName").Close()
Dim testSettings As RegistryKey = _
test9999.CreateSubKey("TestSettings")

' Create data for the TestSettings subkey.
testSettings.SetValue("Language", "French")
testSettings.SetValue("Level", "Intermediate")
testSettings.SetValue("ID", 123)
testSettings.Close()

' Print the information from the Test9999 subkey.
Console.WriteLine("There are {0} subkeys under Test9999.", _
test9999.SubKeyCount.ToString())
For Each subKeyName As String In test9999.GetSubKeyNames()
Dim tempKey As RegistryKey = _
test9999.OpenSubKey(subKeyName)
Console.WriteLine(vbCrLf & "There are {0} values for " & _
"{1}.", tempKey.ValueCount.ToString(), tempKey.Name)
For Each valueName As String In tempKey.GetValueNames()
Console.WriteLine("{0,-8}: {1}", valueName, _
tempKey.GetValue(valueName).ToString())
Next
Next

' Delete the ID value.
testSettings = test9999.OpenSubKey("TestSettings", True)
testSettings.DeleteValue("id")

' Verify the deletion.
Console.WriteLine(CType(testSettings.GetValue( _
"id", "ID not found."), String))
testSettings.Close()

' Delete or close the new subkey.
Console.Write(vbCrLf & "Delete newly created " & _
"registry key? (Y/N) ")
If Char.ToUpper(Convert.ToChar(Console.Read())) = "Y"C Then
Registry.CurrentUser.DeleteSubKeyTree("Test9999")
Console.WriteLine(vbCrLf & "Registry key {0} deleted.", _
test9999.Name)
Else
Console.WriteLine(vbCrLf & "Registry key {0} closed.", _
test9999.ToString())
test9999.Close()
End If

End Sub
End Class

2007-05-10 09:59
Kendy123456
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:62
帖 子:2720
专家分:0
注 册:2007-1-3
收藏
得分:0 

Dim rk As RegistryKey = Registry.CurrentUser

' Create a subkey named Test9999 under HKEY_CURRENT_USER.
Dim test9999 As RegistryKey = rk.CreateSubKey("Test9999")

这样就不会编译报错了 RegistryKey并没有CurrentUser这个属性


2007-05-10 10:41
美妙人生
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-5-10
收藏
得分:0 

嗯,好的,先谢谢了!不懂再请教!

[此贴子已经被作者于2007-5-10 12:22:20编辑过]

2007-05-10 12:21
快速回复:[求助]请教!VB.NET CE环境中注册表读写问题
数据加载中...
 
   



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

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