microsoft / Windows-classic-samples

This repo contains samples that demonstrate the API used in Windows classic desktop applications.
Other
5.1k stars 3.24k forks source link

CloudMirror doesn't provide an example of IStorageProviderCopyHook implementation #290

Open dmitryshunkov opened 1 year ago

dmitryshunkov commented 1 year ago

The documentation for CloudMirror was updated to reflect the support of IStorageProviderCopyHook interface by cloud files API. The interface is not documented. I tried to implement it without success. Only the constructor and destructor of the custom implementation are getting called, but not the CopyCallback method. Example code:

#include "stdafx.h"
#include "StorageProviderCopyHook.h"

StorageProviderCopyHook::StorageProviderCopyHook()
{
    wprintf(L"StorageProviderCopyHook constructor called\n");
}

StorageProviderCopyHook::~StorageProviderCopyHook()
{
    wprintf(L"StorageProviderCopyHook destructor called\n");
}

IFACEMETHODIMP StorageProviderCopyHook::CopyCallback(_In_ HWND hwnd, _In_ UINT operation, _In_ UINT flags, _In_ LPCWSTR srcFile, _In_ DWORD srcAttribs, _In_ LPCWSTR destFile, _In_ DWORD destAttribs, _Out_ UINT* result)
{
    wprintf(L"StorageProviderCopyHook CopyCallback called\n");
    return E_NOTIMPL;
}

Produces next output on file renaming:

StorageProviderCopyHook constructor called
StorageProviderCopyHook destructor called
Thumbnail requested for....

So, CopyCallback never gets called. Please, provide an example of working IStorageProviderCopyHook implementation in the CloudMirror sample.

wangfu91 commented 1 year ago

@dmitryshunkov The doc says:

The Shell calls the cloud provider's copy hook handler for every folder under the registered sync root.

renaming file won't trigger the CopyCallback, try rename a folder.