static void Main(string[] args)
        {
            try
            {
                Process cur_proc = Process.GetCurrentProcess();
                CurrentProcess = cur_proc;
                Process[] p = Process.GetProcessesByName(cur_proc.ProcessName);
                IntPtr handle = IntPtr.Zero;
                if (p.Length > 1)
                {
                    for (int i = 0; i < p.Length; i++)
                        if (string.Compare(System.IO.Path.GetDirectoryName(p[i].MainModule.FileName), System.IO.Path.GetDirectoryName(cur_proc.MainModule.FileName), true) == 0 && p[i].Id != cur_proc.Id)
                        {
                            handle = p[i].MainWindowHandle;
                            /*if (handle == IntPtr.Zero)
                            {
                                System.Threading.Thread.Sleep(5000);
                                p[i].Refresh();
                                if (!p[i].HasExited)
                                    handle = p[i].MainWindowHandle;
                            }*/
                            if (handle != IntPtr.Zero)
                            {
                                SetForegroundWindow(handle);
                                if (IsZoomed(handle) != 0)
                                    ShowWindow(handle, 3/*SW_MAXIMIZE*/);
                                else
                                    if (IsIconic(handle) != 0)
                                    ShowWindow(handle, 9/*SW_RESTORE*/);
                                else
                                    ShowWindow(handle, 5/*SW_SHOW*/);
                                if (args.Length > 0)
                                {
                                    //for (int j = 0; j < args.Length; j++)
                                    {
                                        COPYDATASTRUCT ds = new COPYDATASTRUCT();
                                        IntPtr str_ptr = System.Runtime.InteropServices.Marshal.StringToHGlobalUni(args[0]);
                                        ds.dwData = (IntPtr)32;//flag, zadaem sami, chtoby process znal, kakoe eto konkretno soobshenie
                                        ds.cbData = (uint)(args[0].Length + 1);
                                        ds.lpData = args[0];//str_ptr;
                                        IntPtr ds_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(ds));
                                        Marshal.StructureToPtr(ds, ds_ptr, false);
                                        SendMessage(handle, 74/*WM_COPYDATA*/, cur_proc.Handle, ds_ptr);
                                    }
                                }
                                return;
                            }
                            return;

                        }
                }
            }
            catch
            {

            }
            try
            {

                if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
                CommandLineArgs = args;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                MainForm = new Form1();
                Application.Run(MainForm);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }