Develop and Download Open Source Software

Browse Subversion Repository

Contents of /NeoFT/Win32Util/RegistryHelper.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download)
Tue Mar 25 12:06:05 2008 UTC (16 years ago) by c477
File size: 1039 byte(s)


1 using System;
2 using Microsoft.Win32;
3
4 namespace nft.win32util
5 {
6 /// <summary>
7 /// RegistryHelper ‚ĚŠT—v‚Ěŕ–ž‚Ĺ‚ˇ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 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26