Re: No Type Library?
"Alexander Adam" <contact@emiasys.com> wrote in message
news:1173602121.871617.33310@h3g2000cwc.googlegroups.com
See IDispEventSimpleImpl - it does precisely that, based on sink map
(see also BEGIN_SINK_MAP, SINK_ENTRY_INFO et al). You can use it as
is, or study its source code for some ideas.
Thanks I've been looking at this one. Looks like it is using a
CComStdCallThunk class.
The real work happens in DispCallFunc. This is the API that takes
DISPPARAMS structure with the actual parameter and the description of
formal parameters the method expects, makes necessary conversion, builds
a stack frame and calls the method.
Now, DispCallFunc was designed to work with COM interfaces, so it takes
an interface pointer and an index of a method in it.
IDispEventSimpleImpl allows you to specify an address of any member
function (possibly not virtual) in the sink map. This is where
CComStdCallThunk comes in. It mimics a binary layout of a COM interface
having a single method (by manually constructing a corresponding
vtable). This method is actually a bit of inline assembly that
eventually jumps to your method. The assembly code is needed to replace
the 'this' pointer to point to your class (DispCallFunc passes the
address of CComStdCallThunk itself, since it is fooled into thinking
it's calling a method on CComStdCallThunk).
The issue I see here is that I cannot call my standard methods like
"void(std::string bla);"
You can't. But you can use BSTR parameter, or any other automation
parameter.
If you insist on supporting std::string or any other non-automation
parameter, you will need to write your own replacement for DispCallFunc.
How good are your assembly skills? 'Cause you would need all of them.
I guess this class is always passing
the array of variants into the function, right?
Wrong. It passes whatever parameter types you describe in _ATL_FUNC_INFO
structure. They have to be automation parameters - something for which a
VT_* constant is defined.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925