peter
peter

Reputation: 8682

information in registry

AssemblyName.GetAssemblyName("").Version.ToString() will give the version number ,,but i need to get version number from registry

registry path is under MY computer -> HKEY_LOCAL_MACHINE->SOFTWARE->

leaf->monitor here current version file is there,,from there we need to

fetch version number

Upvotes: 0

Views: 684

Answers (3)

Factor Mystic
Factor Mystic

Reputation: 26790

Wael's code works fine, but there's a couple other (slightly syntactically cleaner) ways to do it, for example:

  • OpenSubKey knows how to open several subkeys at once:

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\leaf\monitor");

  • Additionally, if you only need to get a value, which your question asks about, it's even simpler (and this allows you to set a fallback value if your target key doesn't exist, avoiding a thrown exception if you use OpenSubKey):

string version = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\leaf\monitor", "version", "0");

Upvotes: 3

Wael Dalloul
Wael Dalloul

Reputation: 23044

you can use the following code to get the version key value:

RegistryKey key= Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("leaf").OpenSubKey("monitor ");
string version = key.GetValue("version");

Edit: check now :)

Upvotes: 1

RaYell
RaYell

Reputation: 70444

Here's the class that allows you to read and write windows registy. All you need to do with it is to find the proper value to read.

Upvotes: 0

Related Questions