コード例 #1
0
        /// <summary>
        /// Gets/creates Steam shortcut, assigns this instance's properties to the Steam shortcut, and then launches the shortcut in Steam.
        /// </summary>
        /// <returns>True if successful; otherwise, false.</returns>
        public bool LaunchShortcut()
        {
            AppId = GetNewOrExistingShortcut(out var isShortcutNew);
            if (AppId == 0)
            {
                return(false);
            }

            Logger.Info($"Assigning properties to {(isShortcutNew ? "new" : "existing")} Steam shortcut: " +
                        $"[{AppId}] '{AppName}' | {ExePathInDoubleQuotes} | {StartDirInDoubleQuotes} | {CommandLine}");

            ClientShortcuts.SetShortcutAppName(AppId, AppName);
            ClientShortcuts.SetShortcutExe(AppId, ExePathInDoubleQuotes);
            ClientShortcuts.SetShortcutStartDir(AppId, StartDirInDoubleQuotes);
            ClientShortcuts.SetShortcutCommandLine(AppId, CommandLine);

            // Wait a moment to ensure Steam is done altering the shortcut
            System.Threading.Thread.Sleep(500);

            // Get the ShortcutID for this shortcut so we can construct a Steam shortcut URL
            var crc = ResolveShortcutId(ExePathInDoubleQuotes, AppName);

            Logger.Info($"'{AppName}' ShortcutID resolved to: {crc}");
            var steamUrl = $"steam://rungameid/{crc}";

            Logger.Info($"Starting Steam shortcut: {steamUrl}");

            // Start the shortcut
            Process.Start(steamUrl);

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Resets the shortcut's properties to the SteamShortcutManager default settings.
        /// </summary>
        /// <returns>True if successful; otherwise, false.</returns>
        public bool ResetProxyShortcut()
        {
            if (AppId == 0)
            {
                return(false);
            }

            Logger.Info($"Resetting shortcut properties [{AppId}].");
            ClientShortcuts.SetShortcutAppName(AppId, DefaultShortcut.NAME);
            ClientShortcuts.SetShortcutExe(AppId, DefaultShortcut.EXE);
            ClientShortcuts.SetShortcutStartDir(AppId, DefaultShortcut.START_DIR);
            ClientShortcuts.ClearShortcutUserTags(AppId);
            ClientShortcuts.AddShortcutUserTag(AppId, DefaultShortcut.TAG);
            ClientShortcuts.SetShortcutHidden(AppId, true);
            return(true);
        }