COM DLL/Activex控件 [英] COM DLL/ Activex Control

查看:146
本文介绍了COM DLL/Activex控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在另一个Win32 DLL中使用COM DLL还是Activex控件.我有一个COM DLL,我想在另一个Win 32 Dll中使用它,所以我可以这样做,如果可以告诉我如何在Win32 Dll中使用dispinterface的方法. class ="h2_lin">解决方案

是的,您可以在Win32 dll中使用ComDLL.

#import" ComDLL.dll "
void main()
{
CCOmPtr< NameSpace :: InterFaceName > ; pMyInterFacePtr;
HRESULT hr = pMyInterFacePtr.CoCreateInstance(__ uuidof( coclass ));
//现在pMyInterFacePtr只是实现了您的接口的类的实例. /您现在可以使用该接口的所有方法.
}

有很多创建接口实例的方法-:)您还可以使用CLSID创建该接口的实例.

现在,当您说如何在Win32 Dll中使用dispinterface的方法"时,我不太清楚. ?

您能详细说明一下吗,因为您可以使用IDispatch :: Invoke()方法调用dispinterface的方法.

由于您具有COM接口,因此应该已经实现了IUnknown(可能还实现了IDispatch) ,如果该接口也实现了IDispatch,那么您将能够看到Invoke方法,该方法将为您调用dispinterface的方法.












Can we use COM DLL or Activex Control in another Win32 DLL. I have one COM DLL I want to use it in another Win 32 Dll, So can I do this ,if can then tell me how can I use dispinterface's methods in my Win32 Dll.

Thanks in advance,

解决方案

Yes, you can use a ComDLL in a win32 dll.

#import "ComDLL.dll"
void main()
{
    CCOmPtr<NameSpace::InterFaceName> pMyInterFacePtr;
    HRESULT hr = pMyInterFacePtr.CoCreateInstance(__uuidof(coclass));
    //Now pMyInterFacePtr is nothing but the instance of the class that has implemented your interface.
    //You can use all the methods of that interface now.
}

There are quite a lot of ways to create an instance of the interface -:) You can as well use CLSID for creating the instance of the coclass perhaps depends on the way you import the dll.

Now i am not quite clear when you say "how can I use dispinterface's methods in my Win32 Dll" ?

Can you elaborate on this because you can invoke the dispinterface's methods using IDispatch::Invoke() method.

Since you have your COM Interface, that should have implemented IUnknown ( and possibly IDispatch ), if the interface has implemented IDispatch too then you would be able to see the Invoke method that would call the dispinterface's methods for you.











这篇关于COM DLL/Activex控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆