IDL文件里面是如下内容
//---------------------------------------------------------------------
import "oaidl.idl";
import "ocidl.idl";
import "unknwn.idl";
import "oleidl.idl";
import "urlmon.idl";[ object,
uuid(988934A4-064B-11D3-BB80-00104B35E7F9),

helpstring("IIDownloadManager Interface"),
pointer_default(unique),
local
]
interface IIDownloadManager : IUnknown
{
HRESULT Download(
        [in] IMoniker *pmk,         // Identifies the object to be downloaded
        [in] IBindCtx *pbc,         // Stores information used by the moniker to bind 
        [in] DWORD dwBindVerb,      // The action to be performed during the bind
        [in] LONG grfBINDF,         // Determines the use of URL encoding during the bind
        [in] BINDINFO *pBindInfo,   // Used to implement IBindStatusCallback::GetBindInfo
        [in] LPCOLESTR pszHeaders,  // Additional headers to use with IHttpNegotiate
        [in] LPCOLESTR pszRedir,    // The URL that the moniker is redirected to
        [in] UINT uiCP              // The code page of the object's display name
    ); };[
uuid(F235EC7A-4D21-44B8-8143-EFB9C134B18F),
version(1.0),
helpstring("FinalTest 1.0 Type Library")
]
library FINALTESTLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb"); [
uuid(CE74899B-1315-4919-83FE-003FCE8FC528),
helpstring("IDownloadManager Class")
]
coclass IDownloadManager
{
[default] interface IIDownloadManager;
};
};
//-----------------------------------------------------------------------------------------------
编译出错:
error MIDL2139 : type of the parameter cannot derive from void or void * : [ Type 'LPVOID' ( Parameter 'pBindInfo' ) ]
Error executing midl.exe.然后我参照了另外一种写法,加了LOCAL,但是出现另外的错误:
D:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : error C2259: 'CComObject<class CIDownloadManager>' : cannot instantiate abstract class due to following members:
        D:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class ATL::CComObject<class CIDownloadManager> >::CreateInstance(void *,const struct _
GUID &,void ** )'
D:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : warning C4259: 'long __stdcall IIDownloadManager::Download(struct IMoniker *,struct IBindCtx *,unsigned long,long,struct _tagBINDINFO *,const unsigned short *,const unsigned 
short *,unsigned int)' : pure virtual function was not defined
        G:\COM组件开发\FinalTest\FinalTest.h(80) : see declaration of 'Download'
        D:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class ATL::CComObject<class CIDownloadManager> >::CreateInstance(void *,const struct _
GUID &,void ** )'
D:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : error C2259: 'CComObject<class CIDownloadManager>' : cannot instantiate abstract class due to following members:
        D:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class ATL::CComObject<class CIDownloadManager> >::CreateInstance(void *,const struct _
GUID &,void ** )'
D:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : warning C4259: 'long __stdcall IIDownloadManager::Download(struct IMoniker *,struct IBindCtx *,unsigned long,long,struct _tagBINDINFO *,const unsigned short *,const unsigned 
short *,unsigned int)' : pure virtual function was not defined
        G:\COM组件开发\FinalTest\FinalTest.h(80) : see declaration of 'Download'
        D:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class ATL::CComObject<class CIDownloadManager> >::CreateInstance(void *,const struct _
GUID &,void ** )'这个接口一定要实现才行啊,但是我真的不知道应该怎么做了,请高手帮忙啊!!!

解决方案 »

  1.   

    看样子是你 import 的idl中没有包含 BINDINFO 结构体的定义....如果实在找不到 BINDINFO 是那个idl中定义的,你干脆把它定义到你这个idl中算了。
      

  2.   

    BINDINFO 是存在于urlmon.idl中的我是按照这样http://dev.csdn.net/article/74/74767.shtm这个页面的步骤去实现的,但是第一步却出现这样的问题。//-----------------------------------------------------------------------------------------------------------
    Implemented IDownloadManagerIDownloadManager有一个成员函数,原型如下,HRESULT Download(         
     IMoniker *pmk,
        IBindCtx *pbc,
        DWORD dwBindVerb,
        LONG grfBINDF,
        BINDINFO *pBindInfo,
        LPCOLESTR pszHeaders,
        LPCOLESTR pszRedir,
        UINT uiCP
    );IMoniker,IBindCtx,BINDINFO,可能会比较麻烦,没关系,这里有现成的,
    http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip
    (引用页,http://www.mvps.org/emorcillo/en/code/vb6/wbframe.shtml)
    有源码,可以自己编译,然后那个odl文件这样写就行了,interface IDownloadManager;
    [
        odl,
        uuid(988934A4-064B-11D3-BB80-00104B35E7F9), // IID_IDownloadManager
    ]
    interface IDownloadManager : IUnknown
    {
        HRESULT Download(
            [in] IMoniker *pmk,         // Identifies the object to be downloaded
            [in] IBindCtx *pbc,         // Stores information used by the moniker to bind
            [in] LONG dwBindVerb,      // The action to be performed during the bind
            [in] LONG grfBINDF,         // Determines the use of URL encoding during the bind
            [in] BINDINFO *pBindInfo,   // Used to implement IBindStatusCallback::GetBindInfo       
            //[in] LPCOLESTR pszHeaders,  // Additional headers to use with IHttpNegotiate
            [in] long pszHeaders,
            //[in] LPCOLESTR *pszRedir,    // The URL that the moniker is redirected to
            [in] long pszRedir,
            [in] LONG uiCP              // The code page of the object's display name
        );
    };
    //----------------------------------------------------------------------------------------------------------------