Question

I am wondering a situation during the program execution when the user (beginner programers ones) could implements under an event notification, for example:

TNotifySomething : procedure (const param: TObject) of object;

1 - This event may be implemented by a Dll? I have to publish somehow?
2 - May I pass by reference the objects instantiated during the program execution to the dll method?
3 - In a multithreaded environment, if I call the event(defined in the dll) by 2 or more threads, it will cause me any troubles, like access violations ?
4 - Somebody knows a good book or paper where I can read about it?

P.S : This can be done in Delphi 6?

Était-ce utile?

La solution

1) no. Google for DLL vs BPL. This topic is recurring since 1997. BPLs are for Pascal. DLL are for Windows. There is no objects in Windows. But there are COM interfaces (IUnknown with COM-defined types, that are sup-set of your Pascal types, event callbacks are not there)

You can also try "can JCL except_stack_list work for dll? " thread at http://newsportal.delphi-jedi.org/thread_frameset.php?group=jedi.jcl

2) by means of IUnkown and COM-standardized data types. Other than that you override compiler's type safety which means you should implement and provide your own pascal-to-binary safety layer.

3) Depends on your code, both callee and caller. If both are reentrable, then they are. If some one is not - it would trigger an error.

4) depends what you want to achive.

if you want to get taste of DLLs: any book of assembler, then Delphi manuals about implementing procedures in asm instead of Pascal, especially about binary representation of all those datatypes in different Delphi versions. If you deny Delphi-standard type safety, then you need to provide your own one.

if you want to get taste of COM, then any book about COM and Delphi manuals about implementing and consuming COM objects.

if you want to get taste of BPLs - then read Delphi manuals about Runtime Packages. They are 1st class citizens in Delphi and extra books are but optional.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top