现在手中有一个DLL文件:vodplayer.dll
和一些接口说明:http://www.powercom.net.cn/bbs/dispbbs.asp?boardID=5&ID=1585&page=1
现在我要在我的MFC应用程序中调用这个DLL使用其功能,没有库函数要怎么调用?
求高手指点??用COM接口??COM接口怎么使用??
求助!!!!!

解决方案 »

  1.   

    #import这个dll看看能不能导出声明文件
      

  2.   

    http://www.vckbase.com/document/viewdoc/?id=1493
    这里有组件的调用方法
      

  3.   

    CoCreateInstance()调用COM接口 
      

  4.   

    #import "VODPlayer.dll"倒出来的的是vodplayer.tlh这个文件,这个文件为:#pragma once
    #pragma pack(push, 8)
    #include <comdef.h>
    namespace VODPlayerLib {
    struct __declspec(uuid("c6856ade-ac94-46c0-b8cf-e7e6e0b7904b"))
    /* LIBID */ __VODPlayerLib;
    struct __declspec(uuid("f6707c5e-4aa6-4049-8ad0-eed90fd75b78"))
    /* dispinterface */ _IActiveXEvents;
    struct /* coclass */ ActiveX;
    struct __declspec(uuid("b18e2906-6d89-4310-9197-69bace9f3214"))
    /* dual interface */ IActiveX;_COM_SMARTPTR_TYPEDEF(_IActiveXEvents, __uuidof(_IActiveXEvents));
    _COM_SMARTPTR_TYPEDEF(IActiveX, __uuidof(IActiveX));//
    // Type library items
    //struct __declspec(uuid("f6707c5e-4aa6-4049-8ad0-eed90fd75b78"))
    _IActiveXEvents : IDispatch
    {
        // Methods:
        HRESULT PlayStateChange (
            int newState );
        HRESULT SizeChange (
            int cx,
            int cy );
        HRESULT Error ( );
    };struct __declspec(uuid("c3d8f2c7-a508-4724-bc3a-c247058d17eb"))
    ActiveX;
        // [ default ] interface IActiveX
        // [ default, source ] dispinterface _IActiveXEventsstruct __declspec(uuid("b18e2906-6d89-4310-9197-69bace9f3214"))
    IActiveX : IDispatch
    {
        //
        // Property data
        //    __declspec(property(get=GetURL,put=PutURL))
        _bstr_t URL;
        __declspec(property(get=GetuiMode,put=PutuiMode))
        _bstr_t uiMode;
        __declspec(property(get=GetfullScreen,put=PutfullScreen))
        long fullScreen;
        __declspec(property(get=GetplayState,put=PutplayState))
        long playState;
        __declspec(property(get=GetcurrentPosition,put=PutcurrentPosition))
        double currentPosition;
        __declspec(property(get=Getmute,put=Putmute))
        long mute;
        __declspec(property(get=Getvolume,put=Putvolume))
        long volume;
        __declspec(property(get=Getduration,put=Putduration))
        double duration;
        __declspec(property(get=GetcurrentPositionString))
        _bstr_t currentPositionString;
        __declspec(property(put=Putsubtitle))
        _bstr_t subtitle;
        __declspec(property(get=GetprogName,put=PutprogName))
        _bstr_t progName;
        __declspec(property(get=GetprogId,put=PutprogId))
        _bstr_t progId;
        __declspec(property(get=GetprogPath,put=PutprogPath))
        _bstr_t progPath;
        __declspec(property(get=Getserver,put=Putserver))
        _bstr_t server;
        __declspec(property(put=PutplayMode))
        short playMode;
        __declspec(property(put=Putlogonname))
        _bstr_t logonname;
        __declspec(property(put=Putlogonpass))
        _bstr_t logonpass;
        __declspec(property(put=PutStartTime))
        long StartTime;
        __declspec(property(put=PutBalance))
        long Balance;
        __declspec(property(put=PutKey))
        _bstr_t Key;
        __declspec(property(get=GetBufferProgress))
        long BufferProgress;
        __declspec(property(get=GetError))
        _bstr_t Error;
        __declspec(property(get=GettopView,put=PuttopView))
        long topView;
        __declspec(property(get=GetbufferLength,put=PutbufferLength))
        long bufferLength;
        __declspec(property(get=GetpreBufferPercent,put=PutpreBufferPercent))
        long preBufferPercent;    //
        // Wrapper methods for error-handling
        //    _bstr_t GetURL ( );
        void PutURL (
            _bstr_t pVal );
        _bstr_t GetuiMode ( );
        void PutuiMode (
            _bstr_t pVal );
        long GetfullScreen ( );
        void PutfullScreen (
            long pVal );
        long GetplayState ( );
        void PutplayState (
            long pVal );
        double GetcurrentPosition ( );
        void PutcurrentPosition (
            double pVal );
        long Getmute ( );
        void Putmute (
            long pVal );
        long Getvolume ( );
        void Putvolume (
            long pVal );
        double Getduration ( );
        void Putduration (
            double pVal );
        _bstr_t GetcurrentPositionString ( );
        HRESULT play ( );
        HRESULT stop ( );
        void Putsubtitle (
            _bstr_t _arg1 );
        _bstr_t GetprogName ( );
        void PutprogName (
            _bstr_t pVal );
        _bstr_t GetprogId ( );
        void PutprogId (
            _bstr_t pVal );
        _bstr_t GetprogPath ( );
        void PutprogPath (
            _bstr_t pVal );
        _bstr_t Getserver ( );
        void Putserver (
            _bstr_t pVal );
        void PutplayMode (
            short _arg1 );
        void Putlogonname (
            _bstr_t _arg1 );
        void Putlogonpass (
            _bstr_t _arg1 );
        void PutStartTime (
            long _arg1 );
        void PutBalance (
            long _arg1 );
        void PutKey (
            _bstr_t _arg1 );
        long GetBufferProgress ( );
        _bstr_t GetError ( );
        long GettopView ( );
        void PuttopView (
            long pVal );
        _bstr_t snap (
            _bstr_t newVal );
        HRESULT TickerOverlay (
            _bstr_t text,
            long loops );
        HRESULT BitmapOverlay (
            _bstr_t URL,
            long position,
            long transparent );
        HRESULT AdLinksTicker (
            _bstr_t text );
        HRESULT TickerOverlay2 (
            _bstr_t text,
            long loops,
            long position,
            int textcolor );
        long GetbufferLength ( );
        void PutbufferLength (
            long pVal );
        long GetpreBufferPercent ( );
        void PutpreBufferPercent (
            long pVal );    //
        // Raw methods provided by interface
        //      virtual HRESULT __stdcall get_URL (
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall put_URL (
            /*[in]*/ BSTR pVal ) = 0;
          virtual HRESULT __stdcall get_uiMode (
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall put_uiMode (
            /*[in]*/ BSTR pVal ) = 0;
          virtual HRESULT __stdcall get_fullScreen (
            /*[out,retval]*/ long * pVal ) = 0;
          virtual HRESULT __stdcall put_fullScreen (
            /*[in]*/ long pVal ) = 0;
          virtual HRESULT __stdcall get_playState (
            /*[out,retval]*/ long * pVal ) = 0;
          virtual HRESULT __stdcall put_playState (
            /*[in]*/ long pVal ) = 0;
          virtual HRESULT __stdcall get_currentPosition (
            /*[out,retval]*/ double * pVal ) = 0;
          virtual HRESULT __stdcall put_currentPosition (
            /*[in]*/ double pVal ) = 0;
          virtual HRESULT __stdcall get_mute (
            /*[out,retval]*/ long * pVal ) = 0;
          virtual HRESULT __stdcall put_mute (
            /*[in]*/ long pVal ) = 0;
          virtual HRESULT __stdcall get_volume (
            /*[out,retval]*/ long * pVal ) = 0;
          virtual HRESULT __stdcall put_volume (
            /*[in]*/ long pVal ) = 0;
          virtual HRESULT __stdcall get_duration (
            /*[out,retval]*/ double * pVal ) = 0;
          virtual HRESULT __stdcall put_duration (
            /*[in]*/ double pVal ) = 0;
          virtual HRESULT __stdcall get_currentPositionString (
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall raw_play ( ) = 0;
          virtual HRESULT __stdcall raw_stop ( ) = 0;
          virtual HRESULT __stdcall put_subtitle (
            /*[in]*/ BSTR _arg1 ) = 0;
          virtual HRESULT __stdcall get_progName (
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall put_progName (
            /*[in]*/ BSTR pVal ) = 0;
          virtual HRESULT __stdcall get_progId (
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall put_progId (
            /*[in]*/ BSTR pVal ) = 0;
          virtual HRESULT __stdcall get_progPath (
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall put_progPath (
            /*[in]*/ BSTR pVal ) = 0;
          virtual HRESULT __stdcall get_server (
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall put_server (
            /*[in]*/ BSTR pVal ) = 0;
          virtual HRESULT __stdcall put_playMode (
            /*[in]*/ short _arg1 ) = 0;
          virtual HRESULT __stdcall put_logonname (
            /*[in]*/ BSTR _arg1 ) = 0;
          virtual HRESULT __stdcall put_logonpass (
            /*[in]*/ BSTR _arg1 ) = 0;
          virtual HRESULT __stdcall put_StartTime (
            /*[in]*/ long _arg1 ) = 0;
          virtual HRESULT __stdcall put_Balance (
            /*[in]*/ long _arg1 ) = 0;
          virtual HRESULT __stdcall put_Key (
            /*[in]*/ BSTR _arg1 ) = 0;
          virtual HRESULT __stdcall get_BufferProgress (
            /*[out,retval]*/ long * pVal ) = 0;
          virtual HRESULT __stdcall get_Error (
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall get_topView (
            /*[out,retval]*/ long * pVal ) = 0;
          virtual HRESULT __stdcall put_topView (
            /*[in]*/ long pVal ) = 0;
          virtual HRESULT __stdcall raw_snap (
            /*[in]*/ BSTR newVal,
            /*[out,retval]*/ BSTR * pVal ) = 0;
          virtual HRESULT __stdcall raw_TickerOverlay (
            /*[in]*/ BSTR text,
            /*[in]*/ long loops ) = 0;
          virtual HRESULT __stdcall raw_BitmapOverlay (
            /*[in]*/ BSTR URL,
            /*[in]*/ long position,
            /*[in]*/ long transparent ) = 0;
          virtual HRESULT __stdcall raw_AdLinksTicker (
            /*[in]*/ BSTR text ) = 0;
          virtual HRESULT __stdcall raw_TickerOverlay2 (
            /*[in]*/ BSTR text,
            /*[in]*/ long loops,
            /*[in]*/ long position,
            /*[in]*/ int textcolor ) = 0;
          virtual HRESULT __stdcall get_bufferLength (
            /*[out,retval]*/ long * pVal ) = 0;
          virtual HRESULT __stdcall put_bufferLength (
            /*[in]*/ long pVal ) = 0;
          virtual HRESULT __stdcall get_preBufferPercent (
            /*[out,retval]*/ long * pVal ) = 0;
          virtual HRESULT __stdcall put_preBufferPercent (
            /*[in]*/ long pVal ) = 0;
    };//
    // Wrapper method implementations
    //#include "c:\documents and settings\administrator\桌面\test\test\debug\vodplayer.tli"} // namespace VODPlayerLib#pragma pack(pop)
    这个文件就是申明文件吗?
      

  5.   


    我现在要把这个DLL应用在一个MFC对话框的应用程序中。
    比如:我新建了一个工程Test
    我是要把导出来的这个文件复制添加到工程里面吗?然后在工程中包含这个文件?
    然后怎么调用啊?
      

  6.   

    不用拷贝生成的文件,直接在新的工程里使用 #import指令
      

  7.   

    又发了一个帖子?
    如果是一个控件的话,那么用法和一般的OCX控件的用法是一样的。
    不用导入文件这类的。
    以VS2008为例,在“工具箱”上点右键,选“选择项”,然后选“COM组件”,点“浏览”选中相应的DLL文件,相关的控件就会出现在工具箱中,然后像普通控件一样拖出来,给这个控件定义一个关联变量就行了。
    相关的C++类的生成也可以用工具生成。点“项目”中的“添加类”然后选“ActiveX中的MFC类”,在弹出的对话框中选择相应的DLL文件,会显示出这个DLL中相关的各种接口类,选择你想用的,点确定就行了。
      

  8.   


    #import "vodplayer.dll" no_namespacevoid Demo()
    {
        IXXXPtr sp;
        sp->CreateInstance();
        sp->接口函数();
    }