ok-nick / wincs

A Rust wrapper for the Windows Cloud Filter API
MIT License
16 stars 6 forks source link

Register sync root via Win32 API #5

Open ok-nick opened 2 years ago

ok-nick commented 2 years ago

Currently, wincs is using the StorageProviderSyncRootInfo class to register new sync roots. Unfortunately, as this is a UWP API, you must use HSTRINGs and IBuffers, all of which require extra allocations and needless error checking unless manually implemented.

Manually implementing these interfaces and classes is doable, although mostly bloat. The solution is to use the Win32 API directly via CfRegisterSyncRoot and to register it with the shell via these docs.

There are a few things only documented in the UWP and a few things only documented in the Win32 API. For example, CfRegisterSyncRoot comes with a CF_REGISTER_FLAGS field. In the UWP API, StorageProviderSyncRootInfo comes with AllowPinning, FallbackFileTypeInfo, IconResource, ProtectionMode, RecycleBinUri, ShowSiblingsAsGroup, and StorageProviderItemPropertyDefinitions, many of which can be manually set through the registry, and a few others that cannot.

Some of the UWP-only fields abovementioned are not documented, although you can find most of them in the registry. I'll post the issues so that they could be officially documented.

ok-nick commented 2 years ago

Microsoft Q&A issue here