예제 #1
0
파일: Program.cs 프로젝트: ewin66/Archer
        static void Main()
        {
            bool create;

            using (Mutex mu = new Mutex(true, Application.ProductName, out create))
            {
                if (create)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    if (ys.Common.HaveAuthorityRight())
                    {
                        Application.Run(new Main());
                    }
                }
                // Only allow one Archer instance.
                // Active the opened Archer.
                // Not a safe way, but in this method only takes one line.
                else
                {
                    IntPtr PreWindow = ys.Common.FindWindow(null, File.ReadAllText(Archer.Resource.ArcherTemp));

                    ys.Common.COPYDATASTRUCT data = new ys.Common.COPYDATASTRUCT()
                    {
                        dwData = (IntPtr)100,
                        cbData = System.Text.Encoding.Default.GetBytes(System.Environment.CommandLine).Length + 1,
                        lpData = System.Environment.CommandLine
                    };
                    ys.Common.SendMessage(PreWindow, ys.Common.WM_COPYDATA, 0, ref data);
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: ysmood/Archer
        static void Main()
        {
            bool create;
            using (Mutex mu = new Mutex(true, Application.ProductName, out create))
            {
                if (create)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    if (ys.Common.HaveAuthorityRight()) Application.Run(new Main());
                }
                // Only allow one Archer instance.
                // Active the opened Archer.
                // Not a safe way, but in this method only takes one line.
                else
                {
                    IntPtr PreWindow = ys.Common.FindWindow(null, File.ReadAllText(Archer.Resource.ArcherTemp));

                    ys.Common.COPYDATASTRUCT data = new ys.Common.COPYDATASTRUCT()
                    {
                        dwData = (IntPtr)100,
                        cbData = System.Text.Encoding.Default.GetBytes(System.Environment.CommandLine).Length + 1,
                        lpData = System.Environment.CommandLine
                    };
                    ys.Common.SendMessage(PreWindow, ys.Common.WM_COPYDATA, 0, ref data);
                }
            }
        }
예제 #3
0
파일: Archer.cs 프로젝트: ysmood/Archer
		// Message process
		protected override void WndProc(ref Message m)
		{
			if (m.Msg == ys.Common.WM_COPYDATA)
			{
				ys.Common.COPYDATASTRUCT data = new ys.Common.COPYDATASTRUCT();
				data = (ys.Common.COPYDATASTRUCT)m.GetLParam(data.GetType());

				RunCommandLine(data.lpData);
			}
			else if (m.Msg == ys.Common.WM_QUERYENDSESSION)
			{
				this.Close();
			}
			else
				base.WndProc(ref m);
		}