下面是IDL的内容:[
uuid(E8B8B678-A852-424F-9D0C-6FCF65C167B8),
version(1.0),
helpstring("myCom 2.0 Type Library")
]
library PTALib
{
importlib("stdole2.tlb");
interface ImyCom;
interface ICerts;
interface ICollection;
interface ICert; [uuid(1E0DFFCF-27FF-4574-849B-55007349FEDA),
helpstring("myCom Class")]
coclass myCom {
[default] interface ImyCom;
}; [odl,
uuid(19247043-F8F5-4F31-AF80-0068D63B1E84),
helpstring("ImyCom Interface"),
dual,
oleautomation]
interface ImyCom : IDispatch {
[id(0x00000002), propget, helpstring("property MyCerts")] HRESULT MyCert ([out, retval] ICerts** Certs);
[id(0x60020005), helpstring("method DecryptMessage")]
HRESULT DecryptMessage(
[in] BSTR p7msg,
[in, optional, defaultvalue(1)] OPTION opt,
[out, retval] BSTR* msg); [
odl,
uuid(51C9E94B-FB8B-47A4-ABE4-FE91806DC7C7),
helpstring("ICerts Interface"),
dual,
oleautomation
]
interface ICerts : ICollection {
[id(0x60030000), helpstring("method Add")]
HRESULT Add([in] IUnknown* cert);
[id(0x60030001), helpstring("method Remove")]
HRESULT Remove([in] int idx);
[id(0x60030002), helpstring("method EncryptMessage")]
HRESULT EncryptMessage(
[in] BSTR msg,
[in, optional, defaultvalue(4)] OPTION opt,
[out, retval] BSTR* val);
}; [
odl,
uuid(A857AB58-1EEA-4D0A-B7DE-4E1FC67C4A25),
dual,
oleautomation
]
interface ICollection : IDispatch {
[id(00000000), propget, helpstring("property Item")]
HRESULT Item(
[in] long idx,
[out, retval] VARIANT* pVal);
[id(0xfffffffc), propget, helpstring("property _NewEnum")]
HRESULT _NewEnum([out, retval] IUnknown** pVal);
[id(0x60020002), propget, helpstring("property Count")]
HRESULT Count([out, retval] long* pVal);
};
[
odl,
uuid(860F2720-D3C8-47EC-B073-A10607DDCA80),
helpstring("ICert Interface"),
dual,
oleautomation
]
interface ICert : IDispatch {
[id(0x60020000), propget, helpstring("property CN")]
HRESULT CommonName([out, retval] BSTR* pVal);
[id(0x60020009), helpstring("method SignMessage")]
HRESULT SignMessage(
[in] BSTR msg,
[in, optional, defaultvalue(4)] OPTION opt,
[out, retval] BSTR* signout);
[id(0x00000001), helpstring("method View")]
HRESULT View();
}; [
uuid(D8E0863D-7643-4553-89AD-A4EBCCDAA710),
helpstring("Cert Class")
]
coclass Cert {
[default] interface ICert;
}; [
uuid(66F50F46-70A0-4A05-BD5E-FBCC0F9641EC),
helpstring("Certs Class")
]
coclass Certs {
[default] interface ICerts;
};};
结构比较简单,请大家帮我看看该如何实现
尤其是interface ICerts : ICollection
interface ICollection : IDispatch在代码中该如何写,迷糊ing,谢谢了。有个最简单的小例子最好啦
uuid(E8B8B678-A852-424F-9D0C-6FCF65C167B8),
version(1.0),
helpstring("myCom 2.0 Type Library")
]
library PTALib
{
importlib("stdole2.tlb");
interface ImyCom;
interface ICerts;
interface ICollection;
interface ICert; [uuid(1E0DFFCF-27FF-4574-849B-55007349FEDA),
helpstring("myCom Class")]
coclass myCom {
[default] interface ImyCom;
}; [odl,
uuid(19247043-F8F5-4F31-AF80-0068D63B1E84),
helpstring("ImyCom Interface"),
dual,
oleautomation]
interface ImyCom : IDispatch {
[id(0x00000002), propget, helpstring("property MyCerts")] HRESULT MyCert ([out, retval] ICerts** Certs);
[id(0x60020005), helpstring("method DecryptMessage")]
HRESULT DecryptMessage(
[in] BSTR p7msg,
[in, optional, defaultvalue(1)] OPTION opt,
[out, retval] BSTR* msg); [
odl,
uuid(51C9E94B-FB8B-47A4-ABE4-FE91806DC7C7),
helpstring("ICerts Interface"),
dual,
oleautomation
]
interface ICerts : ICollection {
[id(0x60030000), helpstring("method Add")]
HRESULT Add([in] IUnknown* cert);
[id(0x60030001), helpstring("method Remove")]
HRESULT Remove([in] int idx);
[id(0x60030002), helpstring("method EncryptMessage")]
HRESULT EncryptMessage(
[in] BSTR msg,
[in, optional, defaultvalue(4)] OPTION opt,
[out, retval] BSTR* val);
}; [
odl,
uuid(A857AB58-1EEA-4D0A-B7DE-4E1FC67C4A25),
dual,
oleautomation
]
interface ICollection : IDispatch {
[id(00000000), propget, helpstring("property Item")]
HRESULT Item(
[in] long idx,
[out, retval] VARIANT* pVal);
[id(0xfffffffc), propget, helpstring("property _NewEnum")]
HRESULT _NewEnum([out, retval] IUnknown** pVal);
[id(0x60020002), propget, helpstring("property Count")]
HRESULT Count([out, retval] long* pVal);
};
[
odl,
uuid(860F2720-D3C8-47EC-B073-A10607DDCA80),
helpstring("ICert Interface"),
dual,
oleautomation
]
interface ICert : IDispatch {
[id(0x60020000), propget, helpstring("property CN")]
HRESULT CommonName([out, retval] BSTR* pVal);
[id(0x60020009), helpstring("method SignMessage")]
HRESULT SignMessage(
[in] BSTR msg,
[in, optional, defaultvalue(4)] OPTION opt,
[out, retval] BSTR* signout);
[id(0x00000001), helpstring("method View")]
HRESULT View();
}; [
uuid(D8E0863D-7643-4553-89AD-A4EBCCDAA710),
helpstring("Cert Class")
]
coclass Cert {
[default] interface ICert;
}; [
uuid(66F50F46-70A0-4A05-BD5E-FBCC0F9641EC),
helpstring("Certs Class")
]
coclass Certs {
[default] interface ICerts;
};};
结构比较简单,请大家帮我看看该如何实现
尤其是interface ICerts : ICollection
interface ICollection : IDispatch在代码中该如何写,迷糊ing,谢谢了。有个最简单的小例子最好啦
如果是源码方式,建议你自己手动建个项目,然后自己添加个接口,看看实现机制是什么,照葫芦画瓢喽。