> 1) How can I call a function in a package?
With some difficulty - essentially, the function / procedure must declared
in the interface section of a unit (something like procedure Register) and
you will need to know how the compiler / linker mangles its name (rename the
package to a DLL and look at it using quick view). The value returned by
LoadPackage is a handle to the package (which is just a DLL). You can then
pass this to GetProcAddress to obtain the address of the procedure /
funciton you want to call. (but see comments later)
> 2) Can I have multiple packages with the same function name?
Yes.
> Has anyone got any simple samples of doing this?, or am I
> better to use
> DLL's?
Calling a procedure / function in a package is simple, but it is not very
OO. I prefer to use this method.
Create a utility package, that has a singleton registration class. This
package is used by both your EXE and the dynamically loaded package. The
EXE registers an event with the class. When the package loads, it calls a
method in the registration class to register an interface. This notifies
the EXE, through the event. The EXE can then do whatever it wants with the
interface (such as calling QueryInterface).
Note that for dynamic packages to work you will need to compile your EXE to
use runtime packages.
Regards,
Dennis.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz