From fdcf133d866ab36d56b8fc832689690e1850ed4f Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sun, 1 Jul 2012 13:24:18 +0300 Subject: [PATCH] RecycleManager.dll: Fixed disk error message in some cases --- Plugins/PluginRecycleManager/RecycleManager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Plugins/PluginRecycleManager/RecycleManager.cpp b/Plugins/PluginRecycleManager/RecycleManager.cpp index ba30f64f..ed491c8f 100644 --- a/Plugins/PluginRecycleManager/RecycleManager.cpp +++ b/Plugins/PluginRecycleManager/RecycleManager.cpp @@ -300,6 +300,8 @@ PLUGIN_EXPORT void ExecuteBang(void* data, LPCWSTR args) DWORD WINAPI QueryRecycleBinThreadProc(void* pParam) { + // NOTE: Do not use CRT function (since thread was created by CreateThread())! + SHQUERYRBINFO rbi = {0}; rbi.cbSize = sizeof(SHQUERYRBINFO); SHQueryRecycleBin(NULL, &rbi); @@ -383,8 +385,16 @@ CRawString GetRecycleBinDirectory(WCHAR drive, bool& isFAT) WCHAR search[] = L"\0:\\"; search[0] = drive; + // Prevent the system from displaying message box. + UINT oldMode = SetErrorMode(0); + SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); + WCHAR filesystem[16]; - if (!GetVolumeInformation(search, NULL, 0, NULL, NULL, NULL, filesystem, _countof(filesystem))) + BOOL volumeResult = GetVolumeInformation(search, NULL, 0, NULL, NULL, NULL, filesystem, _countof(filesystem))); + + SetErrorMode(oldMode); + + if (!volumeResult) { return NULL; }