大网数据广告活动
磁盘与文件系统

CancelSynchronousIo function (IoAPI.h)

· 52CE 我爱测

Marks pending synchronous I/O operations that are issued by the specified thread as canceled.

Marks pending synchronous I/O operations that are issued by the specified thread as canceled.

Syntax

BOOL WINAPI CancelSynchronousIo(
  _In_ HANDLE hThread
);

Parameters

hThread [in]

A handle to the thread.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is 0 (zero). To get extended error information, call the GetLastError function.

If this function cannot find a request to cancel, the return value is 0 (zero), and GetLastError returns ERROR_NOT_FOUND.

Remarks

The caller must have the THREAD_TERMINATE access right.

If there are any pending I/O operations in progress for the specified thread, the CancelSynchronousIo function marks them for cancellation. Most types of operations can be canceled immediately; other operations can continue toward completion before they are actually canceled and the caller is notified. The CancelSynchronousIo function does not wait for all canceled operations to complete. For more information, see I/O Completion/Cancellation Guidelines.

The operation being canceled is completed with one of three statuses; you must check the completion status to determine the completion state. The three statuses are:

  • The operation completed normally. This can occur even if the operation was canceled, because the cancel request might not have been submitted in time to cancel the operation.
  • The operation was canceled. The GetLastError function returns ERROR_OPERATION_ABORTED.
  • The operation failed with another error. The GetLastError function returns the relevant error code.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

Technology Supported
Server Message Block (SMB) 3.0 protocol Yes
SMB 3.0 Transparent Failover (TFO) Yes
SMB 3.0 with Scale-out File Shares (SO) Yes
Cluster Shared Volume File System (CsvFS) Yes
Resilient File System (ReFS) Yes

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Header IoAPI.h (include Windows.h);WinBase.h on Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

CancelIo

CancelIoEx

File Management Functions

Synchronous and Asynchronous I/O

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/01/2023
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。