共用方式為


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

如果有變更,有效的變更識別碼 (> 0) 。

如果在上次讀取之後沒有變更,或尚未發生任何變更,則傳回 0。

如果變更追蹤器無法計算變更識別碼,或發生太多檔案變更,且此值溢位,則會傳回 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();
    }
}
}

適用於

另請參閱