shell扩展的例子,典型的例子是下面的应用
https://blog.csdn.net/gdruhv/article/details/83778647
这里面的代码是可以下载的,不过要50积分。
下周后,32位的可以编译过,但是64位的就编译不过了,提示下面这样的错误:
1> ImportShellExt.cpp
1>D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\atlcom.h(3448): error C2259: 'ATL::CComContainedObject<contained>': cannot instantiate abstract class
1> with
1> [
1> contained=CImportShellExt
1> ]
1> D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\atlcom.h(3448): note: due to following members:
1> D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\atlcom.h(3448): note: 'HRESULT IContextMenu::GetCommandString(UINT_PTR,UINT,UINT *,CHAR *,UINT)': is abstract
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\shobjidl.h(2767): note: see declaration of 'IContextMenu::GetCommandString'
很明显说的是函数HRESULT IContextMenu::GetCommandString(UINT_PTR,UINT,UINT *,CHAR ,UINT)没有实现,看下代码中的函数声明,如下所示:
STDMETHOD(GetCommandString)(UINT, UINT, UINT, LPSTR, UINT);
仔细观察下,还真不一样,在于第一个参数UINT_PTR和UINT,64位编译的时候,这两个参数的定义是不一样的,其中UINT_PTR的定义如下:
typedef unsigned __int64 UINT_PTR, PUINT_PTR;
而UINT的定义如下:
typedef unsigned int UINT;
所以需要将STDMETHOD(GetCommandString)(UINT, UINT, UINT, LPSTR, UINT);里面的UINT修改为UINT_PTR即可