Win32Exceptionとは? わかりやすく解説

Win32Exception クラス

Win32 エラー コードの例外がスローされます。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<SerializableAttribute> _
Public Class Win32Exception
    Inherits ExternalException
    Implements ISerializable
Dim instance As Win32Exception
[SerializableAttribute] 
public class Win32Exception : ExternalException,
 ISerializable
[SerializableAttribute] 
public ref class Win32Exception : public
 ExternalException, ISerializable
/** @attribute SerializableAttribute() */ 
public class Win32Exception extends ExternalException
 implements ISerializable
SerializableAttribute 
public class Win32Exception extends
 ExternalException implements ISerializable
解説解説
使用例使用例

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.Object
   System.Exception
     System.SystemException
       System.Runtime.InteropServices.ExternalException
        System.ComponentModel.Win32Exception
           System.Net.HttpListenerException
           System.Net.NetworkInformation.NetworkInformationException
           System.Net.Sockets.SocketException
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Win32Exception コンストラクタ ()

最後に発生した Win32 エラーを使用して、Win32Exception クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Dim instance As New Win32Exception
public Win32Exception ()
public:
Win32Exception ()
public Win32Exception ()
public function Win32Exception ()
解説解説
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Win32Exception コンストラクタ (Int32)

指定したエラーを使用して、Win32Exception クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

public Win32Exception (
    int error
)
public:
Win32Exception (
    int error
)
public Win32Exception (
    int error
)
public function Win32Exception (
    error : int
)

パラメータ

error

この例外に関連付けられている Win32 エラー コード。

解説解説
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Win32Exception コンストラクタ (Int32, String)

指定したエラーと詳細説明を使用して、Win32Exception クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

解説解説
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Win32Exception コンストラクタ (SerializationInfo, StreamingContext)

指定したコンテキスト情報とシリアル化情報で、Win32Exception クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
Dim info As SerializationInfo
Dim context As StreamingContext

Dim instance As New Win32Exception(info,
 context)
protected Win32Exception (
    SerializationInfo info,
    StreamingContext context
)
protected:
Win32Exception (
    SerializationInfo^ info, 
    StreamingContext context
)
protected Win32Exception (
    SerializationInfo info, 
    StreamingContext context
)
protected function Win32Exception (
    info : SerializationInfo, 
    context : StreamingContext
)

パラメータ

info

この例外に関連付けられた SerializationInfo。

context

この例外のコンテキストを表す StreamingContext オブジェクト。

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Win32Exception コンストラクタ (String)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

詳細説明を指定して、Win32Exception クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Win32Exception コンストラクタ (String, Exception)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

詳細説明と例外を指定して、Win32Exception クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    message As String, _
    innerException As Exception _
)
Dim message As String
Dim innerException As Exception

Dim instance As New Win32Exception(message,
 innerException)
public Win32Exception (
    string message,
    Exception innerException
)
public:
Win32Exception (
    String^ message, 
    Exception^ innerException
)
public Win32Exception (
    String message, 
    Exception innerException
)
public function Win32Exception (
    message : String, 
    innerException : Exception
)

パラメータ

message

エラーの詳細説明。

innerException

この例外の原因である内部例外への参照。

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Win32Exception コンストラクタ


Win32Exception プロパティ


パブリック プロパティパブリック プロパティ

プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ HResult  特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。 ( Exception から継承されます。)
参照参照

関連項目

Win32Exception クラス
System.ComponentModel 名前空間

Win32Exception メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Win32Exception クラス
System.ComponentModel 名前空間

Win32Exception メンバ

Win32 エラー コードの例外がスローされます。

Win32Exception データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
プロテクト コンストラクタプロテクト コンストラクタ
パブリック プロパティパブリック プロパティ
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ HResult  特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。(Exception から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Win32Exception クラス
System.ComponentModel 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「Win32Exception」の関連用語

Win32Exceptionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Win32Exceptionのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS