Results 1 to 13 of 13

Thread: Registry key code not working in Windows Vista...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Registry key code not working in Windows Vista...

    I have the following code in my application and the code works fine in Windows 2000, XP but for some reason does not work in Windows Vista, is someone able to help me with this?

    Code:
    dim myReg as string = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\MyCompany\MySoftware", "Path", Nothing)
    Thanks

    Simon

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Registry key code not working in Windows Vista...

    When you say it does not work what do you mean?

    Does it fail to run, does it run but return an error, or does it run but return something you weren't expecting.

    I'd imagine if it works differently on Vista to XP or 2000 its most likely something to do with security/permissions.

  3. #3
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Registry key code not working in Windows Vista...

    Hi,

    Here's an example how to use Registry keys with vista.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  4. #4
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Registry key code not working in Windows Vista...

    Quote Originally Posted by sparrow1 View Post
    Hi,

    Here's an example how to use Registry keys with vista.
    I'm confused - I don't see anything in the question about webforms and master pages

  5. #5
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Registry key code not working in Windows Vista...

    Hi,

    No, but I thould it could be very interesting because it says:

    This is a command-line tool that enables administrators to obtain security information about files, registry keys, and services, and transfer this information from user to user, from local or global group to group, and from domain to domain.
    Enables the Registry Keys.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Re: Registry key code not working in Windows Vista...

    The code in my first post returns Nothing

    I don't understand, are you telling me that no exe in windows Vista can access registry keys.... this does not seem sensible?

    I have tried running my app outside of Visual Studio and I get the same result

    Thanks

    Simon

  7. #7
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Registry key code not working in Windows Vista...

    No what I'm saying is that in Vista some parts of the registry and file system require elevated permissions, ie running as an administrator. I'm not saying this is definitely the problem but if it worked fine for XP and Windows 2000 its one of the first things to look at.

    Have you checked that the registry key exists using Regedit?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Re: Registry key code not working in Windows Vista...

    The regestry key does exist in regedit.

    I have checked the permissions of the registry key in regedit and the permissions have read access. I need the registry key to be able to read by all users as my app checks that another one of my apps exists so that it can be intergrated.

  9. #9
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Registry key code not working in Windows Vista...

    Not sure why it wouldn't work then if the key definitely exists.. I've just tried it on my machine with Nokia PCSuite :

    Code:
    Dim myReg As String = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Nokia\PCSuite", "Applicationpath1", Nothing)
    That works fine. Have you tried checking other keys in the same branch to see if they work?

  10. #10

    Re: Registry key code not working in Windows Vista...

    HKLM is an Administrator only branch I believe. Most registry access is limited for programs to HKLU (HKEY_LOCAL_USER). That would explain why you may not be able to access it in vista and 7, but in XP.

    EDIT: KP, you using Vista or 7?
    Last edited by formlesstree4; Feb 28th, 2010 at 12:48 PM. Reason: Added vista & 7 as the issue

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Registry key code not working in Windows Vista...

    Unless you have changed the permissions, HKLM can be read by anyone - but only written by an Administrator (or similar).

    It has definitely been that way in Windows 2000/XP/Vista/7.

    The only difference for Vista/7 is that if a non-Admin user writes to HKLM, it might be virutalised - it will be stored for that user only, so nobody else can read it.

  12. #12
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Registry key code not working in Windows Vista...

    EDIT: KP, you using Vista or 7?
    I'm using Vista.

    Permissions don't seem to be a problem - as si_the_geek says that branch look to be unrestricted for reading.

    If I was a gambling man I'd say the likelihood is a simple error in the path to the registry key - I'd double and triple check that the spelling is correct before going any further.

  13. #13

    Re: Registry key code not working in Windows Vista...

    I thought HKLM was restricted for admin only period...I stand corrected then.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width