Com-Callback for pointer to SafeArray
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
i have build a COM-Server which has a connection point implemented.
The Callback-Interface is defined linke this in COM:
// Interface IFxcmCallback
[
object, /// (D)COM OBjekt
uuid(F9394ABF-D988-40BB-A684-5D6E3BC91BF7), /// IID
helpstring("IFxcmCallback Interface"),
oleautomation,
dual
]
interface IFxcmCallback : IDispatch
{
[id(1)] HRESULT GetCallbackConfig([out] SAFEARRAY(s_CallbackConfig_t) * );
[id(2)] HRESULT TicksCallback([in] SAFEARRAY(s_FxcmOffers_t) );
};
The Callbacks in Matlab are defined like this:
function MyGetCallbackConfig ( varargin )
varargin{1} = 1;
msgbox("OK");
end
and this:
function MyTicksCallback (varargin)
msgbox("OK");
end
I think that this functions are not defined the correct way. Because after setting up the Connection;
c = actxserver('Backtester.IFxcmOrder')
registerevent(c,{'GetCallbackConfig' '@MyGetCallbackConfig'; 'TicksCallback' '@MyTicksCallback'})
as soon as the server trys to call the "MyGetCallbackCOnfig" Callback-function the follwing error orrures:

The Call:
events(c)
has the Result:

I think that the callback for the "GetCallbackConfig" is not defined the right way by me. But i Do not know how i have to define it.
0 Kommentare
Antworten (1)
Meet
am 19 Jun. 2025
Hi Alexander,
The "GetCallbackConfig" callback needs to return the "[out] SAFEARRAY" expected by your COM interface, and use a column 1D array structure. You could try the below code snippet:
% Enable single-dimensional SAFEARRAY export once at startup:
feature('COM_SafeArraySingleDim', 1);
function configs = MyGetCallbackConfig(~, ~)
% Construct a struct array matching s_CallbackConfig_t
configs(1).FieldA = 123;
configs(1).FieldB = 'Example';
end
For more information on handling COM Data in MATLAB, you could refer to the below MathWorks Documentation:
1 Kommentar
Siehe auch
Kategorien
Mehr zu COM Component Integration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!