Queries for information on the current update sequence number (USN) change journal, its records, and its capacity.
BOOL DeviceIoControl(
(HANDLE) hDevice, // handle to volume
FSCTL_QUERY_USN_JOURNAL, // dwIoControlCode
NULL, // lpInBuffer
0, // nInBufferSize
(LPVOID) lpOutBuffer, // output buffer
(DWORD) nOutBufferSize, // size of output buffer
(LPDWORD) lpBytesReturned, // number of bytes returned
(LPOVERLAPPED) lpOverlapped // OVERLAPPED structure
);
Parameters
- hDevice
A handle to the local volume from which data is to be retrieved.
To retrieve a volume handle, call the
CreateFile function.
- dwIoControlCode
The control code for the operation.
Use
FSCTL_QUERY_USN_JOURNAL for this operation.
- lpInBuffer
Not used with this operation; set to NULL.
- nInBufferSize
Not used with this operation; set to 0 (zero).
- lpOutBuffer
A pointer to the output buffer that receives a
USN_JOURNAL_DATA structure that contains information about the current change journal, its records, and its capacity.
- nOutBufferSize
The size of the output buffer, in bytes.
- lpBytesReturned
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.
- lpOverlapped
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 code | Description |
- ERROR_INVALID_FUNCTION
| The specified volume does not support change journals.
Change journals are only supported on Windows 2000 and later. Where supported, change journals can also be deleted.
|
- ERROR_INVALID_PARAMETER
| One or more parameters is invalid.
For example, DeviceIoControl returns this error code if the handle supplied is not a volume handle.
|
- ERROR_JOURNAL_DELETE_IN_PROGRESS
| 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.
|
- ERROR_JOURNAL_NOT_ACTIVE
| An attempt is made to write a USN record or to read the change journal while the journal is inactive.
|
Remarks
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:
\\.\X:
In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be NTFS 3.0 or later. To obtain the NTFS version of a volume, open a command prompt with Administrator access rights and execute the following command:
fsutil fsinfo ntfsinfo X:
where X is the drive letter of the volume.
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | WinIoCtl.h |
See Also
- Change Journals
- CreateFile
- DeviceIoControl
- GetOverlappedResult
- GetQueuedCompletionStatus
- OVERLAPPED
- USN_JOURNAL_DATA
- Volume
Management Control Codes
Send comments about this topic to Microsoft
Build date: 11/12/2009