C++ show an icon оverlay over all empty folders
I am searching for the C++ solution to show icon overlay over the folder. but I have noticed t开发者_StackOverflow中文版hat it's really bad idea to code overlays in .NET\Java +Shell because interpreter is called all the time you are using explorer.
So I have example how to do add icon over files which contains some text: http://www.codeproject.com/KB/shell/overlayicon.aspx
And I need to mark with my icon all empty folders. How can i do that?
Will appreciate any help.
You need to create a COM object that implements IShellIconOverlayIdentifier like that codeproject article.
Your IsMemberOf method would look something like this:
STDMETHODIMP YourClassThatImplementsIShellIconOverlayIdentifier::IsMemberOf(PCWSTR pwszPath,DWORD Attr)
{
if (!(Attr&FILE_ATTRIBUTE_DIRECTORY)) return S_FALSE; // Not a folder
UINT count = 0;
WIN32_FIND_DATAW wfd;
LPWSTR bufSpec = (LPWSTR) LocalAlloc(LPTR,(lstrlenW(pwszPath)+2+1)*sizeof(WCHAR));
if (bufSpec)
{
lstrcpyW(bufSpec,pwszPath);
PathAddBackslashW(bufSpec);
lstrcatW(bufSpec,L"*");
HANDLE hFind = FindFirstFileW(bufSpec,&wfd);
if (INVALID_HANDLE_VALUE!=hFind) do
{
++count;
} while( count<= 2 && FindNextFileW(hFind,&wfd) );
FindClose(hFind);
LocalFree(bufSpec);
}
return count==2 ? S_OK : S_FALSE;
}
(A empty folder contains two special entries, "." and "..")
精彩评论