次の方法で共有


InstallContext.IsParameterTrue メソッド

指定したコマンド ライン パラメータが true かどうかを確認します。

Public Function IsParameterTrue( _
   ByVal paramName As String _) As Boolean
[C#]
public bool IsParameterTrue(stringparamName);
[C++]
public: bool IsParameterTrue(String* paramName);
[JScript]
public function IsParameterTrue(
   paramName : String) : Boolean;

パラメータ

  • paramName
    確認対象のコマンド ライン パラメータの名前。

戻り値

指定したパラメータが "yes"、"true"、"1"、または空の文字列 ("") の場合は true 。それ以外の場合は false

解説

このメソッドは、コマンド ライン パラメータを解析した結果が格納される Parameters プロパティにアクセスして、指定したパラメータが true かどうかを判断します。

使用例

[Visual Basic, C#, C++] InstallContext クラスのクラス概要に示されているサンプルの抜粋を次に示します。

[Visual Basic, C#, C++] このサンプルでは、 LogtoConsole パラメータが設定されているかどうかを確認するために、 IsParameterTrue メソッドを使用します。 yes の場合、これは LogMessage メソッドを使用してステータス メッセージをインストール ログ ファイルとコンソールに書き込みます。

 
' 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

[C#] 
// 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" );
}

[C++] 
// Check whether the "LogtoConsole" parameter has been set.
if (myInstallContext->IsParameterTrue(S"LogtoConsole")) {
    // Display the message to the console and add it to the logfile.
    myInstallContext->LogMessage(S"The 'Install' method has been called");
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

InstallContext クラス | InstallContext メンバ | System.Configuration.Install 名前空間 | Parameters