Werden IConnectionPoint callbacks für Matlab R2024a unterstützt?

조회 수: 4 (최근 30일)
Alexander
Alexander 2024년 4월 7일
편집: Alexander 2024년 4월 14일
Ich habe eine COM EXE Server erstellt und das IConnectionPoint Interface implementiert.
Es gibt eine Funktionsaufruf von Matlab auf den COM-Server welcher die Callback von Matlab triggern soll.
Das Instanzieren des Servers funktioniert:
Auch das Event wird erkannt:
Beim Registrieren der Callback wird hauptsächlich Advise aufgerufen, läuft aber auch fehlerfrei durch (das ist eine Testimplementierung)
Die Matlab-Callback:
Wenn ich dann versuche die Callback aufzurufen bekomme ich folgenden Fehler:
In Matlab kommt die Rückmeldung:
Das IDL-File schaut wie folgt aus:
( Bitte das IDL-File nochmal prüfen. Daraus wird der Proxy erstellt und ich bin mir absolut nicht sicher, ob das so für einen COM-ConnectionPoint passt)
import "unknwn.IDL";
import "objidl.IDL";
/// <summary>
/// Import Oleat Automation - IDispatch
/// </summary>
import "oaidl.idl";
import "ocidl.idl";
// Make a CLSID_ICallback in interface.h
// This is the CLSID for the ExeServer, not used in the Proxy/Stub dll
// The CLSID of this Proxy/Stub DLL is set in the makefile and must be
// a different one.
// C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\guidgen.exe
declare_guid(CLSID_ICallback,6AE4A038-075B-4F76-A4AF-D6DE4E223DEA);
typedef [uuid(1E43278E-93DE-4BE0-A183-038FFDFA5847)] struct tagsICallbackStruct_t
{
BSTR name;
VARIANT_BOOL flagVar;
}sICallbackStruct_t;
// Interface ICallback
[
object, /// (D)COM OBjekt
uuid(D458049F-ABD8-49F3-A690-7BF5831F9123), /// IID
helpstring("ICallback Interface"),
pointer_default(unique)
]
interface ICallback : IUnknown
{
[id(1)] HRESULT ClbkTick(void);
};
[
object,
uuid(C5DBCC44-F557-4F93-BCAE-67E56664D84D), /// IID
helpstring("ITradingSession Interface"),
pointer_default(unique)
]
interface ITradingSession : IDispatch
{
[id(1)] HRESULT SetCallback([in] ICallback* p_CallBack);
[id(2)] HRESULT TestString([in] BSTR bstr_InputStering, [out] VARIANT* pbstr_OutputString);
[propput] HRESULT Visible([in] VARIANT_BOOL bVisible);
[propget] HRESULT Visible([out, retval] VARIANT_BOOL* pbVisible);
[propput] HRESULT Index([in] unsigned int uiIndex);
[propget] HRESULT Index([out, retval] unsigned int* puiIndex);
[propget] HRESULT IConnectionPointContainer([out, retval] IConnectionPointContainer** pICPC);
};
[
uuid("773D8973-0919-4C7A-93DF-9169CF0799DC"),
version(1.0),
helpstring("ITradingSession Type-lib")
]
library ITradingSession
{
importlib("stdole32.tlb");
[
uuid("7951DDBD-A013-465E-906F-647C9A419FF6"),
helpstring("Component class")
]
coclass Component
{
[default] interface ITradingSession;
[default, source] interface ICallback;
};
};
  댓글 수: 1
Alexander
Alexander 2024년 4월 8일
편집: Alexander 2024년 4월 14일
Ich vermute Matlab unterstützt legidlich OLE Automation interfaces als callback....
Also IDispatch (dual) oder dispinterface (nur spätes Binden).

댓글을 달려면 로그인하십시오.

채택된 답변

Alexander
Alexander 2024년 4월 14일
편집: Alexander 2024년 4월 14일
Matlab unterstützt als Scriptsprache tatsächlich lediglich IDispatch interfaces. Wenn das Callback-Interface als duales interface implementiert wird, funktioniert es. ( Ein Dispatch Interface funktioniert vermutlich auch. Eines mit früher Bindung schlägt wie oben fehl). Im Server muss die Callback via "Invoke" aufgerufen werden.
// Interface ICallback
[
object, /// (D)COM OBjekt
uuid(D458049F-ABD8-49F3-A690-7BF5831F9123), /// IID
helpstring("ICallback Interface"),
pointer_default(unique)
]
interface ICallback : IDispatch
{
[id(1)] HRESULT ClbkTick(void);
};
.....
[
uuid("773D8973-0919-4C7A-93DF-9169CF0799DC"),
version(1.0),
helpstring("ITradingSession Type-lib")
]
library ITradingSession
{
importlib("stdole32.tlb");
[
uuid("7951DDBD-A013-465E-906F-647C9A419FF6"),
helpstring("Component class")
]
coclass Component
{
[default] interface ITradingSession;
[default, source] interface ICallback;
};
};

추가 답변 (0개)

태그

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!