00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 using System;
00025 using System.Runtime.InteropServices;
00026
00027 namespace ZBar
00028 {
00032 public sealed class ZBarException : Exception
00033 {
00034 private string message;
00035 private ZBarError code;
00036
00037 internal ZBarException(IntPtr obj)
00038 {
00039 this.code = (ZBarError)_zbar_get_error_code(obj);
00040 this.message = Marshal.PtrToStringAnsi(_zbar_error_string(obj, 4));
00041 }
00042
00046 public override string Message {
00047 get {
00048 return this.message;
00049 }
00050 }
00051
00055 public ZBarError ErrorCode{
00056 get{
00057 return this.code;
00058 }
00059 }
00060
00061 [DllImport("libzbar")]
00062 private static extern IntPtr _zbar_error_string(IntPtr obj, int verbosity);
00063
00064 [DllImport("libzbar")]
00065 private static extern int _zbar_get_error_code(IntPtr obj);
00066 }
00067
00071 public enum ZBarError{
00075 Ok = 0,
00076
00080 OutOfMemory,
00081
00085 InternalLibraryError,
00086
00090 Unsupported,
00091
00095 InvalidRequest,
00096
00100 SystemError,
00101
00105 LockingError,
00106
00110 AllResourcesBusyError,
00111
00115 X11DisplayError,
00116
00120 X11ProtocolError,
00121
00125 OutputWindowClosed,
00126
00130 WindowsAPIError
00131 }
00132 }