Здравствуйте, Кодёнок, Вы писали:
Кё>Соглашения OLE Automation требуют, чтобы все методы возвращали HRESULT. Может поэтому VBA не работает?
Да нет, это конечно не причем. И метод, HRESULT, я текст по памяти просто воспроизводил. Вот полный IDL:
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(3A84A871-05FB-4194-BFAD-459C02F6030E)
]
interface IReader : IUnknown
{
[helpstring("method Read")] HRESULT Read([out, retval]BSTR* pRes);
};
[
object,
uuid(F3864754-1039-4123-BEAE-DD2045704005),
dual,
helpstring("IComPort Interface"),
pointer_default(unique)
]
interface IComPort : IDispatch
{
};
[
object,
uuid(9A59DCA7-9B3A-4588-A94D-3C001A2311C0),
dual,
helpstring("ITcpClient Interface"),
pointer_default(unique)
]
interface ITcpClient : IDispatch
{
};
[
uuid(2C752472-2A78-4F27-AF97-1D64F27A9277),
version(1.0),
helpstring("MT 1.0 Type Library")
]
library MTLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
interface IReader;
[
uuid(610BEAB6-393B-46F7-A8C2-58A2DF19ADE9),
helpstring("_IReaderEvents Interface")
]
dispinterface _IReaderEvents
{
properties:
methods:
[id(1), helpstring("method DataReady")] HRESULT DataReady();
};
[
object,
uuid(0541A5A1-ED88-4903-81E5-6DC65ACA8452),
dual,
helpstring("ISimpleTester Interface"),
pointer_default(unique)
]
interface ISimpleTester : IDispatch
{
[id(1), helpstring("method Bind")] HRESULT Bind([in]IUnknown* pUnk);
[id(2), helpstring("method Exec")] HRESULT Exec();
[propget, id(3), helpstring("property Result")] HRESULT Result([out, retval] BSTR *pVal);
};
[
uuid(8CCFBFA0-94FE-46F1-A4ED-3639B18ED6A6),
helpstring("ComPort Class")
]
coclass ComPort
{
[default] interface IComPort;
[default, source] dispinterface _IReaderEvents;
};
[
uuid(F23FC867-2431-4294-8CD0-97AF10750B5D),
helpstring("TcpClient Class")
]
coclass TcpClient
{
[default] interface ITcpClient;
[default, source] dispinterface _IReaderEvents;
};
[
uuid(D0518F05-0BF7-4A4C-BAAC-1376D273EF22),
helpstring("SimpleTester Class")
]
coclass SimpleTester
{
[default] interface ISimpleTester;
};
};
А классы явно наследуют IReader:
class ATL_NO_VTABLE CComPort :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CComPort, &CLSID_ComPort>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CComPort>,
public IDispatchImpl<IComPort, &IID_IComPort, &LIBID_MTLib>,
public IReader
{
///
}