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;

#if DEBUG
            Mutex mutex = new Mutex(true, "SuperPutty", out onlyInstance);
#else
            Mutex mutex = new Mutex(true, "SuperPuttyRelease", out onlyInstance);
#endif
            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();
                cd.dwData = 0;
                cd.cbData = (uint)strArgs.Length + 1;

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

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new frmSuperPutty(args));
                GC.KeepAlive(mutex);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            bool onlyInstance = false;
#if DEBUG
            Mutex mutex = new Mutex(true, "SuperPutty", out onlyInstance);
#else
            Mutex mutex = new Mutex(true, "SuperPuttyRelease", out onlyInstance);
#endif
            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();
                cd.dwData = 0;
                cd.cbData = (uint)strArgs.Length + 1;

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

            	Application.EnableVisualStyles();
            	Application.SetCompatibleTextRenderingDefault(false);
            	Application.Run(new frmSuperPutty(args));
            	GC.KeepAlive(mutex);
            }
        }
Beispiel #4
0
        protected override void WndProc(ref Message m)
        {
            const int WM_COPYDATA = 0x004A;

            switch (m.Msg)
            {
            case WM_COPYDATA:
                COPYDATA cd      = (COPYDATA)Marshal.PtrToStructure(m.LParam, typeof(COPYDATA));
                string   strArgs = Marshal.PtrToStringAnsi(cd.lpData);
                string[] args    = strArgs.Split(' ');
                ParseClArguments(args);
                break;

            default:
                break;
            }

            bool callBase = WndProcForFocus(ref m);

            if (callBase)
            {
                base.WndProc(ref m);
            }
        }