コード例 #1
0
        private static void WriteAutostartAppEntryInRegistry()
        {
            try
            {
                string applicationPath = string.Format("\"{0}\"", ServiceRegistration.Get <IPathManager>().GetPath("<APPLICATION_PATH>"));
#if DEBUG
                applicationPath = applicationPath.Replace(".vshost", "");
#endif
                if (IsAutoStartEnabled)
                {
                    WindowsAPI.AddAutostartApplication(applicationPath, AUTOSTART_REGISTER_NAME, true);
                }
                else
                {
                    WindowsAPI.RemoveAutostartApplication(AUTOSTART_REGISTER_NAME, true);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("Can't write autostart value to registry", ex);
            }
        }