大网数据广告活动
Windows 系统接口

NtCancelIoFile function

· 52CE 我爱测

User-mode API - cancels all pending input and output (I/O) operations that are issued by the calling thread for the specified file.

Cancels all pending input and output (I/O) operations that are issued by the calling thread for the specified file. The function does not cancel I/O operations that other threads issue for a file handle.

To cancel I/O operations from another thread, use the NtCancelIoFileEx function.

Note: This function is the user-mode equivalent to the CancelIo Win32 function.

Syntax

BOOL WINAPI NtCancelIoFile(
  _In_ HANDLE hFile
);

Parameters

hFile [in]

A handle to the file.

The function cancels all pending I/O operations for this file handle.

Returns

If the function succeeds, the return value is nonzero. The cancel operation for all pending I/O operations issued by the calling thread for the specified file handle was successfully requested. The thread can use the GetOverlappedResult function to determine when the I/O operations themselves have been completed.

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

Remarks

If there are any pending I/O operations in progress for the specified file handle, and they are issued by the calling thread, the NtCancelIoFile function cancels them. NtCancelIoFile cancels only outstanding I/O on the handle, it does not change the state of the handle; this means that you cannot rely on the state of the handle because you cannot know whether the operation was completed successfully or canceled.

The I/O operations must be issued as overlapped I/O. If they are not, the I/O operations do not return to allow the thread to call the NtCancelIoFile function. Calling the NtCancelIoFile function with a file handle that is not opened with FILE_FLAG_OVERLAPPED does nothing.

All I/O operations that are canceled complete with the error ERROR_OPERATION_ABORTED, and all completion notifications for the I/O operations occur normally.

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
Header ntioapi.h
Library ntdll.lib

See also

CancelIoEx

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 09/08/2022
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

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

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