19

Now that Microsoft have reinstated OneDrive in the file system in Windows 10 (and assuming they don't drop it again in 6 months time), I'm looking for how to determine the sync status of an arbitrary file.

There are at least five different states shown in Explorer (this is just what I've observed, there may be others):

  • Available when online Available when online
  • Available on this device Available on this device
  • Always available on this device Always available on this device
  • Syncing / downloading Syncing / downloading
  • Error Error

The first two states, for a file, can be determined using the FILE_ATTRIBUTE_OFFLINE attribute.

It seems that the "Always available" state can be determined for a file using a new, undocumented file attribute 0x00080000.

Determining these states for folders, and the syncing and error states for both files and folders, however remains a mystery.

My first thought was using the property system (IPropertyStore), but the following four property keys all failed to help:

  • PKEY_OfflineAvailability returns VT_EMPTY
  • PKEY_OfflineStatus returns VT_EMPTY
  • PKEY_FilePlaceholderStatus returns an undocumented value (0xe) but it doesn't change when the status does
  • PKEY_FileOfflineAvailabilityStatus returns VT_EMPTY

I have a feeling this is going to turn out to be just another undocumented Microsoft API but I thought I'd ask to see if anyone has any suggestions.

10
  • 2
    My experiences tend to show that it's the undocumented PKEY_StorageProviderState ({e77e90df-6271-4f5b-834f-2dd1f245dda4} 3) that seems to contain some (undocumented also) enum value.There is a mention of this property in ShObjIdl.idl but what I see doesn't seem to correspond to the values of SYNC_ENGINE_STATE_FLAGS. Note the latest SDK has also a new cfapi.h ("cloud file" API) that could be interesting too... Commented Oct 23, 2017 at 16:27
  • 1
    There is Determining availability of Microsoft OneDrive files, but all the APIs used require an app identity. The reason for this is not immediately apparent to me. Commented Oct 23, 2017 at 16:53
  • 2
    and BTW, 0x80000 is FILE_ATTRIBUTE_PINNED (from winnt.h, appeared in Creators Update SDK 10.0.15063.0) whatever that could mean... Commented Oct 24, 2017 at 7:03
  • 1
    @SimonMourier Ah ha, interesting. I don't have that in my Win10 SDK, will have to check why the latest version hasn't installed. I found this from your mention of cfapi.h so I suspect this is the right track to take. Thanks! Commented Oct 24, 2017 at 7:58
  • 2
    Hey @JonathanPotter, were you able to solve your problem? If so, could you please share some code? I need the same thing. Commented Sep 1, 2020 at 14:28

2 Answers 2

3

I tried reverse-engineering it on Windows 11 22H2 and this is what I found:

Two properties appear different when a file is still syncing:

  • System.FilePlaceholderStatus is 15 when done, and 7 when still syncing. E.g. 0x8 bit set == done syncing.
  • System.SyncTransferStatusFlags is 1 when syncing and is 0 or null otherwise.
Sign up to request clarification or add additional context in comments.

Comments

1

As a minor contribute I can add that while developing an UWP app I had the challenge to retrieve the status. What I found is: 14: available locally; 15: always available locally (still have to understand th difference with 14) 8: available on cloud.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.