EventSourceCreationData.MachineName プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
イベント ソースを登録するコンピューターの名前を取得または設定します。
public:
property System::String ^ MachineName { System::String ^ get(); void set(System::String ^ value); };
public string MachineName { get; set; }
member this.MachineName : string with get, set
Public Property MachineName As String
プロパティ値
イベント ソースを登録するシステムの名前。 既定値はローカル コンピューター (".") です。
例外
コンピューター名が無効です。
例
次のコード例では、コマンド ライン引数からイベント ソースの構成プロパティを設定します。 入力引数は、イベント ソース名、イベント ログ名、コンピューター名、およびイベント メッセージ リソース ファイルを指定します。 この例は、 EventSourceCreationData クラスに提供されるより大きな例の一部です。
EventSourceCreationData mySourceData = new EventSourceCreationData("", "");
bool registerSource = true;
// Process input parameters.
if (args.Length > 0)
{
// Require at least the source name.
mySourceData.Source = args[0];
if (args.Length > 1)
{
mySourceData.LogName = args[1];
}
if (args.Length > 2)
{
mySourceData.MachineName = args[2];
}
if ((args.Length > 3) && (args[3].Length > 0))
{
mySourceData.MessageResourceFile = args[3];
}
}
else
{
// Display a syntax help message.
Console.WriteLine("Input:");
Console.WriteLine(" source [event log] [machine name] [resource file]");
registerSource = false;
}
// Set defaults for parameters missing input.
if (mySourceData.MachineName.Length == 0)
{
// Default to the local computer.
mySourceData.MachineName = ".";
}
if (mySourceData.LogName.Length == 0)
{
// Default to the Application log.
mySourceData.LogName = "Application";
}
Dim mySourceData As EventSourceCreationData = new EventSourceCreationData("", "")
Dim registerSource As Boolean = True
' Process input parameters.
If args.Length > 0
' Require at least the source name.
mySourceData.Source = args(0)
If args.Length > 1
mySourceData.LogName = args(1)
End If
If args.Length > 2
mySourceData.MachineName = args(2)
End If
If args.Length > 3 AndAlso args(3).Length > 0
mySourceData.MessageResourceFile = args(3)
End If
Else
' Display a syntax help message.
Console.WriteLine("Input:")
Console.WriteLine(" source [event log] [machine name] [resource file]")
registerSource = False
End If
' Set defaults for parameters missing input.
If mySourceData.MachineName.Length = 0
' Default to the local computer.
mySourceData.MachineName = "."
End If
If mySourceData.LogName.Length = 0
' Default to the Application log.
mySourceData.LogName = "Application"
End If
注釈
MachineName値を空の文字列にすることはできません。 マシン名が明示的に設定されていない場合、既定ではローカル コンピューター (".") になります。
リモート コンピューターにソースを登録する場合、十分なアクセス許可を持つレジストリ値を書き込むには、そのコンピューターに対する管理者権限が必要です。