-
[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.
-
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
-
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.
-
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...
-
Re: Registry Read Problems Confound Me
also I need to know which line causes the error
-
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
-
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.
-
1 Attachment(s)
Re: Registry Read Problems Confound Me
does the CurVer key look anything like this:
Attachment 116135
?
-
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.
-
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...
-
Re: Registry Read Problems Confound Me
hopefully, Thanks for trying
-
Re: Registry Read Problems Confound Me
There is no default value in 8.1
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
ident
There is no default value in 8.1
how do you explain posts #8 and #9?
-
Re: Registry Read Problems Confound Me
Quote:
There is no default value in 8.1
Can you elaborate please?
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
.paul.
how do you explain posts #8 and #9?
Yes, i'm wondering that myself
-
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
-
Re: Registry Read Problems Confound Me
-
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
-
1 Attachment(s)
Re: Registry Read Problems Confound Me
Attachment 116143
Quote:
Originally Posted by
ident
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
-
Re: Registry Read Problems Confound Me
2013 here, no such key exists. I guess i can't help.
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
ident
2013 here, no such key exists. I guess i can't help.
Still, thanks for your efforts
-
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.
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
Inferrd
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:D
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
Inferrd
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 :ehh: lol, i'm indeed ashamed.
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
.paul.
well spotted:D
Eh, sorry about that .paul. i don't know how i managed to do that. Thanks for your help, works well.
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
Inferrd
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.
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
ident
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
-
Re: Registry Read Problems Confound Me
Quote:
Originally Posted by
ident
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 :p
-
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.
-
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 :mad:). 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?