能力值:
( LV10,RANK:170 )
2 楼
仅凭这两句很难知道什么问题.
修改图标?是不是在图标上覆盖一个小图标?
能力值:
( LV2,RANK:10 )
3 楼
恩!!
是覆盖一个小图标,通过win shell,请问能否实现么!
能力值:
( LV10,RANK:170 )
4 楼
可以实现,需要继承IShellIconOverlayIdentifier接口, 如下:
.H
====================================================================
class ATL_NO_VTABLE CMyOverlayIcon :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMyOverlayIcon, &CLSID_MyOverlayIcon>,
public IDispatchImpl<IMyOverlayIcon, &IID_IMyOverlayIcon, &LIBID_OverlayIconLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public IShellIconOverlayIdentifier
{
public:
CMyOverlayIcon()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_MYOVERLAYICON) BEGIN_COM_MAP(CMyOverlayIcon)
COM_INTERFACE_ENTRY(IMyOverlayIcon)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IShellIconOverlayIdentifier)
END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT()
// IShellIconOverlayIdentifier Methods
STDMETHOD(GetOverlayInfo)(LPWSTR pwszIconFile,int cchMax,int *pIndex,DWORD* pdwFlags);
STDMETHOD(GetPriority)(int* pPriority);
STDMETHOD(IsMemberOf)(LPCWSTR pwszPath,DWORD dwAttrib);
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
};
OBJECT_ENTRY_AUTO(__uuidof(MyOverlayIcon), CMyOverlayIcon)
.CPP
===================================================================
STDMETHODIMP CMyOverlayIcon::GetOverlayInfo(
LPWSTR pwszIconFile,
int cchMax,int* pIndex,
DWORD* pdwFlags)
{
GetModuleFileNameW(_AtlBaseModule.GetModuleInstance(), pwszIconFile, cchMax);
*pIndex = 0;
*pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX;
return S_OK;
}
// IShellIconOverlayIdentifier Method Implementation
// returns the priority of this overlay 0 being the highest.
// this overlay is always selected do to its high priority
STDMETHODIMP CMyOverlayIcon::GetPriority(int* pPriority)
{
// highest priority
*pPriority=0;
return S_OK;
}
// IShellIconOverlayIdentifier Method Implementation
// IShellIconOverlayIdentifier::IsMemberOf
// Returns Whether the object should have this overlay or not
STDMETHODIMP CMyOverlayIcon::IsMemberOf(LPCWSTR pwszPath, DWORD dwAttrib)
{
wchar_t *s = _wcsdup(pwszPath);
HRESULT r = S_FALSE;
_wcslwr(s);
// Criteria
if (wcsstr(s, L"thinksj") != 0)
r = S_OK;
free(s);
return r;
}
但是感觉这个接口不是很方便, 需要先从GetOverlayInfo函数中将图标索引返回给Shell,然后再通过IsMemberOf函数判断是否显示
这个例子改自CodeProject上的一段代码,链接忘了.
能力值:
( LV2,RANK:10 )
5 楼
谢谢,我在vc上试了下,好象有点问题!!
能力值:
( LV2,RANK:10 )
6 楼
哈哈!
总与搞定了!!
万分感谢!!