View Full Version : plugins
rouncer
01-01-2007, 09:52 PM
as far as i know, plugins are dlls that are enumerated and "linked?" at
runtime as compiled code, them being compiled being the important
part so they go nice and quick.
if anyone can help me with some info on this topic id be greatful.
at the moment, the only things ive thought of were to interpret them
(which isnt good for plugins that are supossed to rasterize, interpreted
rastering doesnt sound like a good combination)
or to put a linker in the directory and link them with an exe whenever a
new part is added (is that a crazy idea or would it be ok?)
thanks.
Reedbeta
01-01-2007, 10:20 PM
All DLL files are loaded and linked in at run time. Most DLLs provide an accompanying .lib file, called the import library, which contains the code to do this automatically so you don't have to worry about it. But you can also do it yourself. Just use the WinAPI functions LoadLibrary (http://msdn2.microsoft.com/en-us/library/ms684175.aspx), which loads a DLL and attaches it to a running program, and GetProcAddress (http://msdn2.microsoft.com/en-us/library/ms683212.aspx), which lets you look up the address of a function in the DLL by its name. To make a plugin interface, all you have to do is create a set of functions that DLLs need to implement that can be looked up and called by your program. You can also provide an API to your plugins, i.e. a set of functions in your program that the DLL can call. This can be done by passing a structure containing pointers to the API functions from the program to the plugin during initialization. You can also do all this in a nice object-oriented way with interfaces and virtual functions (which is how COM works).
rouncer
01-01-2007, 10:38 PM
thanks alot.
so you just make a function pointer that points to the address getprocaddress gives you?
[EDIT] dont bother answering, i guess so :)
SmokingRope
01-02-2007, 06:01 AM
MSDN2 DLL REFERENCE (http://msdn2.microsoft.com/en-us/library/1ez7dh12(VS.80).aspx)
MSDN DLL REFERENCE (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dynamic_link_libraries.asp)
rouncer
01-05-2007, 12:38 AM
ive made up my dll interface, ive got a dll, and the library is loaded, but how
do you call the function from getprocaddress?
dont worry fixed it, you gotta typedef it.
hey thanks alot, my programming just went through the roof.
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.