InstallContext.IsParameterTrue(String) Metod

Definition

Avgör om den angivna kommandoradsparametern är true.

public:
 bool IsParameterTrue(System::String ^ paramName);
public bool IsParameterTrue(string paramName);
member this.IsParameterTrue : string -> bool
Public Function IsParameterTrue (paramName As String) As Boolean

Parametrar

paramName
String

Namnet på kommandoradsparametern som ska kontrolleras.

Returer

trueom den angivna parametern är inställd på "ja", "true", "1" eller en tom sträng (""); annars . false

Exempel

Det här exemplet är ett utdrag ur exemplet i klassöversikten för InstallContext klassen.

Den använder IsParameterTrue metoden för att ta reda på om parametern LogtoConsole har angetts. Om yesanvänder LogMessage den sedan metoden för att skriva statusmeddelanden till installationsloggfilen och konsolen.

// Check whether the "LogtoConsole" parameter has been set.
if ( myInstallContext->IsParameterTrue( "LogtoConsole" ) )
{
   // Display the message to the console and add it to the logfile.
   myInstallContext->LogMessage( "The 'Install' method has been called" );
}
// Check whether the "LogtoConsole" parameter has been set.
if ( myInstallContext.IsParameterTrue( "LogtoConsole" ))
{
   // Display the message to the console and add it to the logfile.
   myInstallContext.LogMessage( "The 'Install' method has been called" );
}
' Check wether the "LogtoConsole" parameter has been set.
If myInstallContext.IsParameterTrue("LogtoConsole") = True Then
   ' Display the message to the console and add it to the logfile.
   myInstallContext.LogMessage("The 'Install' method has been called")
End If

Kommentarer

Den här metoden kommer Parameters åt egenskapen, som innehåller en tolkad version av kommandoradsparametrarna, för att avgöra om den angivna parametern är true.

Gäller för

Se även