Windows 右键扩展菜单实现中遇到的问题

Windows 右键扩展菜单实现中遇到的问题
 
1. 右键扩展实现目标
 
实现效果如下:
09104739-8e4651a060684244aa813660ea4222ba.png
 
    对于文本文件点击右键,在右键菜单中出现“SimpleShlExt Text Item”菜单项。
 
2. 开发环境
    Windows7  32位
    VS2005
    
3. 教程与参考资料
    《Windows Shell扩展编程完全指南》         请按照该指南的第一个例子做。
    《ATL开发指南》(用于补充学习)
 
 
4. 遇到问题
 
A.  Shell COM 从 VC6 移植到 VC2003或2005报错
       error C2787: 'IContextMenu' : no GUID has been associated with this object
    error C2440: 'initializing' : cannot convert from 'DWORD_PTR' to 'const IID *'
    error C2440: 'initializing' : cannot convert from 'ATL::_ATL_CREATORARGFUNC (__stdcall *)' to 'DWORD_PTR'
     根据博客《 Shell COM 从 VC6 移植到 VC2003或2005的问题 》中的解释:
     There are two <comdef.h> header files in VC.NET, one in Vc7/include and the other in Vc7/PlatformSDK/include. 
    The former splits off the smart pointer typedefs into comdefsp.h, and it doesn't include IContextMenu. The latter does.
    You can try to #include the PlatformSDK header directly, change your INCLUDE path order。
 
    所以下载windows较新的PlatformSDK , 5.2.3790.1830.15.PlatformSDK_Svr2003SP1_rtm,可以从微软官网直接下载
    安装后C:\Program Files\Microsoft Platform SDK\Include
    打开comdef.h文件,可以看到缺失的GUID。
    09104739-f7fc9d6b17724ba98611b7324fe0c17c.png
 
       调整include路径
        VS2005->Tools->Options
        09104740-41b09b5438e043118767c98f05c6213f.png
 
B. 编译后,注册后仍没有效果
    
    通常VS2005生成的rgs文件包含了下面的内容
09104740-fa3e1ae1efb94a31be65bc23aba48c3c.png
 
    而这三项仅仅是向注册表注册了你开发的DLL,而Explorer还不知道,也不知该在什么时候调用。
    所以要增加下面的内容。
09104740-82868d484eaa4ebfb823fe6d0d440948.png
        修改rgs文件,增加上面的内容。
        注册后,在注册表中,可以看到下面的内容。
09104741-9f120e8215a744fd9c16b9448ec76b86.png
     
    解决完这两个问题,我的右键菜单扩展功能已实现。
 




转载于:https://www.cnblogs.com/lqxinxin/archive/2013/06/09/3128222.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值