MCPcopy Create free account
hub / github.com/bumptop/BumpTop / QueryRecycleBin

Method QueryRecycleBin

trunk/win/Source/BT_WindowsOS.cpp:5858–5905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5856}
5857
5858bool WindowsSystem::QueryRecycleBin()
5859{
5860 OleInitialize(NULL);
5861 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
5862
5863 if (winOS->GetSystemPath(DesktopDirectory) == native(scnManager->getWorkingDirectory()))
5864 {
5865 HKEY recycleBinKey;
5866 TCHAR defaultIconPath[MAX_PATH];
5867 TCHAR fullIconPath[MAX_PATH];
5868 DWORD dwType = REG_SZ;
5869 DWORD dwSize = MAX_PATH;
5870
5871 LONG returnStatus = RegOpenKeyEx(HKEY_CURRENT_USER, QT_NT(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\{645FF040-5081-101B-9F08-00AA002F954E}\\DefaultIcon"), 0, KEY_QUERY_VALUE, &recycleBinKey);
5872
5873 if (returnStatus != ERROR_SUCCESS)
5874 return false;
5875
5876 while (_recyclerThread)
5877 {
5878 _recyclerThread->markAsSafeToJoin(false);
5879
5880 returnStatus = RegQueryValueEx(recycleBinKey, NULL, NULL, &dwType, (LPBYTE) &defaultIconPath, &dwSize) == ERROR_SUCCESS &&
5881 RegQueryValueEx(recycleBinKey, QT_NT(L"full"), NULL, &dwType, (LPBYTE) &fullIconPath, &dwSize) == ERROR_SUCCESS;
5882
5883 if (_memberMutex.tryLock() && returnStatus)
5884 {
5885 bool isRecycleBinFull = _isRecycleBinFull;
5886 if (_tcscmp(defaultIconPath, fullIconPath) == 0)
5887 _isRecycleBinFull = true;
5888 else
5889 _isRecycleBinFull = false;
5890
5891 _recycleBinStateChanged = (_isRecycleBinFull != isRecycleBinFull) ? true : false;
5892 _memberMutex.unlock();
5893 }
5894
5895 _recyclerThread->markAsSafeToJoin(true);
5896 Sleep(5000);
5897 }
5898 RegCloseKey(recycleBinKey);
5899 }
5900
5901 CoUninitialize();
5902 OleUninitialize();
5903
5904 return true;
5905}
5906
5907void WindowsSystem::onPowerResume()
5908{

Callers

nothing calls this directly

Calls 6

GetSystemPathMethod · 0.80
getWorkingDirectoryMethod · 0.80
markAsSafeToJoinMethod · 0.80
nativeFunction · 0.70
tryLockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected