tags:

views:

252

answers:

2

I read this article in http://www.codeproject.com/KB/shell/overlayicon.aspx. I have some questions that I cannot answer. Please help me?

  1. When I build the project to COM dll. When I use other program to call this dll. Which method could I will call to display overlay icon on the selected file? I think I will call GetOverlayInfo() first and call IsMemberOf()? Just 2 functions?
  2. In the GetOverlayInfo(). Will I pass what value in the first parameter? the path of the overlay icon? or the path of the file which will be setted overlay icon on it? Could u give me an example?
  3. In the below function:

    STDMETHODIMP CMyOverlayIcon::GetOverlayInfo(
        LPWSTR pwszIconFile,
        int cchMax,int* pIndex,
        DWORD* pdwFlags)
    {
     GetModuleFileName(_AtlBaseModule.GetModuleInstance(),pwszIconFile,cchMax);
    
    
     *pIndex =0;
     *pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX;
    
    
     return S_OK;
    }
    

Could u tell me could I pass what value to the function when I call it from outside program. Could u give me an example how to call it and transfer value to it?

  1. pwszIconFile
  2. cchMax
  3. pIndex
  4. pdwFlags (Could I pass which value when I call it from outside. Ex C# program)
+1  A: 
  1. Yes, you can get away with just the two functions. But I would call GetPriority() anyway, even if you don't use the return value. You'll never know whether the overlay handler relies on that call or not (if you haven't written it yourself). And you only need to call GetOverlayInfo() once, but IsMemberOf() for every file you want to show the overlay icon for.
  2. You have to pass an (empty) buffer and in cchMax the length of the buffer. The Overlay handler will then fill the buffer with the path of the icon file. But you also have to check the pdwFlags and pIndex (both are filled by the overlay handler too) - depending on the flags set in pdwFlags, you either get a path to an icon file in pwszIconFile or a path to an exe file which contains the icon in its resources. If the latter, then the pIndex value is the resource index of the icon in the exe file you have to load.

You didn't say why you want to call the overlay handlers yourself. If you simply want to show the icons as explorer does in some list view or dialog, you can use a much easier route where you don't need to read the registry where all the overlay handlers are registered (and some of the system overlays aren't even registered there!).

Have a look at KB192055, maybe that's a better way for what you need?

Stefan
Thanks Stefan very very much. I have a more question . COuld you help me?Could you give me an sample snip code write in c++ (or C# ) call the functions of the OverlayIcon.dll to display overlay icon on the file?I am developing an program that have fucntion displaying the overlay icon on the selected file - the certain file that I right-click on it.Could you help me? Im very grateful to you.Thanks in advance.
Sean
just use the code example from KB192055 linked above. This would do what you want (just don't use "*.lnk" but the real extension of the file you want the icon with overlay for).
Stefan
Thanks Stefan very much, I read it. But could you explain to me how can I call this function to enable overlay icon on the selected file. Could you give me an sample snippets. Thanks advance
Sean
A: 

Thanks Stefan very very much. I have a more question . COuld you help me?

Could you give me an sample snip code write in c++ (or C# ) call the functions of the OverlayIcon.dll to display overlay icon on the file?

I am developing an program that have fucntion displaying the overlay icon on the selected file - the certain file that I right-click on it.

Could you help me? Im very grateful to you.

Thanks in advance.

Sean