'' C++ .h STDMETHODIMP MyATL15(LONG a, LONG b, LONG* c); '' C++ .idl [id(1), helpstring("Method MyATL15")] HRESULT MyATL15([in] LONG a, [in] LONG b, [out,retval] LONG* c); '' C++ .idl [id(2), helpstring("Method MyATL16")] HRESULT MyATL16([in] LONG a, [in] LONG b, [out] LONG* c); Private Sub Command1_Click() Dim a, b, c As Long Dim obj As Object Set obj = CreateObject("ATLSimpleObject15Test") Let a = 22 Let b = 23 c = obj.MyATL15(a, b) '' idl keyword: retval MsgBox (c) Let a = 12 Let b = 19 Call obj.MyATL16(a, b, c) '' equals: obj.MyATL16 a, b, c MsgBox (c) Set obj1 = Nothing End Sub
注意:ATL COM不能被託管代碼用invoke方式調用。
反之,.net託管COM代碼可以被 C++/VB/C#以invoke方式調用
關於C# Method.Invoke方式調用C++ COM