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 | static class Program
{
static void RegisterOcx(string ocxPath)
{
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "regsvr32.exe";
p.StartInfo.Arguments = ocxPath;
p.Start();
p.WaitForExit();
}
static string FindExternal(string baseName)
{
string f = Application.StartupPath;
for (int i = 0; i < 6; i++)
{
if (!File.Exists(f + "\\" + baseName)) f = Path.GetDirectoryName(f);
}
if (!File.Exists(f + "\\" + baseName))
{
MessageBox.Show("Could not locate " + baseName + " in: " + f);
return "";
}
f += "\\" + baseName;
return f;
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var clsIdKey = Registry.ClassesRoot.OpenSubKey("rhexed.HexEd");
if (clsIdKey == null)
{
string ocx = FindExternal("hexed.ocx");
if (ocx.Length != 0) RegisterOcx(ocx);
}
Application.Run(new Form1());
}
}
|