-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
60 lines (59 loc) · 1.91 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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BetterStartUp
{
static class Program
{
/// <summary>
/// Ponto de entrada principal para o aplicativo.
/// </summary>
[STAThread]
static void Main(string[] args)
{
if (args.Contains("-startup"))
{
List<Programa> data = new List<Programa>();
try
{
string path = System.Reflection.Assembly.GetEntryAssembly().Location;
path = System.IO.Path.GetDirectoryName(path) + "\\startup.bsu";
using (var file = File.OpenRead(path))
{
var reader = new BinaryFormatter();
data = (List<Programa>)reader.Deserialize(file);
}
}
catch (System.IO.FileNotFoundException)
{
return;
}
if (data.Count > 0)
{
foreach (Programa p in data)
{
if(File.Exists(p.caminho))
{
if (p.delay > 0)
{
System.Threading.Thread.Sleep(p.delay * 1000);
}
System.Diagnostics.Process.Start(p.caminho, p.argumentos);
}
}
}
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new BetterStartUp());
}
}
}
}