次の方法で共有


InstallContext.LogMessage メソッド

メッセージをコンソールとインストール ログ ファイルに書き込みます。

Public Sub LogMessage( _
   ByVal message As String _)
[C#]
public void LogMessage(stringmessage);
[C++]
public: void LogMessage(String* message);
[JScript]
public function LogMessage(
   message : String);

パラメータ

  • message
    書き込むメッセージ。

解説

インストーラは、このメソッドを呼び出して、進行状況などのステータス情報をログ ファイルに書き込むことができます。コマンド ライン パラメータでユーザー インターフェイスを表示するように指定されている場合、インストーラは LogMessage メソッドを呼び出すだけでなく、メッセージ ボックスを表示したりクエリを実行したりする必要もあります。インストールの実行に InstallUtil.exe が使用され、コマンド ラインで "/LogToConsole= 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