-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInstallApp.cs
53 lines (49 loc) · 1.69 KB
/
InstallApp.cs
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
47
48
49
50
51
52
53
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;
using System.Threading.Tasks;
namespace BackUpDesktop
{
internal class InstallApp
{
static string path = Program.BackUpPath + "\\SoftwareName.txt";
public static void FindInstalls(RegistryKey regKey, List<string> keys)
{
foreach (string key in keys)
{
using (RegistryKey rk = regKey.OpenSubKey(key))
{
if (rk == null)
{
continue;
}
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(Convert.ToString(sk.GetValue("DisplayName")));
}
}
using (StreamWriter sw = File.AppendText(path))
{
sw.WriteLine(Convert.ToString(sk.GetValue("DisplayName")));
}
}
catch (Exception ex)
{ }
}
}
}
}
}
}
}