Ejemplo n.º 1
0
 public static void Main()
 {
     Player.App app = new Player.App();
     app.InitializeComponent();
     app.Run();
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Process instance = RunningInstance();
            bool    bExist   = true;
            string  ss       = string.Empty;
            Mutex   MyMutex  = new Mutex(true, "ONLYONETASK", out bExist);

            if (!bExist)
            {
                //Make   sure   the   window   is   not   minimized   or   maximized
                //ShowWindowAsync(instance.MainWindowHandle, WS_SHOWMAXIMIZED);

                ////Set   the   real   intance   to   foreground   window
                //SetForegroundWindow(instance.MainWindowHandle);

                string[]      cmds  = Environment.GetCommandLineArgs();
                List <string> cmd2s = cmds.ToList();
                cmd2s.RemoveAt(0);
                string argstrs = String.Join("", cmd2s);

                if (cmds.Length > 0)
                {
                    int WINDOW_HANDLER = FindWindow(null, @"ImPlayerMainWindow");// (int)new WindowInteropHelper(mianWindow).Handle;
                    if (WINDOW_HANDLER != 0)
                    {
                        COPYDATASTRUCT cds;
                        cds.dwData = (IntPtr)100;
                        cds.lpData = argstrs.Trim();     //cmds[1];
                        cds.cbData = argstrs.Length * 2; //cmds[1].Length * 2;
                        SendMessage(WINDOW_HANDLER, 0x004A, 0, ref cds);
                    }
                }
            }
            else
            {
                Player.App app = new App(); //本项目中APP
                app.InitializeComponent();  //初始化资源
                string[]      cmds  = Environment.GetCommandLineArgs();
                List <string> cmd2s = cmds.ToList();
                cmd2s.RemoveAt(0);
                string argstrs = "";
                if (cmds.Length > 0)
                {
                    argstrs = String.Join("", cmd2s).Trim();
                    //  int WINDOW_HANDLER = FindWindow(null, @"Form1");
                    //  int wh = (int)new WindowInteropHelper(mianWindow).Handle;
                    ////  if (WINDOW_HANDLER != 0)
                    //  MessageBox.Show(wh.ToString());
                    //  {
                    //      COPYDATASTRUCT cds;
                    //      cds.dwData = (IntPtr)100;
                    //      cds.lpData = argstrs;//cmds[1];
                    //      cds.cbData = argstrs.Length * 2;//cmds[1].Length * 2;
                    //      IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(cds));
                    //      Marshal.StructureToPtr(cds, buffer, false);
                    //      SendMessage(wh, 0x004A, 0, buffer);
                    //  }
                }
                mianWindow = new MainPage(argstrs);
                app.Run(mianWindow);
            }
        }