Beispiel #1
0
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == 0x004A)
     {
         COPYDATA cd      = (COPYDATA)Marshal.PtrToStructure(m.LParam, typeof(COPYDATA));
         string   strArgs = Marshal.PtrToStringAnsi(cd.lpData);
         string[] args    = strArgs.Split(' ');
         ParseClArguments(args);
     }
     base.WndProc(ref m);
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            bool onlyInstance = false;
            Mutex mutex = new Mutex(true, "PuttyWrap", out onlyInstance);
            if (!onlyInstance)
            {
                string strArgs = "";
                if(args.Length > 0)
                {
                    strArgs += args[0];

                    for (int i = 1; i < args.Length; i++)
                    {
                        strArgs += " " + args[i];
                    }
                }

                COPYDATA cd = new COPYDATA
                                  {
                                      dwData = 0,
                                      cbData = (uint) strArgs.Length + 1,
                                      lpData = Marshal.StringToHGlobalAnsi(strArgs)
                                  };

                IntPtr lpPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cd));
                Marshal.StructureToPtr(cd, lpPtr, true);
                Process[] plist = Process.GetProcessesByName("PuttyWrap");
                foreach (Process spProcess in plist)
                {
                    SendMessage(spProcess.MainWindowHandle, 0x004A, 0, lpPtr);
                }
                Marshal.FreeHGlobal(lpPtr);
            }
            else
            {

            #if DEBUG
                Logger.OnLog += Console.WriteLine;
            #endif

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new frmPuttyWrap(args));
                GC.KeepAlive(mutex);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            bool  onlyInstance = false;
            Mutex mutex        = new Mutex(true, "PuttyWrap", out onlyInstance);

            if (!onlyInstance)
            {
                string strArgs = "";
                if (args.Length > 0)
                {
                    strArgs += args[0];

                    for (int i = 1; i < args.Length; i++)
                    {
                        strArgs += " " + args[i];
                    }
                }

                COPYDATA cd = new COPYDATA
                {
                    dwData = 0,
                    cbData = (uint)strArgs.Length + 1,
                    lpData = Marshal.StringToHGlobalAnsi(strArgs)
                };

                IntPtr lpPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cd));
                Marshal.StructureToPtr(cd, lpPtr, true);
                Process[] plist = Process.GetProcessesByName("PuttyWrap");
                foreach (Process spProcess in plist)
                {
                    SendMessage(spProcess.MainWindowHandle, 0x004A, 0, lpPtr);
                }
                Marshal.FreeHGlobal(lpPtr);
            }
            else
            {
#if DEBUG
                Logger.OnLog += Console.WriteLine;
#endif

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new frmPuttyWrap(args));
                GC.KeepAlive(mutex);
            }
        }