描述:
1)如何在IDL文件中声明自定义类型(eg. struct): 这是我的IDL文件,可以通过测试--可以在VB中调用,但……
import "oaidl.idl";
import "ocidl.idl";
typedef
// [
// uuid(EF726672-F275-45cd-99FB-8932B0DF1AB4)
// ]
struct tagColor {
short red;
short green;
short blue;
} Color;
[
object,
uuid(5F4F5902-8592-41C4-99E1-DC729ED8755D),
dual,
helpstring("ISCX_ATL Interface"),
pointer_default(unique)
]
interface ISCX_ATL : IDispatch
{
[id(1), helpstring("method Add")] HRESULT Add([in]int addNum, [in]int addNumOther, [out]int *result);
[id(2), helpstring("method Subtract")] HRESULT Subtract([in]int num, [in]int numOther, [out]int *result);
[id(3), helpstring("method SetColor")] HRESULT SetColor([in]const Color *pClr);
[id(4), helpstring("method GetColor")] HRESULT GetColor([out, retval] Color *pColor);
};
[
uuid(648E314A-C6EB-47CE-866E-E57A30DFDE67),
version(1.0),
helpstring("ComDemo 1.0 Type Library")
]
library COMDEMOLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(4230782D-B78A-4957-BC29-855BA923A61A),
helpstring("SCX_ATL Class")
]
coclass SCX_ATL
{
[default] interface ISCX_ATL;
};
struct Color;
};
编译有WARING:
A)warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'pClr' of Procedure 'SetColor' (
Interface 'ISCX_ATL' ) ]
B)warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'pColor' of Procedure 'GetColor'
( Interface 'ISCX_ATL' ) ]
为什么?????
2)如果将[id(4), helpstring("method GetColor")] HRESULT GetColor([out, retval] Color *pColor);中参数写成[out, retval] Color **pColor,那在VB中如何调用??