var v : variant;
begin
v:=CreateOleObject('Server.Class');
result:=v.Method(param1,param2);
end;
Compiler doesn't know any interafaces, everything is based on IDispatch. At
runtime delphi reads type library, bat I don't know how to do this on my
own.
There's two ways of doing this: the
low-level-well-documented-but-insanely-complicated way, and the
no-documentation-but-can-be-made-to-work-in-less-code way (aka the Delphi
way).
For the low-level way, read up on MSDN about the Invoke method of IDispatch.
I advise a strong drink and a large amount of time available before you do
this. I gave up trying to understand the whole low-level thing of Dispatch
interfaces a while ago after seeing what actually goes on :)
For the Delphi way, dive head-first into the ComObj unit. The bit you're
after is the semi-undocumented VarDispInvoke in ComObj, which is what the
compiler actually emits when it compiles your code. This is actually
referenced through (the slightly more documented) VarDispProc. You still
need to do a bit of work to get this to go though, and you need to do stuff
like calling bits of the IDispatch interface to get the method IDs from the
names.
Either way, you're fighting an uphill battle, and should ask youself first
whether there is anther way of doing it.
--
联系客服