M
M
marsdenden2017-04-22 09:45:07
Delphi
marsdenden, 2017-04-22 09:45:07

How to call the com method of an object in Delphi, the name of which is unknown at the time of writing the program?

Hello everybody!
I know and understand how to access the methods and properties of the ole-object. On the example of a KKM driver from Shtrikh-M

v:=CreateOleObject(‘AddIn.DrvFR’);
v.Password:=30;
v.Quantity:=1000;
v.Sale;

But I need to do something different - write a program that will be a kind of interpreter of a certain pseudo-language, respectively, methods and properties will be in variables and will be unknown at the time of compiling the program. However, there is some way to call these methods and access properties.
For example, in 1C you can dynamically load any Dll and access any methods and properties that are there. How does the interpreter find the required method and call it? How can this be implemented in Delphi? Something like this:
obj.PropertySet('Password','30');
obj.ExecMethod('Sale');

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
marsdenden, 2017-04-22
@marsdenden

In general, the issue is resolved. Using the IDispatch methods (which is the result of CreateOleObject), you can find out what methods and properties are available in the pluggable COM object and use Invoke further

K
kalapanga, 2017-04-22
@kalapanga

Speaking of 1C, do you obviously mean the technology of external components? Then we are not talking about "any DLL", but about one written according to very specific rules and conventions. If I remember correctly, there must be predefined properties and methods through which you can get a list of other properties and methods. All this is described somewhere on the ITS with examples.
So if you mean some incomprehensible objects in general, then the answer is no way. If it is quite specific, written according to the rules known to you, then the answer is - study these rules, the structure of these objects of yours.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question