メッセージをコンソールとインストール ログ ファイルに書き込みます。
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