Redigera

Dela via


InstallContext.IsParameterTrue(String) Method

Definition

Determines whether the specified command-line parameter is 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

Parameters

paramName
String

The name of the command-line parameter to check.

Returns

true if the specified parameter is set to "yes", "true", "1", or an empty string (""); otherwise, false.

Examples

This example is an excerpt of the sample in the class overview of the InstallContext class.

It uses the IsParameterTrue method to find out if the LogtoConsole parameter has been set. If yes, it will then use the LogMessage method to write status messages to the installation log file and the console.

// 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" ) == true )
{
   // 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

Remarks

This method accesses the Parameters property, which contains a parsed version of the command-line parameters, to determine whether the specified parameter is true.

Applies to

See also