Results 1 to 30 of 30

Thread: [RESOLVED] Registry Read Problems Confound Me

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Resolved [RESOLVED] Registry Read Problems Confound Me

    Hello, Good Day to All

    I would like some help with this, i'm creating a custom app for myself but i'm doing so as if it were to be used by others. This is just for the knowledge since i'm very interested in software development.

    I've spent 3 days trying to get this done on my own and with the help of Google, I've learned some things but none of which seem to be helping and thus i'm confused. I'm trying to read the registry for the current version of Microsoft Access installed on the Machine. The code I've been using lets me know that the registry key does exist but for some reason i can't get the value, it just shows as blank in the messagebox.

    MessageBox.Show(My.Computer.Registry.ClassesRoot.OpenSubKey("Access.Application\CurVer", False).ToString)

    MessageBox.Show(My.Computer.Registry.ClassesRoot.GetValue("Access.Application\CurVer"))

    The version of Access (2007) i have is 32bit, and i'm running windows 8.1 Pro 64bit. I've tried compiling the app for any cpu/32bit/64bit (Read about the registry redirects) and i always get a blank messagebox.

    I'm hoping more experienced people can give me a hand, thanks if you can.
    Last edited by WestFiasco; Jul 8th, 2014 at 02:25 PM.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    try this:

    Code:
    Imports Microsoft.Win32
    
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim key As RegistryKey = My.Computer.Registry.ClassesRoot.OpenSubKey("Access.Application\CurVer", False)
            MessageBox.Show(key.GetValue("").ToString)
        End Sub
    
    End Class

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    Thanks for the quick reply, when i compile it i get an Unhandled exception message. I don't know how to handle those in Vb.net


    An unhandled exception of type 'System.NullReferenceException' occurred in Media.exe

    Additional information: Object reference not set to an instance of an object.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    Dim key As RegistryKey = My.Computer.Registry.ClassesRoot.OpenSubKey("Access.Application\CurVer", False)

    are you sure Registry.ClassesRoot contains "Access.Application\CurVer"
    can you post your code?

    I tested it before posting and it works on my system...

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    also I need to know which line causes the error

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    If you run it it'll break and highlight the line which halted execution.
    If you can't run it, you'll have an error listed below the app in the IDE, which if you doubleclick it, will take you to the code causing the exception

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    I did it the same as yours (Imported win32)

    Dim key As RegistryKey = My.Computer.Registry.ClassesRoot.OpenSubKey("Access.Aplication\CurVer, False")

    MessageBox.Show(key.GetValue("").ToString)

    I have the registry editor open now and it is there, and the key.GetValue line is the one that throws the exception. I'm so confused as to why it doesn't work.

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    does the CurVer key look anything like this:

    Name:  regedit.png
Views: 436
Size:  2.3 KB

    ?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    The exact same, i'm wondering about my software if that's the issue. i think i've been doing upgrades when i move to a new OS. i don't know if something has been mucked up along the way.

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    I'm not sure. I can't test it in win 8.1
    Maybe someone else can try it for you...

  11. #11

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    hopefully, Thanks for trying

  12. #12
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Registry Read Problems Confound Me

    There is no default value in 8.1
    My Github - 1d3nt

  13. #13
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by ident View Post
    There is no default value in 8.1
    how do you explain posts #8 and #9?

  14. #14

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    There is no default value in 8.1
    Can you elaborate please?

  15. #15

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by .paul. View Post
    how do you explain posts #8 and #9?
    Yes, i'm wondering that myself

  16. #16
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Registry Read Problems Confound Me

    I'm not sure. I can't test it in win 8.1

    Because your not on 8.1 and i'm looking at regedit right now on 8.1
    My Github - 1d3nt

  17. #17
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Registry Read Problems Confound Me

    My Github - 1d3nt

  18. #18
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    I had a look in 8.1
    I don't have Office installed, but it looks like ident has the wrong subkey there, unless the subkeys have a different structure in 8.1

  19. #19

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    Name:  Screenshot (56).jpg
Views: 396
Size:  40.7 KB
    Quote Originally Posted by ident View Post
    I'm not sure. I can't test it in win 8.1

    Because your not on 8.1 and i'm looking at regedit right now on 8.1
    I think you have a different version of Access and you're in the wrong place, thanks for trying anyway
    Last edited by WestFiasco; Jul 8th, 2014 at 04:59 PM.

  20. #20
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Registry Read Problems Confound Me

    2013 here, no such key exists. I guess i can't help.
    My Github - 1d3nt

  21. #21

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by ident View Post
    2013 here, no such key exists. I guess i can't help.
    Still, thanks for your efforts

  22. #22
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Registry Read Problems Confound Me

    Just tried this on Win8.1.

    Paul's code from #2 works fine.

    WestFiasco's code from #7 does give a NullReference Exception.

    The second quotation mark is in the wrong place in the call to the OpenSubKey Method.

  23. #23
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by Inferrd View Post
    Just tried this on Win8.1.

    Paul's code from #2 works fine.

    WestFiasco's code from #7 does give a NullReference Exception.

    The second quotation mark is in the wrong place in the call to the OpenSubKey Method.
    well spotted

  24. #24

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by Inferrd View Post
    Just tried this on Win8.1.

    Paul's code from #2 works fine.

    WestFiasco's code from #7 does give a NullReference Exception.

    The second quotation mark is in the wrong place in the call to the OpenSubKey Method.
    Wow, thanks so much for that. i managed to get two people on windows 8.1 and 7 to run the exe for me, which showed me that my machine is fine and there's a problem with my code. After fixing what you noticed and still got the thrown exception, i also saw that i have a missing p in Application lol, i'm indeed ashamed.

  25. #25

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    21

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by .paul. View Post
    well spotted
    Eh, sorry about that .paul. i don't know how i managed to do that. Thanks for your help, works well.

  26. #26
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by Inferrd View Post
    Just tried this on Win8.1.

    Paul's code from #2 works fine.

    WestFiasco's code from #7 does give a NullReference Exception.

    The second quotation mark is in the wrong place in the call to the OpenSubKey Method.
    But not with office 2013 still.
    My Github - 1d3nt

  27. #27
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by ident View Post
    But not with office 2013 still.
    No, and there should be some consistency there. There might be another key that is consistent on different operating systems with any version of Office

  28. #28
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Registry Read Problems Confound Me

    Quote Originally Posted by ident View Post
    But not with office 2013 still.
    Don't know. I had Office 2013 installed on my Win8.1, but installed office 2007 to test, and I didn't check for the CurVer Key before installing 2007. It was definitely there after installing Office 2007, but gave version 12, not 15.

    On my Win7 machine, I only have Office 2013 installed, and that also has the CurVer Key. Version 15.

    I'll go with what Paul says. There seems to be a lack of consistency. Or maybe your AV has deleted the Key on your machine

  29. #29
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: [RESOLVED] Registry Read Problems Confound Me

    I don't use an AV on my windows 8.1 machine. No need. I'v only ever installed O20013 and it most def is not there.
    My Github - 1d3nt

  30. #30
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: [RESOLVED] Registry Read Problems Confound Me

    Have you actually run Access? The reason I ask is because I've now uninstalled Office 2007 from my Win8.1 machine, leaving just Office 2013, and the Access.Application Key disappeared along with it (still got Access.Application.12 and Access.Application.15 Keys though ... loads of .12 Keys.left in fact ). It's only when I opened Access 2013 that the Access.Application Key reappeared along with its CurVer SubKey.

    Also, if you don't have the Access.Application Key, is any of this KB article relevant to you?

Tags for this Thread

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