EventSourceCreationData.MachineName プロパティ
アセンブリ: System (system.dll 内)
構文Dim instance As EventSourceCreationData Dim value As String value = instance.MachineName instance.MachineName = value
/** @property */ public String get_MachineName () /** @property */ public void set_MachineName (String value)
イベント ソースを登録するシステムの名前。既定値はローカル コンピュータ (".") です。
例外
解説MachineName 値を空の文字列にすることはできません。コンピュータ名を明示的に設定しなかった場合は、既定によりローカル コンピュータ (".") が設定されます。
ソースをリモート コンピュータに登録する場合、十分なアクセス許可を使用してレジストリ値を書き込むには、そのコンピュータの管理者権限が必要です。
使用例コマンド ライン引数からイベント ソースの構成プロパティを設定するコード例を次に示します。入力引数は、イベント ソース名、イベント ログ名、コンピュータ名、およびイベント メッセージ リソース ファイルを指定します。このコード例は、EventSourceCreationData クラスのトピックで取り上げているコード例の一部分です。
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
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"; }
EventSourceCreationData ^ mySourceData = gcnew EventSourceCreationData( "","" ); bool registerSource = true; // Process input parameters. if ( args->Length > 1 ) { // Require at least the source name. mySourceData->Source = args[ 1 ]; if ( args->Length > 2 ) { mySourceData->LogName = args[ 2 ]; } if ( args->Length > 3 ) { mySourceData->MachineName = args[ 3 ]; } if ( (args->Length > 4) && (args[ 4 ]->Length > 0) ) { mySourceData->MessageResourceFile = args[ 4 ]; } } 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"; }
.NET Framework のセキュリティ
プラットフォームWindows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- EventSourceCreationData.MachineName プロパティのページへのリンク