Win32Exception Class

If you ever used Win32 API calls, you know that in case of an error, you have to retrieve the error code by calling the System.Runtime.InteropServices.Marshal.GetLastWin32Error function. What you get though, is only the error number, not the description.

You can get access to Win32Error descriptions with System.ComponentModel.Win32Exception class.

Sample Code

Dim error As Integer = System.Runtime.InteropServices.Marshal.GetLastWin32Error()
Dim msg as String = New System.ComponentModel.Win32Exception(error).Message