扫描配置文件架构

扫描配置文件架构定义了一种 XML 格式,该格式可用于存储 Windows 图像采集 (WIA) 项(如扫描仪和相机)的属性。 这些永久性文件使应用程序无需用户记住项的属性设置即可提供自动扫描。

任何 IWiaItem2 设备都可以具有扫描配置文件。 但是,WIA_CATEGORY_FINISHED_FILE和WIA_CATEGORY_ROOT类型的 IWiaItem2 项不能具有配置文件。

扫描配置文件通过 IScanProfile、IScanProfileMgrIScanProfileUI 接口创建和管理。 应用程序的用户可以使用 IScanProfileUI::ScanProfileDialog 方法以有限的方式修改配置文件。

所有扫描配置文件都具有以下元素: <ProfileGUID>, <DeviceID>, <ProfileName>, <WiaItem>、 和 <Properties>。 设备的默认配置文件还具有 <Default> 元素。

<ProfileGUID>创建扫描配置文件后,<DeviceID>无法更改 元素和 元素。 可以修改 元素和 <WiaItem> 元素的值<ProfileName><Default>可以添加或删除 元素。 可以使用 IScanProfile::SetName、IScanProfile::SetItemIScanProfileMgr::SetDefault 方法以编程方式完成此操作。 用户还可以通过 IScanProfileUI::ScanProfileDialog 方法更改这些属性。

元素 <Properties> 包含子元素 <Property> 。 使用它们将任何 WIA 项或设备属性添加到配置文件。 你还可以开发自己的图像获取 <Property> 子级。 这使得扫描配置文件架构可扩展。 (有关扩展架构的详细信息,请参阅 定义自定义属性IScanProfile::GetPropertyIScanProfile::SetProperty.)

下面是完整的扫描配置文件架构。 下面提供了一个示例配置文件。

<?xml version="1.0"?>
<xs:schema xmlns:xs="https://www.w3.org/2001/XMLSchema"
            targetNamespace="https://www.microsoft.com"
            xmlns="https://www.microsoft.com"
            elementFormDefault="qualified">

<xs:element name="ScanProfile">
            <xs:complexType>
            <xs:sequence>
                        <xs:element name="ProfileGUID" type="xs:string"/>
                        <xs:element name="DeviceID" type="xs:string"/>
<xs:element name="ProfileName" type="xs:string"/>
                        <xs:element name="Default" minOccurs="0">
                                    <xs:complexType>
                                    </xs:complexType>
                        </xs:element>
                        <xs:element name="WiaItem" type="xs:string"/>
                        <xs:element name="Properties" type="Properties"/>
            </xs:sequence>
            </xs:complexType>
</xs:element>
 
<xs:complexType name="Properties">
<xs:sequence>
            <xs:element name="Property" maxOccurs="unbounded" minOccurs="0">
            <xs:complexType>
            <xs:simpleContent>
                        <xs:extension base="xs:string">
                                    <xs:attribute name="id" type="xs:integer" use="required"/>
                                    <xs:attribute name="type" type="xs:integer" use="required"/>
                        </xs:extension>
            </xs:simpleContent>
            </xs:complexType>
            </xs:element>
</xs:sequence>
</xs:complexType>
 
</xs:schema>

单击“ 显示示例” 以查看示例配置文件。

<ScanProfile>
    <ProfileGUID>
        {F862E217-32B0-4396-987A-2191224925CD}
    </ProfileGUID>
    <DeviceID>
        {6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0001
    </DeviceID>
    <ProfileName>
        Last used settings
    </ProfileName>
    <WiaItem>
        {FB607B1F-43F3-488B-855B-FB703EC342A6}
    </WiaItem>
    <Properties>
        <Property id="4103" type="3">
            3
        </Property>
        <Property id="4106" type="72">
            {B96B3CAB-0728-11D3-9D7B-0000F81EF32E}
        </Property>
        <Property id="6147" type="3">
            300
        </Property>
        <Property id="6154" type="3">
            0
        </Property>
        <Property id="6155" type="3">
            0
        </Property>
    </Properties>
</ScanProfile>

参考

IScanProfile::GetProperty

IScanProfile::SetProperty

概念性

WIA 属性常量

定义自定义属性