Interaction.DeleteSetting(String, String, String) Método

Definição

Exclui uma seção ou uma configuração de chave da entrada de um aplicativo no Registro do Windows.Deletes a section or key setting from an application's entry in the Windows registry. O recurso My oferece melhor produtividade e desempenho em operações do Registro do que a função DeleteSetting.The My feature gives you greater productivity and performance in registry operations than the DeleteSetting function. Para obter mais informações, consulte Registry.For more information, see Registry .

[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static void DeleteSetting (string AppName, string? Section = default, string? Key = default);
public static void DeleteSetting (string AppName, string Section = default, string Key = default);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member DeleteSetting : string * string * string -> unit
static member DeleteSetting : string * string * string -> unit
Public Sub DeleteSetting (AppName As String, Optional Section As String = Nothing, Optional Key As String = Nothing)

Parâmetros

AppName
String

Obrigatórios.Required. Expressão String que contém o nome do aplicativo ou do projeto ao qual a seção ou configuração de chave se aplica.String expression containing the name of the application or project to which the section or key setting applies.

Section
String

Obrigatórios.Required. Expressão String que contém o nome da seção da qual a configuração de chave está sendo excluída.String expression containing the name of the section from which the key setting is being deleted. Se apenas AppName e Section forem fornecidos, a seção especificada será excluída juntamente com todas as configurações de chave relacionadas.If only AppName and Section are provided, the specified section is deleted along with all related key settings.

Key
String

Opcional.Optional. Expressão String que contém o nome da configuração de chave que está sendo excluída.String expression containing the name of the key setting being deleted.

Atributos

Exceções

O usuário não está conectado.User is not logged in.

Exemplos

O exemplo a seguir primeiro usa o SaveSetting procedimento para fazer entradas no registro do Windows para o MyApp aplicativo e, em seguida, usa a DeleteSetting função para removê-las.The following example first uses the SaveSetting procedure to make entries in the Windows registry for the MyApp application, and then uses the DeleteSetting function to remove them. Como nenhum Key argumento é especificado, a Startup seção inteira é excluída, incluindo o nome da seção e todas as suas chaves.Because no Key argument is specified, the whole Startup section is deleted, including the section name and all of its keys.

' Place some settings in the registry.
SaveSetting("MyApp", "Startup", "Top", "75")
SaveSetting("MyApp", "Startup", "Left", "50")
' Remove section and all its settings from registry.
DeleteSetting("MyApp", "Startup")
' Remove MyApp from the registry.
DeleteSetting("MyApp")

Comentários

Se todos os argumentos forem fornecidos, a configuração especificada será excluída.If all arguments are provided, the specified setting is deleted. Ocorrerá um erro em tempo de execução se você tentar usar DeleteSetting em uma seção ou configuração de chave inexistente.A run-time error occurs if you attempt to use DeleteSetting on a nonexistent section or key setting.

DeleteSetting requer que um usuário esteja conectado, pois ele funciona na HKEY_LOCAL_USER chave do registro, que não está ativa até que um usuário faça logon interativamente.DeleteSetting requires that a user be logged on since it operates under the HKEY_LOCAL_USER registry key, which is not active until a user logs on interactively.

As configurações do registro que devem ser acessadas de um processo não interativo (como Mtx.exe) devem ser armazenadas sob as HKEY_LOCAL_MACHINE\Software\ HKEY_USER\DEFAULT\Software chaves do registro ou.Registry settings that are to be accessed from a non-interactive process (such as Mtx.exe) should be stored under either the HKEY_LOCAL_MACHINE\Software\ or the HKEY_USER\DEFAULT\Software registry keys.

Aplica-se a

Confira também