Ejemplo n.º 1
0
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		static void Main()
		{
			string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
			Globals.Initialize(exePath);
			PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "BiUpdateHelper_Log.txt");

			FileInfo fiExe = new FileInfo(exePath);
			Environment.CurrentDirectory = fiExe.Directory.FullName;

			settings = new BiUpdateHelperSettings();
			settings.Load();
			if (string.IsNullOrWhiteSpace(settings.secret))
			{
				settings.secret = Hash.GetSHA256Hex(Guid.NewGuid().ToString());
				settings.Save();
			}
			settings.SaveIfNoExist();

			RegistryUtil.Force32BitRegistryAccess = settings.bi32OnWin64;

			AutoFixBad32BitSetting();

			PerformanceData.PerformanceDataCollector.onReportUploaded = () =>
			{
				settings.Load();
				settings.lastUsageReportAt = TimeUtil.GetTimeInMsSinceEpoch();
				settings.Save();
			};
			PerformanceData.PerformanceDataCollector.getSecretString = () =>
			{
				return Program.settings.secret;
			};

			if (Environment.UserInteractive)
			{
				string Title = "BiUpdateHelper " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
				string ServiceName = "BiUpdateHelper";
				ButtonDefinition btnRegKey = new ButtonDefinition("BI Registration Info", btnRegkey_Click);
				ButtonDefinition btnSettings = new ButtonDefinition("Edit Service Settings", btnSettings_Click);
				ButtonDefinition btnCameraConfigLinks = new ButtonDefinition("Camera Config Links", btnCameraConfigLinks_Click);
				ButtonDefinition btnRegistryBackupNow = new ButtonDefinition("Take Registry Backup Now", btnRegistryBackupNow_Click);
				ButtonDefinition btnPerfData = new ButtonDefinition("Performance Data", btnPerfData_Click);
				ButtonDefinition[] customButtons = new ButtonDefinition[] { btnRegKey, btnSettings, btnCameraConfigLinks, btnRegistryBackupNow, btnPerfData };

				System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, customButtons));
			}
			else
			{
				ServiceBase[] ServicesToRun;
				ServicesToRun = new ServiceBase[]
				{
					new MainSvc()
				};
				ServiceBase.Run(ServicesToRun);
			}
		}
Ejemplo n.º 2
0
        private void SaveSettings()
        {
            if (isLoaded)
            {
                //settings.killBlueIrisProcessesDuringUpdate = cb_killBlueIrisProcessesDuringUpdate.Checked;
                settings.backupUpdateFiles = cb_backupUpdateFiles.Checked;
                settings.includeRegistryWithUpdateBackup = cb_includeRegistryWithUpdateBackup.Checked;
                settings.dailyRegistryBackups            = cb_dailyRegistryBackups.Checked;
                settings.logVerbose  = cb_logVerbose.Checked;
                settings.bi32OnWin64 = cb_BI32Win64.Checked;
                RegistryUtil.Force32BitRegistryAccess = settings.bi32OnWin64;

                settings.Save();
            }
        }
Ejemplo n.º 3
0
		private static void AutoFixBad32BitSetting()
		{
			if (Environment.Is64BitOperatingSystem)
			{
				// This is a 64 bit OS, so it is possible that our bi32OnWin64 setting is wrong.
				if (RegistryUtil.GetHKLMKey(@"SOFTWARE\Perspective Software\Blue Iris") == null)
				{
					// No BI detected. Try the opposite setting.
					RegistryUtil.Force32BitRegistryAccess = !RegistryUtil.Force32BitRegistryAccess;
					if (RegistryUtil.GetHKLMKey(@"SOFTWARE\Perspective Software\Blue Iris") == null)
						RegistryUtil.Force32BitRegistryAccess = !RegistryUtil.Force32BitRegistryAccess; // No BI detected. Revert setting.
					else
					{
						// Found BI using the opposite setting.  Save the setting.
						settings.bi32OnWin64 = RegistryUtil.Force32BitRegistryAccess;
						settings.Save();
					}
				}
			}
		}