CryptoSys PKI Toolkit Manual

PKI_LastError

Retrieves the last error message set by the toolkit.

VB6/VBA Syntax

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

nRet = PKI_LastError(strErrMsg, nMaxMsgLen)

Parameters

strErrMsg
[out] String to receive last error message.
nMaxMsgLen
[in] Long specifying the maximum length of the string to be copied.

C/C++ Syntax

long _stdcall PKI_LastError(char *szErrMsg, long nMsgLen);

Returns (VB6/C)

Long: If the preceding function call before calling PKI_LastError was successful, the return value is zero indicating no error; otherwise it is 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.LastError Method

Remarks

Not all functions set the error message string. The error message will never be longer than 511 characters.

Example

These wrapper functions can be used to obtain the last error message.

Public Function pkiGetLastError() As String
    Dim sErrMsg As String
    Dim nLen As Long
    
    nLen = 511
    sErrMsg = String$(nLen, " ")
    nLen = PKI_LastError(sErrMsg, nLen)
    sErrMsg = Left$(sErrMsg, nLen)
    pkiGetLastError = sErrMsg
End Function
void disp_error(long lRet)
{
    char szErrMsg[512];

    PKI_LastError(szErrMsg, sizeof(szErrMsg)-1);
    printf("%ld %s\n", lRet, szErrMsg);
}

See Also

PKI_ErrorCode PKI_ErrorLookup Error codes

[Contents] [Index]

[HOME]   [NEXT: PKI_LicenceType...]

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