示例#1
0
        /// <summary>
        /// Starts the GTA process.
        /// </summary>
        private void StartGTAProcess()
        {
            Process         process;
            ProcessProvider provider;


            provider = new ProcessProvider();

            if (provider.GetGrandTheftAutoProcess() != null)
            {
                EventLogLogger.LogError("Unable to start the GTA V process as it is already running.");
                throw new ApplicationException("Unable to start the GTA V process as it is already running.");
            }

            if (_config.IsSteamGame)
            {
                string steamPath;


                steamPath = RegistryHelper.GetSteamPath();

                if (!string.IsNullOrEmpty(steamPath))
                {
                    process = new Process();
                    process.StartInfo.FileName  = $"{steamPath}\\Steam.exe";
                    process.StartInfo.Arguments = "-applaunch 271590 -StraightIntoFreemode";
                    process.Start();
                }
                else
                {
                    throw new ArgumentException("Unable to find the Steam installation path in the registry.");
                }
            }
            else
            {
                string installPath;


                installPath = RegistryHelper.GetGTASocialClubInstallPath();

                if (!string.IsNullOrEmpty(installPath))
                {
                    process = new Process();
                    process.StartInfo.FileName  = $"{installPath}\\PlayGTAV.exe";
                    process.StartInfo.Arguments = "-StraightIntoFreemode";
                    process.Start();
                }
                else
                {
                    throw new ArgumentException("Unable to find the PlayGTAV installation path in the registry.");
                }
            }
        }