-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
85 lines (79 loc) · 2.75 KB
/
Copy pathProgram.cs
File metadata and controls
85 lines (79 loc) · 2.75 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using FC2Editor.Core;
using FC2Editor.Core.Nomad;
namespace FC2Editor
{
internal static class Program
{
public static string programGuid = "9de9f6ee-6db7-41bf-a0b4-112e45dd3693";
public static string GetMapArgument()
{
string[] commandLineArgs = Environment.GetCommandLineArgs();
if (commandLineArgs.Length >= 2 && !commandLineArgs[1].StartsWith("-"))
{
return commandLineArgs[1];
}
return null;
}
private static bool OpenExistingAppCallback(IntPtr hWnd, IntPtr lParam)
{
if (Win32.GetProp(hWnd, programGuid) != IntPtr.Zero)
{
// This function is not implemented in the provided decompiled source for Win32
// Win32.SetForegroundWindow(hWnd);
IntPtr intPtr = IntPtr.Zero;
int cbData = 0;
string mapArgument = GetMapArgument();
if (mapArgument != null)
{
intPtr = Marshal.StringToCoTaskMemUni(mapArgument);
cbData = (mapArgument.Length + 1) * 2;
}
if (intPtr != IntPtr.Zero)
{
Win32.COPYDATASTRUCT lParam2 = new Win32.COPYDATASTRUCT
{
dwData = IntPtr.Zero,
lpData = intPtr,
cbData = cbData
};
Win32.SendMessage(hWnd, Win32.WM_COPYDATA, 0, ref lParam2);
}
Marshal.FreeCoTaskMem(intPtr);
return false;
}
return true;
}
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.CurrentCulture = CultureInfo.InvariantCulture;
bool createdNew;
using (new Mutex(true, programGuid, out createdNew))
{
if (!createdNew)
{
Win32.EnumWindows(OpenExistingAppCallback, IntPtr.Zero);
return;
}
MainForm mainForm = new MainForm();
SplashForm.Start();
bool flag = Engine.Init(mainForm, mainForm.Viewport);
SplashForm.Stop();
if (flag)
{
mainForm.Show();
mainForm.PostLoad();
Engine.Run();
mainForm.Dispose();
}
}
}
}
}