diff --git a/Samples/CloudMirror/CloudMirror/CloudMirror.vcxproj b/Samples/CloudMirror/CloudMirror/CloudMirror.vcxproj
index abc3eb74..89f2ac0a 100644
--- a/Samples/CloudMirror/CloudMirror/CloudMirror.vcxproj
+++ b/Samples/CloudMirror/CloudMirror/CloudMirror.vcxproj
@@ -24,33 +24,33 @@
{93C711E5-7D66-45DC-9658-4323CE0892B0}
Win32Proj
CloudMirror
- 10.0.17763.0
+ 10.0.18362.0
true
Application
true
- v141
+ v142
Unicode
Application
false
- v141
+ v142
true
Unicode
Application
true
- v141
+ v142
Unicode
Application
false
- v141
+ v142
true
Unicode
diff --git a/Samples/CloudMirror/CloudMirror/Placeholders.cpp b/Samples/CloudMirror/CloudMirror/Placeholders.cpp
index 248a5f7a..15ea87d5 100644
--- a/Samples/CloudMirror/CloudMirror/Placeholders.cpp
+++ b/Samples/CloudMirror/CloudMirror/Placeholders.cpp
@@ -114,7 +114,7 @@ void Placeholders::Create(
// This icon is just for the sample. You should provide your own branded icon here
prop.IconResource(L"shell32.dll,-44");
- wprintf(L"Applying custom state for %sx\n", relativeName.data());
+ wprintf(L"Applying custom state for %s\n", relativeName.data());
Utilities::ApplyCustomStateToPlaceholderFile(destPath, relativeName.data(), prop);
if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
@@ -131,6 +131,14 @@ void Placeholders::Create(
// certainly noteworthy for production code
}
+ if (std::wstring_view(relativeName).find(L"error") != std::wstring::npos)
+ {
+ wprintf(L"Apply error state to %s\n", relativeName.c_str());
+
+ auto placeholderPath = std::filesystem::path(destPath) / relativeName;
+ Utilities::UpdateErrorOnItem(placeholderPath.c_str(), true);
+ }
+
} while (FindNextFile(hFileHandle, &findData));
FindClose(hFileHandle);
diff --git a/Samples/CloudMirror/CloudMirror/Utilities.cpp b/Samples/CloudMirror/CloudMirror/Utilities.cpp
index 9307c405..1206abfb 100644
--- a/Samples/CloudMirror/CloudMirror/Utilities.cpp
+++ b/Samples/CloudMirror/CloudMirror/Utilities.cpp
@@ -128,4 +128,38 @@ void Utilities::ApplyCustomStateToPlaceholderFile(PCWSTR path, PCWSTR filename,
// otherwise the exception will get rethrown and this method will crash out as it should
wprintf(L"Failed to set custom state with %08x\n", static_cast(winrt::to_hresult()));
}
+}
+
+void Utilities::UpdateErrorOnItem(PCWSTR path, bool setError)
+{
+ try
+ {
+ winrt::com_ptr item;
+ winrt::check_hresult(SHCreateItemFromParsingName(path, nullptr, IID_PPV_ARGS(item.put())));
+
+ winrt::com_ptr propertyStore;
+ winrt::check_hresult(item->GetPropertyStore(GPS_READWRITE | GPS_EXTRINSICPROPERTIESONLY, IID_PPV_ARGS(propertyStore.put())));
+
+ PROPVARIANT propVar{};
+ if (setError)
+ {
+ propVar.vt = VT_UI4;
+ propVar.ulVal = static_cast(E_FAIL);
+ winrt::check_hresult(propertyStore->SetValue(PKEY_LastSyncError, propVar));
+ }
+ else
+ {
+ // Clear by setting to empty
+ propVar.vt = VT_EMPTY;
+ winrt::check_hresult(propertyStore->SetValue(PKEY_LastSyncError, propVar));
+ }
+
+ winrt::check_hresult(propertyStore->Commit());
+ }
+ catch (...)
+ {
+ // winrt::to_hresult() will eat the exception if it is a result of winrt::check_hresult,
+ // otherwise the exception will get rethrown and this method will crash out as it should
+ wprintf(L"Failed to set error state with %08x\n", static_cast(winrt::to_hresult()));
+ }
}
\ No newline at end of file
diff --git a/Samples/CloudMirror/CloudMirror/Utilities.h b/Samples/CloudMirror/CloudMirror/Utilities.h
index c0a64e67..9ddc4e96 100644
--- a/Samples/CloudMirror/CloudMirror/Utilities.h
+++ b/Samples/CloudMirror/CloudMirror/Utilities.h
@@ -13,6 +13,7 @@ class Utilities
static void AddFolderToSearchIndexer(_In_ PCWSTR folder);
static void ApplyTransferStateToFile(_In_ PCWSTR fullPath, _In_ CF_CALLBACK_INFO& callbackInfo, UINT64 total, UINT64 completed);
static void ApplyCustomStateToPlaceholderFile(_In_ PCWSTR path, _In_ PCWSTR filename, _In_ winrt::StorageProviderItemProperty& prop);
+ static void UpdateErrorOnItem(PCWSTR path, bool setError);
static winrt::com_array ConvertSidToStringSid(_In_ PSID sid)
{
diff --git a/Samples/CloudMirror/CloudMirror/stdafx.h b/Samples/CloudMirror/CloudMirror/stdafx.h
index 27dda552..acd69520 100644
--- a/Samples/CloudMirror/CloudMirror/stdafx.h
+++ b/Samples/CloudMirror/CloudMirror/stdafx.h
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
namespace winrt {
using namespace Windows::Foundation;