Pelles C forum
C language => Beginner questions => Topic started by: Jokaste on May 08, 2019, 02:59:00 AM
-
This program explains how to use SHGetKnownFolderPath (https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath).
It runs under Windows 10. Could run under Windows 7 & 8 but that's all.
LPSTR GetSpecialFolder(REFKNOWNFOLDERID rfid,LPSTR __lpszResult)
{
LPWSTR _lpwszPath = NULL ;
HRESULT _hr = SHGetKnownFolderPath(rfid,KF_FLAG_CREATE,NULL,&_lpwszPath) ;
if(SUCCEEDED(_hr))
{
WideCharToMultiByte(CP_UTF8,0,_lpwszPath,lstrlenW(_lpwszPath),__lpszResult,MAX_PATH,NULL,NULL) ;
return (__lpszResult) ;
}
return (NULL) ;
}
It cleans many folders :
- Internet cache
- History
- CD Burning cache
- Cookies
- Printers cache
- Recents Documents
- Applications updates
- Downloaded files
- Searches
- Searches history
- Downloaded Program Files
- Prefetch
- Software Distribution
It empties all recyclebins
Launches Dism.exe (https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/deployment-image-servicing-and-management--dism--command-line-options) to clean WinSxS
You must run the program wih Administrator privileges.