Retrieves the error message associated with a given error code.
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)
String to receive error message.Long specifying the maximum length of the string to be copied.Long specifying the error code for which the message is required.
long _stdcall PKI_ErrorLookup(char *szErrMsg, long nMsgLen, long nErrCode);
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.
The error message will never be longer than 127 characters.
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