CryptoSys API Library Manual

API_ErrorLookup

Retrieves the error message associated with a given error code.

VB6/VBA Syntax

Public Declare Function API_ErrorLookup Lib "diCryptoSys.dll" (ByVal strOutput As String, ByVal nMaxChars As Long, ByVal nErrorCode As Long) As Long

nRet = API_ErrorLookup(strOutput, nMaxChars, nErrorCode)

Parameters

strOutput
[out] String to receive error message.
nMaxChars
[in] Long specifying the maximum number of characters to be received.
nErrorCode
[in] Long specifying the error code for which the message is required.

C/C++ Syntax

long _stdcall API_ErrorLookup(char *szOutput, long nMsgLen, long nErrCode);

Returns (VB6/C)

Long: the number of characters in the output string or zero if there is no corresponding error message.

.NET Equivalent

General.ErrorLookup Method

Remarks

The error message will never be longer than 127 characters.

Example

The Visual Basic apiErrorLookup wrapper function is in the VB declaration module.

Public Function apiErrorLookup(nCode As Long) As String
' Returns a string with the error message for code nCode
    Dim strMsg As String
    Dim nRet As Long
    
    strMsg = String(128, " ")
    nRet = API_ErrorLookup(strMsg, Len(strMsg), nCode)
    apiErrorLookup = Left(strMsg, nRet)
End Function

To use:

Dim nErrCode As Long
nErrCode = 33
Debug.Print "ErrorLookup(" & nErrCode & ")=" & apiErrorLookup(nErrCode)
ErrorLookup(33)=Invalid key length (BAD_KEY_LEN_ERROR)

To display all possible error messages:

    Dim nRet As Long
    Dim strErrMsg As String * 128
    Dim i As Integer
    
    For i = 0 To 10000
        nRet = API_ErrorLookup(strErrMsg, Len(strErrMsg), i)
        If (nRet > 0) Then
            Debug.Print i & " = " & Left(strErrMsg, nRet)
        End If
    Next

See Also

Error codes

[Contents] [Index]

[HOME]   [NEXT: API_LicenceType...]

Copyright © 2001-11 D.I. Management Services Pty Ltd. All rights reserved.