[FlagsAttribute()]
public enum WiaVariableTypes
Value | Member | Description |
---|---|---|
0x00000000 | Empty | VT_EMPTY |
0x00000001 | Null | VT_NULL |
0x00000002 | I2 | (0x00000012)VT_I2 |
0x00000003 | I4 | (0x00000013)VT_I4 |
0x00000004 | R4 | VT_R4 |
0x00000005 | R8 | VT_R8 |
0x00000006 | Cy | VT_CY |
0x00000007 | Date | VT_DATE |
0x00000008 | Bstr | VT_BSTR |
0x00000009 | Dispatch | VT_DISPATCH |
0x0000000A | Error | VT_ERROR |
0x0000000B | Bool | VT_BOOL |
0x0000000C | Variant | VT_VARIANT |
0x0000000D | Unknown | VT_UNKNOWN |
0x0000000E | Decimal | VT_DECIMAL |
0x00000010 | I1 | (0x00000011)VT_I1 |
0x00000011 | UI1 | VT_UI1 |
0x00000012 | UI2 | VT_UI2 |
0x00000013 | UI4 | VT_UI4 |
0x00000014 | I8 | (0x00000015)VT_I8 |
0x00000015 | UI8 | VT_UI8 |
0x00000016 | Int | (0x00000017)VT_INT |
0x00000017 | UInt | VT_UINT |
0x00000018 | Void | VT_VOID |
0x00000019 | HResult | VT_HRESULT |
0x0000001A | Ptr | (0x00000025)(0x00000026)VT_PTR |
0x0000001B | SafeArray | VT_SAFEARRAY |
0x0000001C | CArray | VT_CARRAY |
0x0000001D | UserDefined | VT_USERDEFINED |
0x0000001E | Lpstr | VT_LPSTR |
0x0000001F | Lpwstr | VT_LPWSTR |
0x00000024 | Record | VT_RECORD |
0x00000025 | IntPtr | (0x00000026)VT_INT_PTR |
0x00000026 | UIntPtr | VT_UINT_PTR |
0x00000040 | FileTime | VT_FILETIME |
0x00000041 | Blob | (0x00000FFF)VT_BLOB |
0x00000042 | Stream | (0x00000049)VT_STREAM |
0x00000043 | Storage | VT_STORAGE |
0x00000044 | StreamedObject | VT_STREAMED_OBJECT |
0x00000045 | StoredObject | VT_STORED_OBJECT |
0x00000046 | BlobObject | VT_BLOB_OBJECT |
0x00000047 | CF | VT_CF |
0x00000048 | Clsid | VT_CLSID |
0x00000049 | VersionedStream | VT_VERSIONED_STREAM |
0x00000FFF | IllegalMasked | VT_ILLEGALMASKED |
0x00000FFF | TypeMask | VT_TYPEMASK |
0x00000FFF | BstrBlob | VT_BSTR_BLOB |
0x00001000 | Vector | VT_VECTOR |
0x00002000 | Array | (0x0000001C)(0x00002000)VT_ARRAY |
0x00004000 | ByRef | VT_BYREF |
0x00008000 | Reserved | VT_RESERVED |
0x0000FFFF | Illegal | VT_ILLEGAL |
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Wia;
WiaSession session;
public void EnumCapabilitiesExample(IntPtr parent)
{
if (!WiaSession.IsAvailable(WiaVersion.Version1))
{
Console.WriteLine("WIA version 1.0 not installed.");
return;
}
session = new WiaSession();
session.Startup(WiaVersion.Version1);
DialogResult res = session.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault);
if (res != DialogResult.OK)
{
Console.WriteLine("Error selecting WIA device.");
session.Shutdown();
return;
}
session.EnumCapabilitiesEvent += new EventHandler<WiaEnumCapabilitiesEventArgs>(wiaSession_EnumCapabilitiesEvent);
object rootItem = session.GetRootItem(null);
if (rootItem != null)
{
session.EnumCapabilities(rootItem, WiaEnumCapabilitiesFlags.None);
}
session.EnumCapabilitiesEvent -= new EventHandler<WiaEnumCapabilitiesEventArgs>(wiaSession_EnumCapabilitiesEvent);
session.Shutdown();
}
void wiaSession_EnumCapabilitiesEvent(object sender, WiaEnumCapabilitiesEventArgs e)
{
string strMsg = string.Empty;
string strPropAccess = string.Empty;
string strPropValue = string.Empty;
strMsg = string.Format("WIA Capabilities count = {0}\n", e.CapabilitiesCount);
Console.WriteLine(strMsg);
// print out the received capability information into the console window.
if (e.CapabilitiesCount > 0)
{
Console.WriteLine("Capability information:\n");
// print out received capability property ID.
strMsg = string.Format("Property ID:\t{0}\n", e.Capability.PropertyId.ToString());
Console.WriteLine(strMsg);
// print out received capability property Name.
strMsg = string.Format("Property Name:\t{0}\n", e.Capability.PropertyName);
Console.WriteLine(strMsg);
// print out received capability property access.
if ((e.Capability.PropertyAttributes & WiaPropertyAttributesFlags.ReadWrite) == WiaPropertyAttributesFlags.ReadWrite)
{
strPropAccess += "ReadWrite";
}
else
{
if ((e.Capability.PropertyAttributes & WiaPropertyAttributesFlags.Read) == WiaPropertyAttributesFlags.Read)
strPropAccess += "Read";
if ((e.Capability.PropertyAttributes & WiaPropertyAttributesFlags.Write) == WiaPropertyAttributesFlags.Write)
{
if (!string.IsNullOrEmpty(strPropAccess))
{
strPropAccess += " | Write";
}
else
{
strPropAccess += "Write";
}
}
}
if ((e.Capability.PropertyAttributes & WiaPropertyAttributesFlags.Cashable) == WiaPropertyAttributesFlags.Cashable)
{
if (!string.IsNullOrEmpty(strPropAccess))
{
strPropAccess += " | Cashable";
}
else
{
strPropAccess += "Cashable";
}
}
strMsg = string.Format("Property Access:\t{0}\n", strPropAccess);
Console.WriteLine(strMsg);
// print out received capability property value(s).
if ((e.Capability.PropertyAttributes & WiaPropertyAttributesFlags.List) == WiaPropertyAttributesFlags.List)
{
strPropValue = "Property List Values:\n";
for (int i = 0; i < e.Capability.Values.ListValues.ValuesCount; i++)
{
if ((e.Capability.VariableType & WiaVariableTypes.Bstr) == WiaVariableTypes.Bstr)
{
strPropValue = strPropValue + "\t" + Convert.ToString(e.Capability.Values.ListValues.Values[i]) + "\n";
}
else if ((e.Capability.VariableType & WiaVariableTypes.Clsid) == WiaVariableTypes.Clsid)
{
System.Guid guidValue = (System.Guid)e.Capability.Values.ListValues.Values[i];
strPropValue = strPropValue + "\t" + guidValue.ToString() + "\n";
}
else
{
strPropValue = strPropValue + "\t" + (Convert.ToInt32(e.Capability.Values.ListValues.Values[i])).ToString() + "\n";
}
}
}
else if ((e.Capability.PropertyAttributes & WiaPropertyAttributesFlags.Range) == WiaPropertyAttributesFlags.Range)
{
strPropValue = string.Format("Property Range Values:\n\tMinimum Value: {0}\n\tMaximum Value: {1}\n", e.Capability.Values.RangeValues.MinimumValue, e.Capability.Values.RangeValues.MaximumValue);
}
else if ((e.Capability.PropertyAttributes & WiaPropertyAttributesFlags.Flag) == WiaPropertyAttributesFlags.Flag)
{
strPropValue = e.Capability.Values.FlagsValues.FlagValues.ToString();
}
else // The property value is of type "None", and in this case you can retrieve the value by calling the GetPropertyXXX method appropriate for the received variable type.
{
strPropValue = "Property Value: ";
object rootItem = session.GetRootItem(null);
if ((e.Capability.VariableType & WiaVariableTypes.Bstr) == WiaVariableTypes.Bstr)
{
string stringValue = session.GetPropertyString(rootItem, null, e.Capability.PropertyId);
strPropValue += stringValue;
}
else if ((e.Capability.VariableType & WiaVariableTypes.Clsid) == WiaVariableTypes.Clsid)
{
Guid guidValue = session.GetPropertyGuid(rootItem, null, e.Capability.PropertyId);
strPropValue += guidValue.ToString();
}
else
{
int longValue = session.GetPropertyLong(rootItem, null, e.Capability.PropertyId);
strPropValue += longValue.ToString();
}
}
Console.WriteLine(strPropValue);
}
}