CryptoSys PKI Toolkit Manual

PKI_ErrorLookup

Retrieves the error message associated with a given error code.

VB6/VBA Syntax

Public Declare Function PKI_ErrorLookup Lib "diCrPKI.dll" (ByVal strErrMsg As String, ByVal nMaxMsgLen As Long, ByVal nErrorCode As Long) As Long

nRet = PKI_LastError(strErrMsg, nMaxMsgLen)

Parameters

strErrMsg
[out] String to receive error message.
nMaxMsgLen
[in] Long specifying the maximum length of the string to be copied.
nErrorCode
[in] Long specifying the error code for which the message is required.

C/C++ Syntax

long _stdcall PKI_ErrorLookup(char *szErrMsg, long nMsgLen, long nErrCode);

Returns (VB6/C)

Long: The number of characters that have been set in strErrMsg. If the function is called with nMaxMsgLen set to zero or strErrMsg as NULL, the return value is the number of characters in the error message.

.NET Equivalent

General.ErrorLookup Method

Remarks

The error message will never be longer than 127 characters.

Example

    Dim nLen As Long
    Dim nErrCode As Long
    Dim strErrMsg As String * 128
    
    nErrCode = 25
    nLen = PKI_ErrorLookup(strErrMsg, Len(strErrMsg), nErrCode)
    Debug.Print "ErrorLookup(" & nErrCode & ")=" & Left(strErrMsg, nLen)

This should return

ErrorLookup(25)=Input data too short

This wrapper function will return the corresponding error message for a given error code:

Public Function pkiErrorLookup(nErrCode As Long) As String
' Returns the error message for error code nErrCode
    Dim sErrMsg As String
    Dim nLen As Long
    
    nLen = 127
    sErrMsg = String$(nLen, " ")
    nLen = PKI_ErrorLookup(sErrMsg, nLen, nErrCode)
    sErrMsg = Left$(sErrMsg, nLen)
    pkiErrorLookup = sErrMsg
End Function

See Also

PKI_ErrorCode Error codes

[Contents] [Index]

[HOME]   [NEXT: PKI_LastError...]

Copyright © 2004-12 D.I. Management Services Pty Ltd. All rights reserved.