IClientVirtualDeviceSet2::Close (VDI)IClientVirtualDeviceSet2::Close (VDI)

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions)

Close 函数用于关闭 IClientVirtualDeviceSet2::Create 创建的虚拟设备集 。The Close function closes the virtual device set created by IClientVirtualDeviceSet2::Create. 其结果是释放与虚拟设备集关联的所有资源。It results in the release of all resources associated with the virtual device set.

语法Syntax

HRESULT IClientVirtualDeviceSet2::Close ();

返回值Return Value

返回值Return Value 说明Explanation
NOERRORNOERROR 将在虚拟设备集成功关闭后返回。This is returned when the virtual device set was successfully closed.
VD_E_PROTOCOLVD_E_PROTOCOL 未采取任何操作,因为虚拟设备集未打开。No action was taken because the virtual device set was not open.
VD_E_OPENVD_E_OPEN 设备仍处于打开状态。Devices were still open.

备注Remarks

对 Close 的调用是由客户端做出的声明,表示应释放虚拟设备集所用的所有资源。The invocation of Close is a declaration by the client that all resources used by the virtual device set should be released. 调用 Close 前,客户端须确保已终止涉及数据缓冲区和虚拟设备的所有活动。The client must ensure that all activity involving data buffers and virtual devices is terminated before invoking Close. Close 会使由 OpenDevice 返回的所有虚拟设备接口失效。All virtual device interfaces returned by OpenDevice are invalidated by Close.

在返回 Close 调用后,允许客户端在虚拟设备集接口上发出一个 Create 调用。The client is permitted to issue a Create call on the virtual device set interface after the Close call returns. 此类调用将为后续的 BACKUP 或 RESTORE 操作创建新的虚拟设备集。Such a call would create a new virtual device set for a subsequent BACKUP or RESTORE operation.

如果在一台或多台虚拟设备处于打开状态时调用 Close,则会返回 VD_E_OPEN。If Close is called when one or more virtual devices are still open, VD_E_OPEN is returned. 在这种情况下,如果可能,将在内部触发 SignalAbort 以确保正确关闭。In this case, SignalAbort is internally triggered, to ensure a proper shutdown if possible. 将释放 VDI 资源。VDI resources are released. 调用 IClientVirtualDeviceSet2::Close 前,客户端应在每台设备上等待 VD_E_CLOSE 指示。The client should wait for a VD_E_CLOSE indication on each device before invoking IClientVirtualDeviceSet2::Close. 如果客户端知道虚拟设备集已处于异常终止状态,则它应不会收到 GetCommand 发出的 VD_E_CLOSE 指示,并且当共享缓冲区上的活动终止后,它可以调用 IClientVirtualDeviceSet2::Close。If the client knows that the virtual device set is already in an Abnormally Terminated state, then it should not expect a VD_E_CLOSE indication from GetCommand, and may invoke IClientVirtualDeviceSet2::Close as soon as activity on the shared buffers is terminated.

后续步骤Next steps

有关详细信息,请参阅 SQL Server 虚拟设备接口引用概述For more information, see the SQL Server virtual device interface reference overview.