StorageLibraryChangeReader.GetLastChangeId メソッド

定義

指定された StorageFolder または StorageLibrary のインデックス作成サービスによって最後に処理された変更を表す一意の値を取得します。

public:
 virtual unsigned long long GetLastChangeId() = GetLastChangeId;
uint64_t GetLastChangeId();
public ulong GetLastChangeId();
function getLastChangeId()
Public Function GetLastChangeId () As ULong

戻り値

UInt64

unsigned long long

uint64_t

変更があった場合は、有効な変更 ID (> 0)。

前回の読み取り以降に変更がない場合、または変更がまだ発生していない場合は、0 を返します。

変更トラッカーが変更 ID を計算できない場合、またはファイルの変更が多すぎてこの値がオーバーフローした場合は、StorageLibraryChangeId::Unknown を返します。

Windows の要件

デバイス ファミリ
Windows 10, version 2104 (10.0.20348.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v12.0 で導入)

// applications are expected to persist the previous value
UINT64 appsLastPersistedChangeId = StorageLibraryLastChangeId::Unknown();
StorageFolder folder = StorageFolder::GetFolderFromPathAsync(L"my folder path").get();

StorageLibraryChangeTracker tracker = folder.TryGetChangeTracker();
if (tracker != nullptr)
{
StorageLibraryChangeTrackerOptions ops;
ops.TrackChangeDetails(false);
tracker.Enable(ops);

StorageLibraryChangeReader reader = tracker.GetChangeReader();
if (reader != nullptr)
{
    UINT32 changeId = reader.GetLastChangeId();
    if ((changeId == StorageLibraryLastChangeId::Unknown())
    {
        ScanFolderSlow();
    }
    else if (changeId == 0)
    {
        // no changes in the storage folder yet, OR nothing has changed
        ProcessNormalApplicationStartup();
    }
    else if (changeId != appsLastPersistedChangeId)
    {
        // There have been new changes since we’ve last ran, process them
        appsLastPersistedChangeId = changeId;
        ScanFolderForChanges();
    }
    else
    {
        // changeId and our last persisted change id match, also normal application startup
        ProcessNormalApplicationStartup();
    }
}
}

適用対象

こちらもご覧ください