Desktop Functions: Smart Device Functions:
|
Search Results for "FormatMessage" in [All]netapi32
static string FormatMessage(int errCode)
Console.WriteLine(FormatMessage(errCode)); kernel32
static extern uint FormatMessage(uint dwFlags, IntPtr lpSource,
static extern uint FormatMessage( uint dwFlags, IntPtr lpSource,
static extern uint FormatMessage( uint dwFlags, IntPtr lpSource,
static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, [Out] StringBuilder lpBuffer, uint nSize, string[] Arguments);
<DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=CharSet.Unicode, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByRef lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As [String], ByVal nSize As Integer, ByRef Arguments As IntPtr) As Integer
<DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=CharSet.Unicode, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, <MarshalAs(UnmanageType.LPWStr)> ByRef lpBuffer As String, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer
<DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=CharSet.Unicode, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As StringBuilder, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer To have FormatMessage substitute %1, %2, etc. with arguments you pass it, declare FormatMessage with a string[] for the last parameter and just pass a normal C# string array. You need to include FORMAT_MESSAGE_ARGUMENT_ARRAY in the dwFlags parameter for this to work. If you are trying use FormatMessage to "decode" an error from Marshal.GetLastWin32Error, go take a look at Marshal.ThrowExceptionForHR (http://msdn.microsoft.com/en-us/library/ckxcyk36(v=VS.80).aspx).
uint dwChars= FormatMessage(
uint length = FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, formatPtr, 0, 0, msgBuilder, 101, formatArgs);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, (uint)Marshal.GetLastWin32Error(), 0, msgBuilder, 101, null);
static extern uint FormatMessage(uint dwFlags, IntPtr lpSource,
static extern uint FormatMessage( uint dwFlags, IntPtr lpSource,
static extern uint FormatMessage( uint dwFlags, IntPtr lpSource,
static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, [Out] StringBuilder lpBuffer, uint nSize, string[] Arguments);
<DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=CharSet.Unicode, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByRef lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As [String], ByVal nSize As Integer, ByRef Arguments As IntPtr) As Integer
<DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=CharSet.Unicode, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, <MarshalAs(UnmanageType.LPWStr)> ByRef lpBuffer As String, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer
<DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=CharSet.Unicode, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As StringBuilder, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer To have FormatMessage substitute %1, %2, etc. with arguments you pass it, declare FormatMessage with a string[] for the last parameter and just pass a normal C# string array. You need to include FORMAT_MESSAGE_ARGUMENT_ARRAY in the dwFlags parameter for this to work. If you are trying use FormatMessage to "decode" an error from Marshal.GetLastWin32Error, go take a look at Marshal.ThrowExceptionForHR (http://msdn.microsoft.com/en-us/library/ckxcyk36(v=VS.80).aspx).
uint dwChars= FormatMessage(
uint length = FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, formatPtr, 0, 0, msgBuilder, 101, formatArgs);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, (uint)Marshal.GetLastWin32Error(), 0, msgBuilder, 101, null);
<System.Runtime.InteropServices.DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=System.Runtime.InteropServices.CharSet.Unicode)>
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByRef lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As IntPtr, ByVal nSize As Integer, ByRef Arguments As IntPtr) As Integer
Dim dwChars As Integer = FormatMessage(Format_Message.FORMAT_MESSAGE_ALLOCATE_BUFFER Or Format_Message.FORMAT_MESSAGE_FROM_SYSTEM Or Format_Message.FORMAT_MESSAGE_IGNORE_INSERTS, 4: GetLastError To retrieve the error message corresponding to this error code, you can use the [Win32Exception] class, as explained in the FormatMessage page (look at the bottom of the page). advapi325: RegOpenKey If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error. 6: RegOpenKeyEx If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error. misc7: FAQ
coredll
[DllImport("coredll", EntryPoint = "FormatMessageW", SetLastError = true)]
private static extern int FormatMessage(FormatMessageFlags dwFlags, IntPtr lpSource,
Declare Function FormatMessageW Lib "coredll.dll" (TODO) As TODO See http://msdn2.microsoft.com/en-us/library/ms679351.aspx for details on the FormatMessage native method.
[DllImport("coredll", EntryPoint = "FormatMessageW", SetLastError = true)]
private static extern int FormatMessage(FormatMessageFlags dwFlags, IntPtr lpSource,
public enum FormatMessageFlags : int
if (FormatMessage(FormatMessageFlags.FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, win32ErrorCode, 0, sbMsg, sbMsg.Capacity, null) != 0) |