-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
64 lines (61 loc) · 2 KB
/
Program.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
54
55
56
57
58
59
60
61
62
63
64
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace LOLFlashRecorder
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
InitProgram();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private static void InitProgram()
{
//检查dm.dll是否存在,如果不存在就添加
if (!IsRegeditItemExist())
{
Process p = new Process();
p.StartInfo.FileName = "Regsvr32.exe";
p.StartInfo.Arguments = @"/s dm.dll";
p.Start();
if (!IsRegeditItemExist())
{
DialogResult dr = MessageBox.Show("程序安装dm.dll出错,请检查是否存在此文件!\n是否重新尝试?", "警告", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
if (dr == DialogResult.Retry)
{
InitProgram();
}
else
{
Environment.Exit(-1);
}
}
}
}
private static bool IsRegeditItemExist()
{
string[] subkeyNames;
RegistryKey key = Registry.ClassesRoot;
RegistryKey software = key.OpenSubKey("WOW6432Node").OpenSubKey("CLSID");
subkeyNames = software.GetSubKeyNames();
foreach (string keyName in subkeyNames)
{
if (keyName == @"{26037A0E-7CBD-4FFF-9C63-56F2D0770214}")
{
key.Close();
return true;
}
}
key.Close();
return false;
}
}
}