在VC.NET里怎么调用一个封装在DLL里的COM组件啊,谢谢!!!
我只有一个DLL,还知道他的几个方法,别的都不知道了,不太懂应该怎么操作,谢谢!!!

解决方案 »

  1.   

    没有头文件?DLL注册了没有,如果注册了,而且Com组件是自动化的,那么只要知道里面的方法,参数等。没有头文件也可以,使用IDispatch接口调用就可以了。
      

  2.   

    对.NET项目->添加引用->浏览->打开DLL的COM组件ok
      

  3.   

    to steedhorse:
          dll注册过了,没有头文件,用IDispatch接口怎么调用?能给一点示例代码么?我刚刚接触COM,对一些接口的概念有的模糊,请大家多多指教,谢谢!
    to   uno:
         用引用没有用,在C#项目里面有用能看到接口,在VC++项目里面就看不到,不知道为什么?
      

  4.   

    没有TLB文件,Import进去有用么?
      

  5.   

    用OLE View看了,有接口,但是就是不行
    queryInterface中的GUID 和IID应该是那个啊,下面是我的IDL文件:
    // Generated .IDL file (by the OLE/COM Object Viewer)
    // 
    // typelib filename: image.dll[
      uuid(710993A2-4F87-41D7-B6FE-F5A20368465F),
      version(1.0),
      helpstring("Image 1.0 Type Library"),
      custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 83951780),
      custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 1079412854)]
    library ImageLib
    {
         importlib("stdole2.tlb");    // Forward declare all types defined in this typelib
        interface IAnimator;    [
          uuid(06ADA938-0FB0-4BC0-B19B-0A38AB17F182),
          helpstring("Animator Class")
        ]
        coclass Animator {
            [default] interface IAnimator;
        };    [
          odl,
          uuid(0C1CF2DF-05A3-4FEF-8CD4-F5CFC4355A16),
          helpstring("IAnimator Interface"),
          dual,
          nonextensible,
          oleautomation
        ]
        interface IAnimator : IDispatch {
            [id(0x00000001), helpstring("method LoadFromFile")]
            HRESULT LoadFromFile([in] BSTR FileName);
           };
    };