This method returns a text description of an neoVI API error number.
int _stdcall icsneoGetErrorInfo(int lErrorNumber, TCHAR *szErrorDescriptionShort, TCHAR *szErrorDescriptionLong,int*lMaxLengthShort,int*lMaxLengthLong,int*lErrorSeverity,int*lRestartNeeded);
Public Declare Function icsneoGetErrorInfo Lib "icsneo40.dll" _
(ByVal lErrorNumber As Int32, _
ByVal sErrorDescriptionShort As String, _
ByVal sErrorDescriptionLong As String, _
ByRef lMaxLengthShort As Int32, _
ByRef lMaxLengthLong As Int32, _
ByRef lErrorSeverity As Int32, _
ByRef lRestartNeeded As Int32) As Int32
lErrorNumber
[in] This is the number of the error message returned from GetErrorMessages. A separate topic describes the possible values for error messages.
sErrorDescriptionShort
[out] This is short description of the error. This parameter should be sized to include up to 255 characters including the NULL terminator.
sErrorDescriptionLong
[out] This is longer more detailed description of the error. This parameter should be sized to include up to 255 characters including the NULL terminator.
lMaxLengthShort
[in] This is the size in characters of the sErrorDescriptionShort array that is being passed in. This value must be 255 or less.
lMaxLengthLong
[in] This is the size in characters of the sErrorDescriptionLong array that is being passed in. This value must be 255 or less.
lErrorSeverity
[out] This indicates the error severity. This is estimated severity for the application and doesn't have significant meaning. See Table 1 below for more information.
lRestartNeeded
[out] If 1 it is recommend that the application close communications with the DLL and reopen it.
Return Values
If the error number was found successfully the return value will be non-zero.
Remarks
None.
Table 1 - Descriptions of Error Severity
Examples
// Read the errors from the DLLlResult =icsneoGetErrorMessages(hObject,iErrors,&lNumberOfErrors);if (lResult ==0)MessageBox(hWnd,TEXT("Problem Reading errors"),TEXT("neoVI Example"),0);// dump the neoVI errorsif (lNumberOfErrors >0){for (lCount=0;lCount <lNumberOfErrors;lCount++) {wsprintf(szOut,TEXT("Error %d - "),iErrors[lCount]);OutputDebugString(szOut);icsneoGetErrorInfo(iErrors[lCount],szDescriptionShort,szDescriptionLong,&lMaxLengthShort,&lMaxLengthLong,&lErrorSeverity,&lRestartNeeded);OutputDebugString(szDescriptionShort);OutputDebugString(TEXT("\n")); }}elseOutputDebugString(TEXT("No Errors to report\n"));
Public Function icsneoGetDLLErrorInfo(ByVal lErrorNum As Int32, ByRef sErrorShort As String, ByRef sErrorLong As String, ByRef lSeverity As Int32, ByRef bRestart As Int32) As Boolean
Dim lErrorLongLength As Int32
Dim lErrorShortLength As Int32
Dim lRestart As Int32
Dim lResult As Int32
sErrorLong = New String(Chr(0), 255)
sErrorShort = New String(Chr(0), 255)
lErrorLongLength = 255
lErrorShortLength = 255
lResult = icsneoGetErrorInfo(lErrorNum, sErrorShort, sErrorLong, lErrorShortLength, lErrorLongLength, lSeverity, lRestart)
sErrorShort = Left(sErrorShort, lErrorShortLength)
sErrorLong = Left(sErrorLong, lErrorLongLength)
bRestart = CBool(lRestart)
icsneoGetDLLErrorInfo = CBool(lResult)
End Function
**This function reads errors and loads them into a list box**
Private Sub cmdGetErrors_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetErrors.Click
Dim lResult As Integer '//Storage for result of Function Call
Dim lErrors(600) As Int32 '//Array for Error information
Dim lNumberOfErrors As Integer '//Storage for Number of Errors
Dim lCount As Integer '//Counter
Dim sErrorShort As String '//String Holding Short Error Name
Dim sErrorLong As String '//String Holding Long Error Name
Dim iSeverity As Int32 '//Storage for Level of error
Dim bRestart As Int32 '//flag for if Restart is required
'// Read Out the errors
lResult = icsneoGetErrorMessages(m_hObject, lErrors(0), lNumberOfErrors)
'// Test the returned result
If Not CBool(lResult) Then
MsgBox("Problem Reading Errors")
Else
'//List Error information
lstErrorHolder.Items.Clear()
For lCount = 1 To lNumberOfErrors
Call icsneoGetDLLErrorInfo(lErrors(lCount - 1), sErrorShort, sErrorLong, iSeverity, bRestart)
lstErrorHolder.Items.Add(sErrorShort + " - Description" + _
sErrorLong + " - Errornum: " + Convert.ToString(lErrors(lCount - 1)))
Next lCount
End If
End Sub
privatevoidcmdGetErrors_Click(object sender,System.EventArgs e){int iResult =0; //Storage for Result of Callint[] iErrors =newint[600]; //Array for Error Numbersint iNumberOfErrors =0; // Storage for number of errorsint iCount=0; //Counterint iSeverity =0; //tells the Severity of Errorint iMaxLengthShort =0; //Tells Max length of Error Stringint iMaxLengthLong =0; //Tells Max Length of Error Stringint lRestart =0; //tells if a restart is neededStringBuilder sErrorShort =newStringBuilder(256); //String for ErrorStringBuilder sErrorLong =newStringBuilder(256); //String for Error iMaxLengthShort =1; //Set initial conditions iMaxLengthLong =1; //Set initial conditions // Read Out the errors iResult =icsNeoDll.icsneoGetErrorMessages(m_hObject,refiErrors[0],ref iNumberOfErrors); // Test the returned resultif(iResult ==0) {MessageBox.Show ("Problem Reading Errors"); }else {if(iNumberOfErrors !=0) {for(iCount=0;iCount< iNumberOfErrors;iCount++) { //Get Text Description of the Error iResult =icsNeoDll.icsneoGetErrorInfo(iErrors[iCount], sErrorShort, sErrorLong ,ref iMaxLengthShort ,ref iMaxLengthLong,ref iSeverity,ref lRestart); lstErrorHolder.Items.Add (sErrorShort + " - Description " + sErrorLong + " - Errornum: " + iErrors[iCount]);
} } }}