VB Registry Access Question!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am putting together a app that on startup needs to check if a registry key
exists, if not it will popup one window and if it does popup another. I have
the framework for this functioning fine on my dev machine, but when I try to
run it I get a couple of errors related to Registry Permissions.

I have searched around for tips on ways to do this but only find parts
spread all over the place, and none of them seem to plug in well together.

Does anyone have a suggestion as to how it might be better to handle this?

Here is what I am doing!

<!--Code
<Assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum,
All:="HKEY_CURRENT_USER\SOFTWARE\Premier Data Services")>

Public Class frm_Main
Inherits System.Windows.Forms.Form

Public Shared Sub Main()

Dim keyLocale As String
keyLocale = "SOFTWARE\Premier Data Services\NEPA Tracking"

Dim pdsAppKey As Microsoft.Win32.RegistryKey
pdsAppKey = Registry.CurrentUser.OpenSubKey(keyLocale, False)

If pdsAppKey Is Nothing Then
Application.Run(New frm_NewUser)
Else
Application.Run(New frm_Main)
End If

End Sub

EndCode -->

Thanks!
 
Hi

I think we need to collection some information first.
1. What is the exact error message you encounter and which code line throw
the exception?
2. Did the problem persists with all the application, you may try the
sample below.
RegistryKey.OpenSubKey Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfmicrosoftwin32registrykeyclassopensubkeytopic.asp
3. Have you tried to use an administrator account to see if that works for
you?

Also you may try to run the application with administrator right and run
locally to see if that works for you.

You may try to the tool regmon to see what has happened when security error
occur.
Regmon for Windows NT/9x
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfmicrosoftwin32registrykeyclassopensubkeytopic.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top