devxlogo

SystemErrorDescription – Convert an API error code to a string

SystemErrorDescription – Convert an API error code to a string

Private Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" _    (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, _    ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, _    Arguments As Long) As LongPrivate Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000' Convert an API error number to a descriptive string'' If any error it returns an empty string, in which case' the Err.LastDllError property can be use to retrieve' extended error informationFunction SystemErrorDescription(ByVal ErrCode As Long) As String    Dim buffer As String * 1024    Dim ret As Long    ' return value is the length of the result message    ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, ErrCode, 0, buffer, _        Len(buffer), 0)    SystemErrorDescription = Left$(buffer, ret)End Function

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist