Browse Subversion Repository
Contents of /NeoFT/Win32Util/RegistryHelper.cs
Parent Directory
| Revision Log
| 1 |
using System; |
| 2 |
using Microsoft.Win32; |
| 3 |
|
| 4 |
namespace nft.win32util |
| 5 |
{ |
| 6 |
/// <summary> |
| 7 |
/// RegistryHelper ĚTvĚŕžĹˇB |
| 8 |
/// </summary> |
| 9 |
public class RegistryHelper |
| 10 |
{ |
| 11 |
private RegistryHelper() |
| 12 |
{ |
| 13 |
} |
| 14 |
|
| 15 |
// Read data string of specified key and value from system registry. |
| 16 |
public static string ReadKey(string key,string valname) |
| 17 |
{ |
| 18 |
int n = key.IndexOf('\\'); |
| 19 |
string baseKey = key.Substring(5,n-5); |
| 20 |
string subKey = key.Substring(n+1); |
| 21 |
RegistryKey rKey; |
| 22 |
switch(baseKey) |
| 23 |
{ |
| 24 |
case "CLASSES_ROOT": |
| 25 |
rKey = Registry.ClassesRoot; |
| 26 |
break; |
| 27 |
case "LOCAL_MACHINE": |
| 28 |
rKey = Registry.LocalMachine; |
| 29 |
break; |
| 30 |
case "CURRENT_USER": |
| 31 |
rKey = Registry.CurrentUser; |
| 32 |
break; |
| 33 |
case "CURRENT_CONFIG": |
| 34 |
rKey = Registry.CurrentConfig; |
| 35 |
break; |
| 36 |
default: |
| 37 |
return null; |
| 38 |
} |
| 39 |
if(valname==null) |
| 40 |
valname=""; |
| 41 |
object o = rKey.OpenSubKey(subKey,false).GetValue(valname); |
| 42 |
if(o==null) |
| 43 |
return null; |
| 44 |
else |
| 45 |
return o.ToString(); |
| 46 |
} |
| 47 |
} |
| 48 |
} |
|