Desktop Functions: Smart Device Functions:
|
FormatMessage (kernel32)
C# Signature:
[DllImport("kernel32.dll")] VB.Net Signature:
<DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, _ User-Defined Types:None. Notes:DO NOT P/Invoke FormatMessage ever! You are not guaranteed to get the correct error message. The reason is that several internal .NET Framework calls call onto Win32 API's which can reset the Last error. You MUST use the Win32Exception and Marshal.GetLastWin32Error as shown below. Tips & Tricks:This functionality is also given by System.ComponentModel.Win32Exception:
string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message; Or in VB
Dim errorMessage As String = New Win32Exception(Err.LastDllError).Message Sample Code:Please add some! Alternative Managed API:Do you know one? Please contribute it! Please edit this page!Do you have...
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more). |
|