Example #1
0
        private void CheckOptions(ArgumentParser parser)
        {
            if (parser.HasErrors)
            {
                runShutdown = false;
                exitApp     = true;
                Current.Shutdown(1);
            }
            else if (parser.Driverinstall)
            {
                CreateBaseThread();
                WelcomeDialog dialog = new WelcomeDialog(true);
                dialog.ShowDialog();
                runShutdown = false;
                exitApp     = true;
                Current.Shutdown();
            }
            else if (parser.ReenableDevice)
            {
                DS4Devices.ReEnableDevice(parser.DeviceInstanceId);
                runShutdown = false;
                exitApp     = true;
                Current.Shutdown();
            }
            else if (parser.Runtask)
            {
                StartupMethods.LaunchOldTask();
                runShutdown = false;
                exitApp     = true;
                Current.Shutdown();
            }
            else if (parser.Command)
            {
                IntPtr hWndDS4WindowsForm = FindWindow(ReadIPCClassNameMMF(), "DS4Windows");
                if (hWndDS4WindowsForm != IntPtr.Zero)
                {
                    COPYDATASTRUCT cds;
                    cds.lpData = IntPtr.Zero;

                    try
                    {
                        cds.dwData = IntPtr.Zero;
                        cds.cbData = parser.CommandArgs.Length;
                        cds.lpData = Marshal.StringToHGlobalAnsi(parser.CommandArgs);
                        SendMessage(hWndDS4WindowsForm, DS4Forms.MainWindow.WM_COPYDATA, IntPtr.Zero, ref cds);
                    }
                    finally
                    {
                        if (cds.lpData != IntPtr.Zero)
                        {
                            Marshal.FreeHGlobal(cds.lpData);
                        }
                    }
                }

                runShutdown = false;
                exitApp     = true;
                Current.Shutdown();
            }
        }