Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Registrykey reading problems

Reply
 
Old 03-31-2008   #1 (permalink)
pantagruel


 
 

Registrykey reading problems

Hi,

I'm trying to read a registry key:

I've tried:

RegistryKey rkey1 = rkey.OpenSubKey(
"SYSTEM\\CurrentControlSet\\Services\\Rendering Service");

then
RegistryKey rkey1 = rkey.OpenSubKey(
"SYSTEM\\CurrentControlSet\\Services\\Rendering Service\\");
due to problems

I've tried

RenderingQ = rkey1.GetValue("RenderingQOnDemandQ");

which gave an error when compiling of
Error 6 Cannot implicitly convert type 'object' to 'string'. An
explicit conversion exists (are you missing a cast?)

which seems weird, from the documentation I thought GetValue returned
a string?
so I tried:

RenderingQ = rkey1.GetValue("RenderingQOnDemandQ").ToString();

that compiles.

When I run it however I get a null value exception (the same situation
exists for all the various keys I'm working with)

if I do a registry dump of the key I'm working with I get:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Rendering
Service]

and
"RenderingQOnDemandQ"="C:\\RenditionServerQ\\QueueManagerQ\\OnDemandQ"

So I suppose there is something simple that i don't know about working
with the registry in .Net that someone can help me with?

Is it a casting exception?
How should I cast?





My System SpecsSystem Spec
Old 03-31-2008   #2 (permalink)
pantagruel


 
 

Re: Registrykey reading problems

On Mar 31, 10:42 am, pantagruel <rasmussen.br...@xxxxxx> wrote:
Quote:

> Hi,
>
> I'm trying to read a registry key:
>
> I've tried:
>
> RegistryKey rkey1 = rkey.OpenSubKey(
> "SYSTEM\\CurrentControlSet\\Services\\Rendering Service");
>
> then
> RegistryKey rkey1 = rkey.OpenSubKey(
> "SYSTEM\\CurrentControlSet\\Services\\Rendering Service\\");
> due to problems
>
> I've tried
>
> RenderingQ = rkey1.GetValue("RenderingQOnDemandQ");
>
> which gave an error when compiling of
> Error 6 Cannot implicitly convert type 'object' to 'string'. An
> explicit conversion exists (are you missing a cast?)
>
> which seems weird, from the documentation I thought GetValue returned
> a string?
> so I tried:
>
> RenderingQ = rkey1.GetValue("RenderingQOnDemandQ").ToString();
>
> that compiles.
>
> When I run it however I get a null value exception (the same situation
> exists for all the various keys I'm working with)
>
> if I do a registry dump of the key I'm working with I get:
>
> [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Rendering
> Service]
>
> and
> "RenderingQOnDemandQ"="C:\\RenditionServerQ\\QueueManagerQ\\OnDemandQ"
>
> So I suppose there is something simple that i don't know about working
> with the registry in .Net that someone can help me with?
>
> Is it a casting exception?
> How should I cast?
oops, obviously should note that rkey is RegistryKey rkey =
Registry.LocalMachine;
My System SpecsSystem Spec
Old 03-31-2008   #3 (permalink)
Marc Gravell


 
 

Re: Registrykey reading problems

It definitely returns an object - after all, not all attributes are strings.

You might want to double-check the key name; equally, using string literals
(i.e. @"foo") can make it easier to avoid escaping issues. Using a different
key (that exists on my machine) the following works fine:

string value = Convert.ToString(
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RemoteAccess",
@"DisplayName", null));

Marc


My System SpecsSystem Spec
Old 03-31-2008   #4 (permalink)
Family Tree Mike


 
 

RE: Registrykey reading problems

Be aware that registry virtualization on Vista or 64bit OS's will mess up
your mind in this scenario. If you are on 32 bit XP however, I don't see why
this wouldn't work, given the key is specified correctly.

"pantagruel" wrote:
Quote:

> Hi,
>
> I'm trying to read a registry key:
>
> I've tried:
>
> RegistryKey rkey1 = rkey.OpenSubKey(
> "SYSTEM\\CurrentControlSet\\Services\\Rendering Service");
>
> then
> RegistryKey rkey1 = rkey.OpenSubKey(
> "SYSTEM\\CurrentControlSet\\Services\\Rendering Service\\");
> due to problems
>
> I've tried
>
> RenderingQ = rkey1.GetValue("RenderingQOnDemandQ");
>
> which gave an error when compiling of
> Error 6 Cannot implicitly convert type 'object' to 'string'. An
> explicit conversion exists (are you missing a cast?)
>
> which seems weird, from the documentation I thought GetValue returned
> a string?
> so I tried:
>
> RenderingQ = rkey1.GetValue("RenderingQOnDemandQ").ToString();
>
> that compiles.
>
> When I run it however I get a null value exception (the same situation
> exists for all the various keys I'm working with)
>
> if I do a registry dump of the key I'm working with I get:
>
> [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Rendering
> Service]
>
> and
> "RenderingQOnDemandQ"="C:\\RenditionServerQ\\QueueManagerQ\\OnDemandQ"
>
> So I suppose there is something simple that i don't know about working
> with the registry in .Net that someone can help me with?
>
> Is it a casting exception?
> How should I cast?
>
>
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
start up problems - i've been reading threads all night !! .NET General
Problems reading Vista 64-Bit OS installation DVD after clone copy Vista installation & setup
Sony MemoryStick card reading problems in x64 - NOT in x86! General Discussion
Re: Some Problems, mainly with Reading CDs? Vista General
Problems Reading Disks in RC1 Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46