-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
65 lines (61 loc) · 1.65 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
65
/*
* Created by SharpDevelop.
* User: jgustafson
* Date: 3/23/2017
* Time: 4:48 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace DeepFileFind
{
/// <summary>
/// Class with program entry point.
/// </summary>
internal sealed class Program
{
/// <summary>
/// Program entry point.
/// </summary>
[STAThread]
private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var process = Process.GetCurrentProcess(); // Or whatever method you are using
string fullPath = process.MainModule.FileName;
bool version_then_exit = false;
for (int i=0; i<args.Length; i++) {
string s = args[i];
Debug.WriteLine("args["+i.ToString()+"]="+s);
bool handled = false;
/*
try {
}
catch (Exception exn) {
Debug.WriteLine("Could not finish checking for startup path:");
Debug.WriteLine(exn.ToString());
}
*/
if (s == "--version") {
version_then_exit = true;
}
else if (fullPath.ToLower().EndsWith(s) || fullPath.ToLower().EndsWith(s+".exe")) {
// args[0] is NOT the application in the CLR.
Debug.WriteLine("Warning: unexpected value arg["+i.ToString()+"]=\""+s+"\"");
}
else { // add .exe in case was run with Windows
MainForm.startup_path = s;
Debug.WriteLine("MainForm.startup_path=\""+s+"\"");
handled = true;
}
}
MainForm mainform = new MainForm();
mainform.version_then_exit = version_then_exit;
Application.Run(mainform);
}
}
}