InstallContext.IsParameterTrue(String) 方法

定義

判斷指定的命令列參數是否為 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

參數

paramName
String

要檢查的命令列參數名稱。

傳回

如果指定的參數設定為「yes」、「true」、「1」或空字串 (""),則為 true,否則為 false

範例

此範例是 類別概觀中範例的 InstallContext 摘錄。

它會使用 IsParameterTrue 方法來找出是否已 LogtoConsole 設定 參數。 如果 yes為,則會使用 方法將 LogMessage 狀態消息寫入安裝記錄檔和控制台。

// 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

備註

這個方法會 Parameters 存取 屬性,其中包含已剖析的命令行參數版本,以判斷指定的參數是否為 true

適用於

另請參閱