Creating Icon Overlay handlers

Source: Internet
Author: User

Create icon marker handlers (cont.)

1. Create a new ATL Project.

2, it is recommended that the Project property in Linker–general-"Register Output" set to No,c/c++-"Code Generation"-"Runtime Library" is set to/MTD.

3. Right-click Add Class in Solution Explorer and select ATL simple Object. and name the Class in the dialog box that pops up.

4, add after the completion of the proposed build Project,midl compiler will generate IIDs and CLSIDs based on the. idl file.

5. Switch to the new Class. h file to inherit the interface Ishelliconoverlayidentifier.

1 //myoverlay.h:declaration of the Cmyoverlay2 3 #pragmaOnce4#include"resource.h"       //Main symbols5 6 7 8#include"example_i.h"9#include <ShlObj.h>Ten  One  A  - #ifDefined (_WIN32_WCE) &&!defined (_ce_dcom) &&!defined (_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) - #error"Single-threaded COM objects is not properly supported on Windows CE platform, such as the Windows Mobile platforms that Do is include full DCOM support. Define _ce_allow_single_threaded_objects_in_mta to force ATL to support creating Single-thread COM object ' s and allow use Of it ' s single-threaded COM object implementations. The threading model in your RGS file were set to ' free ' as that's the only threading model supported in non DCOM Windows C E platforms. " the #endif -  - using namespaceATL; -  +  - //Cmyoverlay +  A classatl_no_vtable Cmyoverlay: at      PublicCcomobjectrootex<ccomsinglethreadmodel>, -      PublicCcomcoclass<cmyoverlay, &CLSID_MyOverlay>, -      PublicIdispatchimpl<imyoverlay, &iid_imyoverlay, &Libid_examplelib, -     /*wmajor =*/ 1,/*Wminor =*/ 0>, -      PublicIshelliconoverlayidentifier - { in  Public: - Cmyoverlay () to     { +     } -  the Declare_registry_resourceid (Idr_myoverlay) *  $ Panax Notoginseng Begin_com_map (Cmyoverlay) - com_interface_entry (Imyoverlay) the com_interface_entry (IDispatch) + com_interface_entry (ishelliconoverlayidentifier) A End_com_map () the  +  -  $ declare_protect_final_construct () $  - stdmethod (ismemberof) (This_ _in_ pcwstr pwszpath, DWORD dwattrib); - stdmethod (getoverlayinfo) (This_ _out_writes_ (Cchmax) pwstr Pwsziconfile, the         intCchmax, _out_int* Pindex, _out_ DWORD *pdwflags); -STDMETHOD (getpriority) (This_ _out_int*pipriority);Wuyi  the HRESULT finalconstruct () -     { Wu         returnS_OK; -     } About  $     voidfinalrelease () -     { -     } -  A  Public: +  the  -  $ }; the  theObject_entry_auto (__uuidof (Myoverlay), Cmyoverlay)
MyOverlay.h

6. Implement the Class according to MSDN.

1 //MyOverlay.cpp:Implementation of Cmyoverlay2 3#include"stdafx.h"4#include"MyOverlay.h"5#include <WinBase.h>6 #pragmaComment (lib, "Kernel32.lib")7 8 //Cmyoverlay9 Ten stdmethodimp Cmyoverlay::ismemberof (this_ _in_ pcwstr pwszpath, DWORD dwattrib) One { A     if(_TCSCMP (Pwszpath, L"Test") ==0) -     { -         returnS_OK; the     } -     Else -     { -         returnS_FALSE; +     } - } +  A stdmethodimp Cmyoverlay::getoverlayinfo ( at this_ _out_writes_ (Cchmax) pwstr Pwsziconfile, -     intCchmax, -_out_int*Pindex, -_out_ DWORD *pdwflags) - { -      in Getmodulefilenamew (_atlbasemodule.getmoduleinstance (), Pwsziconfile, Cchmax); -  to*pindex =0; +  -*pdwflags = Isioi_iconfile |Isioi_iconindex; the  *     returnS_OK; $ }Panax Notoginseng  -STDMETHODIMP Cmyoverlay::getpriority (This_ _out_int*pipriority) the { +*pipriority =0; A  the     returnS_OK; +}
MyOverlay.cpp

7. Add the registry information in the. rgs file to ensure that each GUID is consistent with the. idl file.

1 HKCR2 {3 Noremove CLSID4     {5ForceRemove {29913677-1662-46c5-8645-16f84da6f438} = S'Myoverlay Class'6         {7 ForceRemove Programmable8InprocServer32 = S'%MODULE%'9             {TenVal ThreadingModel = s'Apartment' One             } ATypeLib = S'{942f4dbb-4667-4767-a35b-52f32f623c63}' -Version = S'1.0' -         } the     } - } -  - HKLM + { - Noremove Software +     { A Noremove Microsoft at         { - Noremove Windows -             { - Noremove CurrentVersion -                 { - Noremove Explorer in                     { - Noremove shelliconoverlayidentifiers to                         { +ForceRemove'Myoverlay'= S'{29913677-1662-46c5-8645-16f84da6f438}' -                             { the                             } *                         } $                     }Panax Notoginseng                 } -             } the         } +     } A}

8. Build Project After you register or unregister the generated. dll file by Cmd.exe. Effective after restarting Explorer.exe.

9, because the number of slots is limited, check whether the subkey added in the registry is within the valid range (currently the first 15). You can advance the position of a child by adding a space before the name.

10. See the effect as shown.

Reference URL: http://www.codeproject.com/Articles/7484/How-to-overlay-an-icon-over-existing-shell-objects

—————————————————————————————————————

This article for my original, if you need to reprint please indicate the source.

Creating Icon Overlay handlers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.