Win32Exception クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ Public Class Win32Exception Inherits ExternalException Implements ISerializable

Win32 エラー コードは、表示されるときに数値表現からシステム メッセージへと変換されます。この例外に関連付けられているエラー コードの数値表現にアクセスするには、NativeErrorCode を使用します。エラー コードの詳細については、http://msdn.microsoft.com のプラットフォーム SDK ドキュメントで「Win32 Error Codes」を参照してください。
![]() |
---|
このクラスに適用される HostProtectionAttribute 属性の Resources プロパティの値は、SharedState です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的には、アイコンをダブルクリック、コマンドを入力、またはブラウザに URL を入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。 |

Win32 の例外をキャッチし、その内容を解釈する方法を次のコード例に示します。この例では、存在しない実行可能ファイルを起動するため、Win32 の例外が発生します。例外をキャッチしたときに、この例では、それぞれのエラー メッセージ、エラー コード、および例外の発生源をフェッチします。
Try Dim myProc As New System.Diagnostics.Process() myProc.StartInfo.FileName = "c:\nonexist.exe" 'Attempting to start a non-existing executable myProc.Start() 'Start the application and assign it to the process component. Catch w As System.ComponentModel.Win32Exception Console.WriteLine(w.Message) Console.WriteLine(w.ErrorCode.ToString()) Console.WriteLine(w.NativeErrorCode.ToString()) Console.WriteLine(w.StackTrace) Console.WriteLine(w.Source) Dim e As New Exception() e = w.GetBaseException() Console.WriteLine(e.Message) End Try
try { System.Diagnostics.Process myProc = new System.Diagnostics.Process(); myProc.StartInfo.FileName = "c:\nonexist.exe"; //Attempting to start a non-existing executable myProc.Start(); //Start the application and assign it to the process component. } catch(Win32Exception w) { Console.WriteLine(w.Message); Console.WriteLine(w.ErrorCode.ToString()); Console.WriteLine(w.NativeErrorCode.ToString()); Console.WriteLine(w.StackTrace); Console.WriteLine(w.Source); Exception e=w.GetBaseException(); Console.WriteLine(e.Message); }
try { System::Diagnostics::Process^ myProc = gcnew System::Diagnostics::Process; //Attempting to start a non-existing executable myProc->StartInfo->FileName = "c:\nonexist.exe"; //Start the application and assign it to the process component. myProc->Start(); } catch ( Win32Exception^ w ) { Console::WriteLine( w->Message ); Console::WriteLine( w->ErrorCode ); Console::WriteLine( w->NativeErrorCode ); Console::WriteLine( w->StackTrace ); Console::WriteLine( w->Source ); Exception^ e = w->GetBaseException(); Console::WriteLine( e->Message ); }

System.Exception
System.SystemException
System.Runtime.InteropServices.ExternalException
System.ComponentModel.Win32Exception
System.Net.HttpListenerException
System.Net.NetworkInformation.NetworkInformationException
System.Net.Sockets.SocketException


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からWin32Exception クラスを検索する場合は、下記のリンクをクリックしてください。

- Win32Exception クラスのページへのリンク