| [DllImport("Kernel32.dll")] |
| public static extern int FormatMessage(int flags, IntPtr source, int messageId, int languageId, StringBuilder |
| buffer, int size, IntPtr arguments ); |
|
|
| // You can call FormatMessage to get a descriptive error message |
| StringBuilder sbFormatMessage = new StringBuilder(1024); |
| retVal = Interop.FormatMessage(Interop.FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, Marshal.GetLastWin32Error(), 0, sbFormatMessage, |
| sbFormatMessage.Capacity, IntPtr.Zero); |
|
Download C# sample, formatmessage.zip Download VB.NET sample, formatmessage_VB.zip |