/// <summary> /// スタートアップの有効状態を変更 /// </summary> /// <param name="startup_register_place">スタートアップの登録場所</param> /// <param name="register_name">登録名</param> /// <param name="effective_state">有効状態</param> /// <exception cref="FreeEcho.FEStartupControl.ChangeEffectiveStateStartupException"></exception> public static void ChangeEffectiveState( StartupRegisterPlace startup_register_place, string register_name, bool effective_state ) { try { RegistryHivePath registry_hive_path = null; string extension = null; // 拡張子 switch (startup_register_place) { case StartupRegisterPlace.FolderLogonUser: registry_hive_path = StartupRegistryHidePath.DisabledFolderLogonUser(); extension = ".lnk"; break; case StartupRegisterPlace.FolderAllUser: registry_hive_path = StartupRegistryHidePath.DisabledFolderAllUser(); extension = ".lnk"; break; case StartupRegisterPlace.RegistryLogonUser: registry_hive_path = StartupRegistryHidePath.DisabledRegistryLogonUser(); break; case StartupRegisterPlace.RegistryAllUser: registry_hive_path = StartupRegistryHidePath.DisabledRegistryAllUser(); break; case StartupRegisterPlace.RegistryAllUser32Bit: registry_hive_path = StartupRegistryHidePath.DisabledRegistryAllUser32Bit(); break; } using (Microsoft.Win32.RegistryKey base_registry_key = Microsoft.Win32.RegistryKey.OpenBaseKey(registry_hive_path.RegistryHive, Microsoft.Win32.RegistryView.Default)) { using (Microsoft.Win32.RegistryKey sub_registry_key = base_registry_key.CreateSubKey(registry_hive_path.Path)) { sub_registry_key.SetValue(register_name + extension, effective_state ? new byte[] { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } : new byte[] { 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, Microsoft.Win32.RegistryValueKind.Binary); } } } catch { throw new ChangeEffectiveStateStartupException(); } }
/// <summary> /// キャンセルされているスタートアップを取得 /// </summary> /// <param name="startup_information">スタートアップ情報</param> private static void GetCancelStartup( ref System.Collections.Generic.List <StartupInformation> startup_information ) { GetDesignationCancelStartup(ref startup_information, StartupRegisterPlace.FolderLogonUser, StartupRegistryHidePath.DisabledFolderLogonUser()); GetDesignationCancelStartup(ref startup_information, StartupRegisterPlace.FolderAllUser, StartupRegistryHidePath.DisabledFolderAllUser()); GetDesignationCancelStartup(ref startup_information, StartupRegisterPlace.RegistryLogonUser, StartupRegistryHidePath.DisabledRegistryLogonUser()); if (System.Environment.Is64BitProcess) { GetDesignationCancelStartup(ref startup_information, StartupRegisterPlace.RegistryAllUser, StartupRegistryHidePath.DisabledRegistryAllUser()); GetDesignationCancelStartup(ref startup_information, StartupRegisterPlace.RegistryAllUser32Bit, StartupRegistryHidePath.DisabledRegistryAllUser32Bit()); } }