asp.net读注册表问题,高手过来看一下

executemylove 2007-04-06 01:48:12
VB.net的

Sub Readreg()
Dim reg As Microsoft.Win32.RegistryKey, subreg As Microsoft.Win32.RegistryKey
reg = Microsoft.Win32.Registry.CurrentUser
subreg = reg.OpenSubKey("Software\Eoffice\Run", True)
If Not subreg Is Nothing Then
If subreg.GetValue("No") <> "" Then
Dim str As Object = subreg.GetValue("No")
lblSimpleCode.Text = str.ToString()
Else
lblSimpleCode.Text = "empty"
End If
Else
lblSimpleCode.Text = "NO Key"
End If
End Sub

为什么subreg总是nothing??,我确定键值是一定存在的。
我用winform运行正确,请教各位。谢
...全文
255 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
executemylove 2007-04-06
  • 打赏
  • 举报
回复
我用模拟验证用户的方式:

Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity

currentWindowsIdentity = CType(User.Identity, System.Security.Principal.WindowsIdentity)
impersonationContext = currentWindowsIdentity.Impersonate()

'Insert your code that runs under the security context of the authenticating user here.

impersonationContext.Undo()
也不行啊。提示“匿名标识不能执行模拟。”
把匿名去掉后,集成windows身份验证还是不行。我已经疯了
executemylove 2007-04-06
  • 打赏
  • 举报
回复
传说中的高手在哪里?
ustbwuyi 2007-04-06
  • 打赏
  • 举报
回复
既然不是我说的错误,也只能帮顶了...
executemylove 2007-04-06
  • 打赏
  • 举报
回复
沉得好快呀...
up
executemylove 2007-04-06
  • 打赏
  • 举报
回复
怎么没人来看看。
现在问题是这样的:在vs.net中右键点击流畅可以读出这个值。而在iis虚拟目录中读不出来,这是为什么?
executemylove 2007-04-06
  • 打赏
  • 举报
回复
我试了在vs2005 里又可以读出来。在2003里却是“NO Key“,实在奇怪

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧