Sets the error string that corresponds to a specific
TwainExceptionCode
Syntax
Parameters
- code
- A TwainExceptionCode value to set the string message for.
- message
- A String that contains the new message for code.
Example
Visual Basic | Copy Code |
---|
Public Sub SetCodeMessageExample()
Dim code As TwainExceptionCode = TwainExceptionCode.StopScan
Dim message As String = TwainException.GetCodeMessage(code)
MessageBox.Show(String.Format("Code: {0}, message: {1}", code, message))
Try
Throw New TwainException(code)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
TwainException.SetCodeMessage(code, "My new message")
Try
Throw New TwainException(code)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub |
C# | Copy Code |
---|
public void SetCodeMessageExample() { // Get the initial FileFormat message TwainExceptionCode code = TwainExceptionCode.StopScan; string message = TwainException.GetCodeMessage(code); MessageBox.Show(string.Format("Code: {0}, message: {1}", code, message)); // make sure that this message is used now try { throw new TwainException(code); } catch(Exception ex) { MessageBox.Show(ex.Message); } // change this message to a custom one TwainException.SetCodeMessage(code, "My new message"); // make sure that this new message is used now try { throw new TwainException(code); } catch(Exception ex) { MessageBox.Show(ex.Message); } } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also