MainStartup.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. using MediaBrowser.Common.Implementations.Logging;
  2. using MediaBrowser.Model.Logging;
  3. using MediaBrowser.Server.Implementations;
  4. using MediaBrowser.Server.Startup.Common;
  5. using MediaBrowser.Server.Startup.Common.Browser;
  6. using MediaBrowser.ServerApplication.Native;
  7. using MediaBrowser.ServerApplication.Splash;
  8. using MediaBrowser.ServerApplication.Updates;
  9. using Microsoft.Win32;
  10. using System;
  11. using System.Configuration.Install;
  12. using System.Diagnostics;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Management;
  16. using System.Runtime.InteropServices;
  17. using System.ServiceProcess;
  18. using System.Threading;
  19. using System.Threading.Tasks;
  20. using System.Windows.Forms;
  21. using CommonIO.Windows;
  22. using Emby.Drawing.ImageMagick;
  23. using ImageMagickSharp;
  24. using MediaBrowser.Common.Net;
  25. using MediaBrowser.Server.Implementations.Logging;
  26. namespace MediaBrowser.ServerApplication
  27. {
  28. public class MainStartup
  29. {
  30. private static ApplicationHost _appHost;
  31. private static ILogger _logger;
  32. private static bool _isRunningAsService = false;
  33. private static bool _appHostDisposed;
  34. [DllImport("kernel32.dll", SetLastError = true)]
  35. static extern bool SetDllDirectory(string lpPathName);
  36. /// <summary>
  37. /// Defines the entry point of the application.
  38. /// </summary>
  39. public static void Main()
  40. {
  41. var options = new StartupOptions();
  42. _isRunningAsService = options.ContainsOption("-service");
  43. var currentProcess = Process.GetCurrentProcess();
  44. var applicationPath = currentProcess.MainModule.FileName;
  45. var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86");
  46. Wand.SetMagickCoderModulePath(architecturePath);
  47. var success = SetDllDirectory(architecturePath);
  48. var appPaths = CreateApplicationPaths(applicationPath, _isRunningAsService);
  49. var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
  50. logManager.ReloadLogger(LogSeverity.Debug);
  51. logManager.AddConsoleOutput();
  52. var logger = _logger = logManager.GetLogger("Main");
  53. ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
  54. // Install directly
  55. if (options.ContainsOption("-installservice"))
  56. {
  57. logger.Info("Performing service installation");
  58. InstallService(applicationPath, logger);
  59. return;
  60. }
  61. // Restart with admin rights, then install
  62. if (options.ContainsOption("-installserviceasadmin"))
  63. {
  64. logger.Info("Performing service installation");
  65. RunServiceInstallation(applicationPath);
  66. return;
  67. }
  68. // Uninstall directly
  69. if (options.ContainsOption("-uninstallservice"))
  70. {
  71. logger.Info("Performing service uninstallation");
  72. UninstallService(applicationPath, logger);
  73. return;
  74. }
  75. // Restart with admin rights, then uninstall
  76. if (options.ContainsOption("-uninstallserviceasadmin"))
  77. {
  78. logger.Info("Performing service uninstallation");
  79. RunServiceUninstallation(applicationPath);
  80. return;
  81. }
  82. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  83. RunServiceInstallationIfNeeded(applicationPath);
  84. if (IsAlreadyRunning(applicationPath, currentProcess))
  85. {
  86. logger.Info("Shutting down because another instance of Emby Server is already running.");
  87. return;
  88. }
  89. if (PerformUpdateIfNeeded(appPaths, logger))
  90. {
  91. logger.Info("Exiting to perform application update.");
  92. return;
  93. }
  94. try
  95. {
  96. RunApplication(appPaths, logManager, _isRunningAsService, options);
  97. }
  98. finally
  99. {
  100. OnServiceShutdown();
  101. }
  102. }
  103. /// <summary>
  104. /// Determines whether [is already running] [the specified current process].
  105. /// </summary>
  106. /// <param name="applicationPath">The application path.</param>
  107. /// <param name="currentProcess">The current process.</param>
  108. /// <returns><c>true</c> if [is already running] [the specified current process]; otherwise, <c>false</c>.</returns>
  109. private static bool IsAlreadyRunning(string applicationPath, Process currentProcess)
  110. {
  111. var duplicate = Process.GetProcesses().FirstOrDefault(i =>
  112. {
  113. try
  114. {
  115. if (currentProcess.Id == i.Id)
  116. {
  117. return false;
  118. }
  119. }
  120. catch (Exception)
  121. {
  122. return false;
  123. }
  124. try
  125. {
  126. //_logger.Info("Module: {0}", i.MainModule.FileName);
  127. if (string.Equals(applicationPath, i.MainModule.FileName, StringComparison.OrdinalIgnoreCase))
  128. {
  129. return true;
  130. }
  131. return false;
  132. }
  133. catch (Exception)
  134. {
  135. return false;
  136. }
  137. });
  138. if (duplicate != null)
  139. {
  140. _logger.Info("Found a duplicate process. Giving it time to exit.");
  141. if (!duplicate.WaitForExit(15000))
  142. {
  143. _logger.Info("The duplicate process did not exit.");
  144. return true;
  145. }
  146. }
  147. if (!_isRunningAsService)
  148. {
  149. return IsAlreadyRunningAsService(applicationPath);
  150. }
  151. return false;
  152. }
  153. private static bool IsAlreadyRunningAsService(string applicationPath)
  154. {
  155. var serviceName = BackgroundService.GetExistingServiceName();
  156. WqlObjectQuery wqlObjectQuery = new WqlObjectQuery(string.Format("SELECT * FROM Win32_Service WHERE State = 'Running' AND Name = '{0}'", serviceName));
  157. ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher(wqlObjectQuery);
  158. ManagementObjectCollection managementObjectCollection = managementObjectSearcher.Get();
  159. foreach (ManagementObject managementObject in managementObjectCollection)
  160. {
  161. var obj = managementObject.GetPropertyValue("PathName");
  162. if (obj == null)
  163. {
  164. continue;
  165. }
  166. var path = obj.ToString();
  167. _logger.Info("Service path: {0}", path);
  168. // Need to use indexOf instead of equality because the path will have the full service command line
  169. if (path.IndexOf(applicationPath, StringComparison.OrdinalIgnoreCase) != -1)
  170. {
  171. _logger.Info("The windows service is already running");
  172. return true;
  173. }
  174. }
  175. return false;
  176. }
  177. /// <summary>
  178. /// Creates the application paths.
  179. /// </summary>
  180. /// <param name="applicationPath">The application path.</param>
  181. /// <param name="runAsService">if set to <c>true</c> [run as service].</param>
  182. /// <returns>ServerApplicationPaths.</returns>
  183. private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService)
  184. {
  185. var resourcesPath = Path.GetDirectoryName(applicationPath);
  186. if (runAsService)
  187. {
  188. var systemPath = Path.GetDirectoryName(applicationPath);
  189. var programDataPath = Path.GetDirectoryName(systemPath);
  190. return new ServerApplicationPaths(programDataPath, applicationPath, resourcesPath);
  191. }
  192. return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath, resourcesPath);
  193. }
  194. /// <summary>
  195. /// Gets a value indicating whether this instance can self restart.
  196. /// </summary>
  197. /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
  198. public static bool CanSelfRestart
  199. {
  200. get
  201. {
  202. return !_isRunningAsService;
  203. }
  204. }
  205. /// <summary>
  206. /// Gets a value indicating whether this instance can self update.
  207. /// </summary>
  208. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  209. public static bool CanSelfUpdate
  210. {
  211. get
  212. {
  213. return !_isRunningAsService;
  214. }
  215. }
  216. private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
  217. /// <summary>
  218. /// Runs the application.
  219. /// </summary>
  220. /// <param name="appPaths">The app paths.</param>
  221. /// <param name="logManager">The log manager.</param>
  222. /// <param name="runService">if set to <c>true</c> [run service].</param>
  223. /// <param name="options">The options.</param>
  224. private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options)
  225. {
  226. var fileSystem = new WindowsFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")));
  227. fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
  228. //fileSystem.AddShortcutHandler(new LnkShortcutHandler(fileSystem));
  229. var nativeApp = new WindowsApp(fileSystem, _logger)
  230. {
  231. IsRunningAsService = runService
  232. };
  233. _appHost = new ApplicationHost(appPaths,
  234. logManager,
  235. options,
  236. fileSystem,
  237. "emby.windows.zip",
  238. nativeApp);
  239. var initProgress = new Progress<double>();
  240. if (!runService)
  241. {
  242. if (!options.ContainsOption("-nosplash")) ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash"));
  243. // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
  244. SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
  245. ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
  246. }
  247. var task = _appHost.Init(initProgress);
  248. Task.WaitAll(task);
  249. task = task.ContinueWith(new Action<Task>(a => _appHost.RunStartupTasks()), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent);
  250. if (runService)
  251. {
  252. StartService(logManager);
  253. }
  254. else
  255. {
  256. Task.WaitAll(task);
  257. task = InstallVcredist2013IfNeeded(_appHost, _logger);
  258. Task.WaitAll(task);
  259. SystemEvents.SessionEnding += SystemEvents_SessionEnding;
  260. SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
  261. HideSplashScreen();
  262. ShowTrayIcon();
  263. task = ApplicationTaskCompletionSource.Task;
  264. Task.WaitAll(task);
  265. }
  266. }
  267. private static ServerNotifyIcon _serverNotifyIcon;
  268. private static TaskScheduler _mainTaskScheduler;
  269. private static void ShowTrayIcon()
  270. {
  271. //Application.EnableVisualStyles();
  272. //Application.SetCompatibleTextRenderingDefault(false);
  273. _serverNotifyIcon = new ServerNotifyIcon(_appHost.LogManager, _appHost, _appHost.ServerConfigurationManager, _appHost.LocalizationManager);
  274. _mainTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
  275. Application.Run();
  276. }
  277. private static SplashForm _splash;
  278. private static Thread _splashThread;
  279. private static void ShowSplashScreen(Version appVersion, Progress<double> progress, ILogger logger)
  280. {
  281. var thread = new Thread(() =>
  282. {
  283. _splash = new SplashForm(appVersion, progress);
  284. _splash.ShowDialog();
  285. });
  286. thread.SetApartmentState(ApartmentState.STA);
  287. thread.IsBackground = true;
  288. thread.Start();
  289. _splashThread = thread;
  290. }
  291. private static void HideSplashScreen()
  292. {
  293. if (_splash != null)
  294. {
  295. Action act = () =>
  296. {
  297. _splash.Close();
  298. _splashThread = null;
  299. };
  300. _splash.Invoke(act);
  301. }
  302. }
  303. static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
  304. {
  305. if (e.Reason == SessionSwitchReason.SessionLogon)
  306. {
  307. BrowserLauncher.OpenDashboard(_appHost);
  308. }
  309. }
  310. public static void Invoke(Action action)
  311. {
  312. if (_isRunningAsService)
  313. {
  314. action();
  315. }
  316. else
  317. {
  318. Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, _mainTaskScheduler ?? TaskScheduler.Current);
  319. }
  320. }
  321. /// <summary>
  322. /// Starts the service.
  323. /// </summary>
  324. private static void StartService(ILogManager logManager)
  325. {
  326. var service = new BackgroundService(logManager.GetLogger("Service"));
  327. service.Disposed += service_Disposed;
  328. ServiceBase.Run(service);
  329. }
  330. /// <summary>
  331. /// Handles the Disposed event of the service control.
  332. /// </summary>
  333. /// <param name="sender">The source of the event.</param>
  334. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  335. static void service_Disposed(object sender, EventArgs e)
  336. {
  337. ApplicationTaskCompletionSource.SetResult(true);
  338. OnServiceShutdown();
  339. }
  340. private static void OnServiceShutdown()
  341. {
  342. _logger.Info("Shutting down");
  343. DisposeAppHost();
  344. }
  345. /// <summary>
  346. /// Installs the service.
  347. /// </summary>
  348. private static void InstallService(string applicationPath, ILogger logger)
  349. {
  350. try
  351. {
  352. ManagedInstallerClass.InstallHelper(new[] { applicationPath });
  353. logger.Info("Service installation succeeded");
  354. }
  355. catch (Exception ex)
  356. {
  357. logger.ErrorException("Uninstall failed", ex);
  358. }
  359. }
  360. /// <summary>
  361. /// Uninstalls the service.
  362. /// </summary>
  363. private static void UninstallService(string applicationPath, ILogger logger)
  364. {
  365. try
  366. {
  367. ManagedInstallerClass.InstallHelper(new[] { "/u", applicationPath });
  368. logger.Info("Service uninstallation succeeded");
  369. }
  370. catch (Exception ex)
  371. {
  372. logger.ErrorException("Uninstall failed", ex);
  373. }
  374. }
  375. private static void RunServiceInstallationIfNeeded(string applicationPath)
  376. {
  377. var serviceName = BackgroundService.GetExistingServiceName();
  378. var ctl = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == serviceName);
  379. if (ctl == null)
  380. {
  381. RunServiceInstallation(applicationPath);
  382. }
  383. }
  384. /// <summary>
  385. /// Runs the service installation.
  386. /// </summary>
  387. private static void RunServiceInstallation(string applicationPath)
  388. {
  389. var startInfo = new ProcessStartInfo
  390. {
  391. FileName = applicationPath,
  392. Arguments = "-installservice",
  393. CreateNoWindow = true,
  394. WindowStyle = ProcessWindowStyle.Hidden,
  395. Verb = "runas",
  396. ErrorDialog = false
  397. };
  398. using (var process = Process.Start(startInfo))
  399. {
  400. process.WaitForExit();
  401. }
  402. }
  403. /// <summary>
  404. /// Runs the service uninstallation.
  405. /// </summary>
  406. private static void RunServiceUninstallation(string applicationPath)
  407. {
  408. var startInfo = new ProcessStartInfo
  409. {
  410. FileName = applicationPath,
  411. Arguments = "-uninstallservice",
  412. CreateNoWindow = true,
  413. WindowStyle = ProcessWindowStyle.Hidden,
  414. Verb = "runas",
  415. ErrorDialog = false
  416. };
  417. using (var process = Process.Start(startInfo))
  418. {
  419. process.WaitForExit();
  420. }
  421. }
  422. /// <summary>
  423. /// Handles the SessionEnding event of the SystemEvents control.
  424. /// </summary>
  425. /// <param name="sender">The source of the event.</param>
  426. /// <param name="e">The <see cref="SessionEndingEventArgs"/> instance containing the event data.</param>
  427. static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
  428. {
  429. if (e.Reason == SessionEndReasons.SystemShutdown || !_isRunningAsService)
  430. {
  431. Shutdown();
  432. }
  433. }
  434. /// <summary>
  435. /// Handles the UnhandledException event of the CurrentDomain control.
  436. /// </summary>
  437. /// <param name="sender">The source of the event.</param>
  438. /// <param name="e">The <see cref="UnhandledExceptionEventArgs"/> instance containing the event data.</param>
  439. static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  440. {
  441. var exception = (Exception)e.ExceptionObject;
  442. new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
  443. if (!_isRunningAsService)
  444. {
  445. MessageBox.Show("Unhandled exception: " + exception.Message);
  446. }
  447. if (!Debugger.IsAttached)
  448. {
  449. Environment.Exit(Marshal.GetHRForException(exception));
  450. }
  451. }
  452. /// <summary>
  453. /// Performs the update if needed.
  454. /// </summary>
  455. /// <param name="appPaths">The app paths.</param>
  456. /// <param name="logger">The logger.</param>
  457. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
  458. private static bool PerformUpdateIfNeeded(ServerApplicationPaths appPaths, ILogger logger)
  459. {
  460. // Look for the existence of an update archive
  461. var updateArchive = Path.Combine(appPaths.TempUpdatePath, "MBServer" + ".zip");
  462. if (File.Exists(updateArchive))
  463. {
  464. logger.Info("An update is available from {0}", updateArchive);
  465. // Update is there - execute update
  466. try
  467. {
  468. var serviceName = _isRunningAsService ? BackgroundService.GetExistingServiceName() : string.Empty;
  469. new ApplicationUpdater().UpdateApplication(appPaths, updateArchive, logger, serviceName);
  470. // And just let the app exit so it can update
  471. return true;
  472. }
  473. catch (Exception e)
  474. {
  475. logger.ErrorException("Error starting updater.", e);
  476. MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message));
  477. }
  478. }
  479. return false;
  480. }
  481. public static void Shutdown()
  482. {
  483. if (_isRunningAsService)
  484. {
  485. ShutdownWindowsService();
  486. }
  487. else
  488. {
  489. DisposeAppHost();
  490. ShutdownWindowsApplication();
  491. }
  492. }
  493. public static void Restart()
  494. {
  495. DisposeAppHost();
  496. if (!_isRunningAsService)
  497. {
  498. //_logger.Info("Hiding server notify icon");
  499. //_serverNotifyIcon.Visible = false;
  500. _logger.Info("Starting new instance");
  501. //Application.Restart();
  502. Process.Start(_appHost.ServerConfigurationManager.ApplicationPaths.ApplicationPath);
  503. ShutdownWindowsApplication();
  504. }
  505. }
  506. private static void DisposeAppHost()
  507. {
  508. if (!_appHostDisposed)
  509. {
  510. _logger.Info("Disposing app host");
  511. _appHostDisposed = true;
  512. _appHost.Dispose();
  513. }
  514. }
  515. private static void ShutdownWindowsApplication()
  516. {
  517. //_logger.Info("Calling Application.Exit");
  518. //Application.Exit();
  519. _logger.Info("Calling Environment.Exit");
  520. Environment.Exit(0);
  521. _logger.Info("Calling ApplicationTaskCompletionSource.SetResult");
  522. ApplicationTaskCompletionSource.SetResult(true);
  523. }
  524. private static void ShutdownWindowsService()
  525. {
  526. _logger.Info("Stopping background service");
  527. var service = new ServiceController(BackgroundService.GetExistingServiceName());
  528. service.Refresh();
  529. if (service.Status == ServiceControllerStatus.Running)
  530. {
  531. service.Stop();
  532. }
  533. }
  534. private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger)
  535. {
  536. try
  537. {
  538. var version = ImageMagickEncoder.GetVersion();
  539. return;
  540. }
  541. catch (Exception ex)
  542. {
  543. logger.ErrorException("Error loading ImageMagick", ex);
  544. }
  545. try
  546. {
  547. await InstallVcredist2013().ConfigureAwait(false);
  548. }
  549. catch (Exception ex)
  550. {
  551. logger.ErrorException("Error installing Visual Studio C++ runtime", ex);
  552. }
  553. }
  554. private async static Task InstallVcredist2013()
  555. {
  556. var httpClient = _appHost.HttpClient;
  557. var tmp = await httpClient.GetTempFile(new HttpRequestOptions
  558. {
  559. Url = GetVcredist2013Url(),
  560. Progress = new Progress<double>()
  561. }).ConfigureAwait(false);
  562. var exePath = Path.ChangeExtension(tmp, ".exe");
  563. File.Copy(tmp, exePath);
  564. var startInfo = new ProcessStartInfo
  565. {
  566. FileName = exePath,
  567. CreateNoWindow = true,
  568. WindowStyle = ProcessWindowStyle.Hidden,
  569. Verb = "runas",
  570. ErrorDialog = false
  571. };
  572. _logger.Info("Running {0}", startInfo.FileName);
  573. using (var process = Process.Start(startInfo))
  574. {
  575. process.WaitForExit();
  576. }
  577. }
  578. private static string GetVcredist2013Url()
  579. {
  580. if (Environment.Is64BitProcess)
  581. {
  582. return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x64.exe";
  583. }
  584. // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_arm.exe
  585. return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x86.exe";
  586. }
  587. /// <summary>
  588. /// Sets the error mode.
  589. /// </summary>
  590. /// <param name="uMode">The u mode.</param>
  591. /// <returns>ErrorModes.</returns>
  592. [DllImport("kernel32.dll")]
  593. static extern ErrorModes SetErrorMode(ErrorModes uMode);
  594. /// <summary>
  595. /// Enum ErrorModes
  596. /// </summary>
  597. [Flags]
  598. public enum ErrorModes : uint
  599. {
  600. /// <summary>
  601. /// The SYSTE m_ DEFAULT
  602. /// </summary>
  603. SYSTEM_DEFAULT = 0x0,
  604. /// <summary>
  605. /// The SE m_ FAILCRITICALERRORS
  606. /// </summary>
  607. SEM_FAILCRITICALERRORS = 0x0001,
  608. /// <summary>
  609. /// The SE m_ NOALIGNMENTFAULTEXCEPT
  610. /// </summary>
  611. SEM_NOALIGNMENTFAULTEXCEPT = 0x0004,
  612. /// <summary>
  613. /// The SE m_ NOGPFAULTERRORBOX
  614. /// </summary>
  615. SEM_NOGPFAULTERRORBOX = 0x0002,
  616. /// <summary>
  617. /// The SE m_ NOOPENFILEERRORBOX
  618. /// </summary>
  619. SEM_NOOPENFILEERRORBOX = 0x8000
  620. }
  621. }
  622. }