Click to Rate and Give Feedback
MSDN
MSDN Library
System Services
File Services
File Systems
Volume Management
 FSCTL_QUERY_USN_JOURNAL Control Cod...

  Switch on low bandwidth view
FSCTL_QUERY_USN_JOURNAL Control Code

Queries for information on the current 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 codeDescription
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.

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

\\.\DriveLetter:

where DriveLetter is the letter that identifies the drive where the volume appears. The volume must use NTFS 5.0 or later.

To compile an application that uses this function, you may need to define the _WIN32_WINNT macro as 0x0500. For more information, see Using the Windows Headers.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinIoCtl.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: 7/9/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker