FSCTL_ENUM_USN_DATA control code

Enumerates the update sequence number (USN) data between two specified boundaries to obtain master file table (MFT) records.

To perform this operation, call the DeviceIoControl function with the following parameters.

DeviceIoControl( (HANDLE) hDevice,              // handle to volume
                 (DWORD) FSCTL_ENUM_USN_DATA,   // dwIoControlCode
                 (LPVOID) lpInBuffer,           // input buffer
                 (DWORD) nInBufferSize,         // size of input buffer
                 (LPVOID) lpOutBuffer,          // output buffer
                 (DWORD) nOutBufferSize,        // size of output buffer
                 (LPDWORD) lpBytesReturned,     // number of bytes returned
                 (LPOVERLAPPED) lpOverlapped ); // OVERLAPPED structure);



A handle to the local volume from which data is to be retrieved.

To retrieve a volume handle, call the CreateFile function.


The control code for the operation.

Use FSCTL_ENUM_USN_DATA for this operation.


A pointer to the input buffer, an MFT_ENUM_DATA_V0 or MFT_ENUM_DATA_V1 structure.

This structure specifies the boundaries between which MFT entries are listed.

Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  MFT_ENUM_DATA_V1 structures are not supported before Windows Server 2012.


The size of the input buffer, in bytes. The size passed determines whether the system looks for the additional members at the end of the MFT_ENUM_DATA_V1 structure.


A pointer to the output buffer that receives a USN followed by zero or more USN_RECORD_V2 or USN_RECORD_V3 structures.

The USN is a DWORDLONG value that represents the USN following the last record in the buffer. It can be used in a subsequent call to FSCTL_ENUM_USN_DATA to get the next set of records following those in the current output buffer.

For more information about navigating the data in the output buffer, see Walking a Buffer of Change Journal Records.

Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  USN_RECORD_V3 structures are not supported before Windows Server 2012.


The size of the output buffer, in bytes.


A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.

If the output buffer is too small, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.

If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.

If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.


A pointer to an OVERLAPPED structure.

If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.

If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.

For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been completed. Otherwise, the function does not return until the operation has been completed or an error occurs.

Return value

If the operation completes successfully, DeviceIoControl returns a nonzero value.

If the operation fails or is pending, DeviceIoControl returns zero, and the contents of the output buffer pointed to by the lpOutBuffer parameter are meaningless. To get extended error information, call GetLastError.

Possible return values include the following.

Return codeDescription

The file system on the specified volume does not support this control code.


One or more parameters is invalid.

For example, DeviceIoControl returns this error code if the handle supplied is not a volume handle.



For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic.

To enumerate files on a volume, use the FSCTL_ENUM_USN_DATA operation one or more times. On the first call, set the starting point, the StartFileReferenceNumber member of the MFT_ENUM_DATA structure, to (DWORDLONG)0. Each call to FSCTL_ENUM_USN_DATA retrieves the starting point for the subsequent call as the first entry in the output buffer.

By comparing To identify recent changes to a volume, use the FSCTL_READ_USN_JOURNAL control code.

To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form:


In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be NTFS.

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


Server Message Block (SMB) 3.0 protocol


SMB 3.0 Transparent Failover (TFO)


SMB 3.0 with Scale-out File Shares (SO)


Cluster Shared Volume File System (CsvFS)




Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]


WinIoCtl.h (include Windows.h)

See also

Volume Management Control Codes