当前位置:编程学习 > C#/ASP.NET >>

VS2005 和 VS2008 问题

同样是一段windows shell扩展程序,在vs2008下运行就没问题,在vs2005环境下运行会出现如下问题
error C2787: 'IExtractIconW' : 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'

我想在vs2005下运行成功,请问该如何解决,更新sdk么(如何更新)?还是另有高招? --------------------编程问答-------------------- 可能是使用的netframework版本的原因 --------------------编程问答-------------------- 关键的问题是以下头文件没有包含正确
 
#include "shlobj.h"
 
#include "comdef.h"
 
#include <shlguid.h>
 
下面是收集的一些问题解决过程:
 
1、Have you downloaded the Latest Platfrom SDK? If so, are your vc dirs pointing to the proper include dirs, eg: shlguid.h is getting picked up from the SDK\include and not the vc98\include. You set those in the tools-Options->directories->include dirs for VC
 
2、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, or supply the missing typedef yourself, e.g.
 
struct __declspec(uuid("000214e4-0000-0000-c000-000000000046"))
 
IContextMenu;
 
_COM_SMARTPTR_TYPEDEF(IContextMenu, __uuidof(IContextMenu));
 
3、怎样找到Interface的GUID?
 
我在注册表 HKCR\Interface\ 下可以找到形式为
 
{aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee}的键,如果其下有默认项="Interface",则说明这个键就是该Interface的GUID。
 
有没有其它方法?
 
(1) VC6\common\Tools 下有个OLE/COM Object Viewer 很方便,但在VC2005下就没找到这个工具
 
(2) PlatformSDK\include\comdef.h 中也有GUID的定义
 
4、__uuidof它是C++ 运算符
 
[总结]
 
如上所述,如果把PlatformSDK/include放在前面仍然不可以的话,就下载新的SDK,把include目录包含进去就好了。个人感觉手动添加这些uuid值如,struct __declspec(uuid("000214e4-0000-0000-c000-000000000046"))
 
IContextMenu;
 
_COM_SMARTPTR_TYPEDEF(IContextMenu, __uuidof(IContextMenu));
 
过了这个村,还会有下个店,还不如直接更新一下SDK来得直接保险。
--------------------编程问答-------------------- lz很厉害啊,我来蹭分了。

不过一般downgrade可能都会 有问题。 --------------------编程问答-------------------- 可能是版本的原因,调试一下试试咯,。 --------------------编程问答-------------------- 可能是版本的原因,在VS2005打上netframework3.0补丁试试 --------------------编程问答-------------------- VS2005和VS2008的版本不一样,相应的库也就有区别
另外也有可能是netframework的问题,我用的是3.5版的,再不行再升级SP1试试 --------------------编程问答--------------------
引用 2 楼 abc86269456 的回复:
关键的问题是以下头文件没有包含正确
 
#include "shlobj.h"
 
#include "comdef.h"
 
#include <shlguid.h>
 
下面是收集的一些问题解决过程:
 
1、Have you downloaded the Latest Platfrom SDK? If so, are your vc dirs pointing to th……

谢谢分享~ --------------------编程问答-------------------- 用的是VS2010,2010好多优化过了,用时没问题 --------------------编程问答-------------------- vs2005我也用不惯~~~ --------------------编程问答-------------------- VS2005和VS2008的版本不一样,相应的库也就有区别 --------------------编程问答-------------------- --------------------编程问答-------------------- 我机器安完VS2005后VS2008就安不上了 --------------------编程问答-------------------- 谢谢分享
引用 2 楼 abc86269456 的回复:
关键的问题是以下头文件没有包含正确
 
#include "shlobj.h"
 
#include "comdef.h"
 
#include <shlguid.h>
 
下面是收集的一些问题解决过程:
 
1、Have you downloaded the Latest Platfrom SDK? If so, are your vc dirs pointing to t……
--------------------编程问答-------------------- 有些函数的参数变了,尤其是vs2008 sp1里面,很多类库都升级了 --------------------编程问答--------------------
引用 4 楼 dcymfh 的回复:
可能是版本的原因,调试一下试试咯,。
版本不同呀   --------------------编程问答-------------------- 这个我也要多 注意,也面临vs2005与vs2008的取舍 --------------------编程问答--------------------
补充:.NET技术 ,  VC.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,