query registry from aspx page

  • Thread starter Thread starter anthonyx26
  • Start date Start date
A

anthonyx26

Trying to query the registry here from my aspx page but keep getting the
following error. Any ideas?

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:

Line 24: lpType As Long, lpData As String, lpcbData As Long) As Long
Line 25:
Line 26: RegistryKey key =
Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Setup",
false);
Line 27:
Line 28: Dim myregval = key.GetValue("BootDir").ToString();

Source File: C:\Inetpub\wwwroot\GMMM_uploadPR.aspx Line: 26
 
Sorry for confusion. Using vb.net.

- anthony

Mark Rae said:
This seems to be a mixture of VB.NET and C#...

Line 24 looks like VB.NET, but it looks as if Dim is missing at the
beginning.

Line 26 looks like C# due to the instantiation syntax, the fact that
'false' is all lower-case, and the semi-colon at the end.

Line 28 looks like VB.NET, but it has a semi-colon at the end.

Please clarify what server-side language you are using...
 
Trying to query the registry here from my aspx page but keep getting the
following error.  Any ideas?

Server Error in '/' Application.
---------------------------------------------------------------------------­-----

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:

Line 24:        lpType As Long, lpData As String, lpcbData As Long) As Long
Line 25:
Line 26: RegistryKey key =
Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVers­ion\\Setup",
false);
Line 27:
Line 28: Dim myregval = key.GetValue("BootDir").ToString();

Source File: C:\Inetpub\wwwroot\GMMM_uploadPR.aspx    Line: 26

Possibly a syntax error.
 
I love the smell of fresh sarcasm in the morning :-)

I ended up solving the problem by ripping out a bunch of junk code (I'm not
the one who had put the page together). This worked like a charm:

Dim MyPath =
Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\BlahCo\BlahProduct",
"Path", Nothing)

Just a little surprised no one else had suggested this simple one liner to
get the registry value. Plenty o' sarcasm though ;-)

Cheers!
- anthony
 
Back
Top