Queries for information on the current update sequence number (USN) change journal, its records, and its capacity.

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

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



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_QUERY_USN_JOURNAL for this operation.


Not used with this operation; set to NULL.


Not used with this operation; set to 0 (zero).


A pointer to the output buffer that receives a USN_JOURNAL_DATA_V0 or USN_JOURNAL_DATA_V1 or USN_JOURNAL_DATA_V2 structure that contains information about the current change journal, its records, and its capacity.


The size of the output buffer, in bytes. If the size passed is at least sizeof(USN_JOURNAL_DATA_V0) but less than sizeof(USN_JOURNAL_DATA_V1), the output structure is a USN_JOURNAL_DATA_V0 structure. If the size passed is at least sizeof(USN_JOURNAL_DATA_V1) but less than sizeof(USN_JOURNAL_DATA_V2), the output buffer is a USN_JOURNAL_DATA_V1 structure. If the output buffer is sizeof(USN_JOURNAL_DATA_V2) or larger, the output buffer is a USN_JOURNAL_DATA_V2 structure.

Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  USN_JOURNAL_DATA_V1 is not supported before Windows 8 and Windows Server 2012. USN_JOURNAL_DATA_V2 is not supported before Windows 8.1 and Windows Server 2012 R2.


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 0 (zero).

If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation does not return output data and lpOutBuffer is NULL, DeviceIoControl uses 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 is complete. 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 is opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.

If hDevice is 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 is complete. Otherwise, the function does not return until the operation is complete or an error occurs.

Return value

If the operation completes successfully, DeviceIoControl returns a nonzero value, and the output buffer pointed to by lpOutBuffer contains a valid USN_JOURNAL_DATA structure.

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

The possible return values include the following.

Return codeDescription

The specified volume does not support change journals. Where supported, change journals can also be deleted.


One or more parameters is invalid.

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


An attempt is made to read from, create, delete, or modify the journal while a journal deletion is in process, or an attempt is made to write a USN record while a journal deletion is in process.


An attempt is made to write a USN record or to read the change journal while the journal is inactive.



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

For more information, see Creating, Modifying, and Deleting a Change Journal.

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 formatted with the NTFS filesystem.

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)



An application may experience false positives on CsvFs pause/resume.


Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]


WinIoCtl.h (include Windows.h)

See also

Change Journals
Volume Management Control Codes