private string GetExe(bool fromSteam, string steamAppId, out string args)
        {
            args = string.Empty;



            try
            {
                if (fromSteam && string.IsNullOrEmpty(steamAppId) == false)
                {
                    var steamExe = Registry.CurrentUser.OpenSubKey("Software", false)
                                   .OpenSubKey("Classes")
                                   .OpenSubKey("Steam")
                                   .OpenSubKey("shell")
                                   .OpenSubKey("open")
                                   .OpenSubKey("command")
                                   .GetValue("").ToString();
                    steamExe = steamExe.Replace(" \"%1\"", string.Empty).Replace("\"", String.Empty);
                    args     = " -applaunch " + steamAppId;
                    return(steamExe);
                }
            }
            catch (Exception)
            {
            }

            if (string.IsNullOrEmpty(LinkProviderFactory.DeferredExePath) == false)
            {
                return(LinkProviderFactory.DeferredExePath);
            }

            return(ProviderHelpers.GetExecutingPath());
        }
예제 #2
0
        private static void HandleDesktopFile(string activationProtocol, string desktopFile, string steamAppId)
        {
            using (var f = File.Open(desktopFile, FileMode.OpenOrCreate))
            {
                using (var writter = new StreamWriter(f))
                {
                    var filename = ProviderHelpers.GetExecutingPath();

                    if (filename.Contains(" "))
                    {
                        filename = "\"" + filename + "\"";
                    }

                    var icon = filename;

                    if (string.IsNullOrEmpty(LinkProviderFactory.DeferredExePath) == false)
                    {
                        filename = LinkProviderFactory.DeferredExePath;
                    }

                    if (string.IsNullOrEmpty(steamAppId) == false)
                    {
                        filename = "steam -applaunch " + steamAppId;
                    }


                    writter.Write(DesktopFileFormat, filename, icon, activationProtocol);
                }
            }
        }
        private void SetProtocol(RegistryKey classes, string activationProtocol, bool fromSteam, string steamAppId)
        {
            var appkey = classes.OpenSubKey(activationProtocol);

            if (appkey != null)
            {
                classes.DeleteSubKeyTree(activationProtocol);
                appkey = null;
            }

            appkey = classes.CreateSubKey(activationProtocol);
            appkey.SetValue("", string.Format("URL:{0} Protocol", activationProtocol));
            appkey.SetValue("URL Protocol", "");

            string args;
            var    executingExe = GetExe(fromSteam, steamAppId, out args);

            appkey
            .CreateSubKey("shell")
            .CreateSubKey("open")
            .CreateSubKey("command")
            .SetValue("", string.Format("\"{0}\" {1} \"%1\"", executingExe, args));


            var defaultIcon = appkey.CreateSubKey("DefaultIcon");

            defaultIcon.SetValue("", string.Format("\"{0}\",-1", ProviderHelpers.GetExecutingPath()));

            _schemes.Add(activationProtocol);
        }