Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

VB Registry Access Question!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DEWright_CA@online.nospam - 24 Aug 2005 20:52 GMT
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!
Signature

D @ premierdata

"Peter Huang" [MSFT] - 25 Aug 2005 09:45 GMT
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

Signature

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


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.