佚名通过本文主要向大家介绍了com idl,com idl connect,idl,idl是什么意思,envi idl技术殿堂等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: idl和COM组件的一个菜鸟级问题
描述:
解决方案1:
描述:
[
uuid(B24262D5-0FBF-48CC-816A-FB2AD85E398D),
version(1.0),
helpstring("A")
]
library ALib
[
..............
..............
#include"B.idl"
#include"C.idl"
]
如上边所举的例子,是不是可以这样理解。
1.library ALib所在的IDL可以理解为一个COM组件,而B.idl和C.idl则可以理解为相应的接口。
2.是不是可以使用B接口的对象指针调用QueryInterface函数找到C接口,或是用C调到B.
谢谢~~~
解决方案1:
library ALib是一上COM组件。而不是所在的IDL是一个组件。
组件中可以定义多个接口,再定义类继承你所定义的一个或多个接口,实现接口定义的方法。
这里有一个组件和接口定义的事例,你可以参考一下。
// ProcessManager.idl : IDL source for ProcessManager.dll解决方案2:
//
// This file will be processed by the MIDL tool to
// produce the type library (ProcessManager.tlb) and marshalling code.
import "oaidl.idl";
import "ocidl.idl";
#include "olectl.h"
[
object,
uuid(F328C384-8063-424D-B03A-EAB3A348CDAC),
dual,
helpstring("IProcessList Interface"),
pointer_default(unique)
]
interface IProcessList : IDispatch
{
[id(1), helpstring("method ShowProcessListDlg")] HRESULT ShowProcessListDlg();
[id(2), helpstring("method LoadProcessListFun")] HRESULT LoadProcessListFun();
[id(3), helpstring("method UnloadProcessListFun")] HRESULT UnloadProcessListFun();
};
[
uuid(E49555EC-6BB7-416A-A94C-9DB7D992DC80),
version(1.0),
helpstring("ProcessManager 1.0 Type Library")
]
library PROCESSMANAGERLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(2F533D8F-7201-4955-B7FD-9DDE5600F563),
helpstring("_IProcessListEvents Interface")
]
dispinterface _IProcessListEvents
{
properties:
methods:
};
[
uuid(B4B62183-505E-4887-B17A-5566C56DF539),
helpstring("ProcessList Class")
]
coclass ProcessList
{
[default] interface IProcessList;
};
};
是想说接口查询吧
接口通过QueryInterface可以查询到定义在一个组件内的其他接口,这是COM的规范之一。
所以准确的说是
可以使用B接口的对象指针调用QueryInterface函数找到C接口
也可以使用C接口的对象指针调用QueryInterface函数找到B接口