|
1 CallRegistry.Call_CurrentUser_Fun(subitem: "SOFTWARE\\XXXNode\\", propertyname: "propertyXXX", param: " -mc D:\\xxx\\Book\\xxx.pdf");
静态类:
01 public static class CallRegistry
02 {
03 public static int Call_CurrentUser_Fun(string subitem, string propertyname, stringparam)
04 {
05
06 RegistryKey key = Registry.CurrentUser;
07 RegistryKey appitem = key.OpenSubKey(subitem, false);
08
09 if (null == appitem)
10 {
11 return -1;
12 }
13 string appPath = appitem.GetValue(propertyname).ToString();
14 if (String.IsNullOrEmpty(appPath))
15 {
16 return -2;
17 }
18 ProcessStartInfo psi = new ProcessStartInfo(appPath);
19 psi.UseShellExecute = false;
20 Process process = new Process();
21
22 if (!String.IsNullOrEmpty(param))
23 {
24 psi.Arguments = param;
25 }
26 process.StartInfo = psi;
27 bool result = process.Start();
28 return result ? 1 : 0;
29 }
30
31 public static int Call_CurrentUser_Fun(string subitem, string propertyname, string[] args)
32 {
33 StringBuilder param = new StringBuilder();
34 if (args != null)
35 {
36 foreach (string tmpParam in args)
37 {
38 param.Append(tmpParam).Append(" ");
39 } 40 }
41 return Call_CurrentUser_Fun(subitem, propertyname, param.ToString());
42 }
43 }
转自http://www.2cto.com |
|