I need a high-level Delphi API wrapping the native Windows Journal functionality. The API must support Windows 10 or higher, taking advantage of all the latest Journal features that are available together with the very first release of Windows 10. It should support 32 bit and 64 bit platforms natively. It must be able to disable file system redirection on 32 bit platforms to accurately capture all changes when 32 bit code is being run on a 64 bit operating system.
The following is a draft of the functions that should be available with the high-level Delphi API. Please feel free to suggest changes/enhancements/fixes to this API as necessary:
function IsJournalDeleting(Volume: Char): Boolean;
Returns whether the Windows Journal is being deleted on the target volume. GetLastError should return the WinAPI failure code where applicable.
function IsJournalEnabled(Volume: Char): Boolean;
Returns whether the Windows Journal is enabled on the target volume. GetLastError should return the WinAPI failure code where applicable.
function EnableJournal(Volume: Char): Boolean;
Enables the Windows Journal on the target volume. GetLastError should return the WinAPI failure code where applicable.
function DisableJournal(Volume: Char): Boolean;
Disables the Windows Journal on the target volume. GetLastError should return the WinAPI failure code where applicable.
function PrepJournalChanges(Volume: Char; ChangeTypes: DWORD): Boolean;
Starts monitoring the designated volume for changes. ChangeTypes is a flag to identify the types of changes to monitor for, as defined in the Windows Journal APIs. GetLastError should return the WinAPI failure code where applicable.
function GetJournalChanges(Volume: Char; Callback: TJournalChangeCallback): Boolean;
Returns the full list of changes picked up from the Windows Journal previously enabled (using the API above where necessary) on the desired volume, since the last time PrepJournalChanges was called, or if PrepJournalChanges was already called, since the last time GetJournalChanges was called. The Callback function described below is called for each Journal change that is detected. GetLastError should return the WinAPI failure code where applicable. IMPORTANT: The USN_REASON_CLOSE flag requires special treatment. When this flag is specified, changes should be reported only when the changed file/folder has been closed. However, you may still internally need to keep monitoring changes without the USN_REASON_CLOSE flag, to properly capture all types of changes occurring in between, which you may need to properly resolve file and folder paths. Otherwise, you may be unable to resolve some type of file and folder paths based on the types of changes occurring.
type TJournalChangeCallback = function(FileName: String; IsFolder: Boolean; ChangeTypes: DWORD): Boolean;
FileName contains the name of the file that was changed, including full file path. IsFolder designates whether FileName designates a folder. ChangeTypes contains the bitmask identifying the types of changes that are being reported. This user defined function returns TRUE to continue enumerating changes through the callback, or FALSE to stop enumerating changes immediately, where all changes captured by the last call to GetJournalChanges will be lost permanently, while new changes happening since the last call to GetJournalChanges may still be captured by a new call to GetJournalChanges.
function DoneJournalChanges: Boolean;
Frees up any resources allocated by PrepJournalChanges/GetJournalChanges. Any further calls after DoneJournalChanges has been called must start with a new call to PrepJournalChanges and further calls to GetJournalChanges as necessary. GetLastError should return the WinAPI failure code where applicable.