Here's a plugin type. Notice it has a field for a function:
Now here is the loading code. It loads the library and retrieves the handle to a function, then stores it as a field:
I thought it was a pretty cool concept, and it works without a hitch in Max.
Type TPlugin Field name$ Field library Field class Field GetClass:Int() EndType
Now here is the loading code. It loads the library and retrieves the handle to a function, then stores it as a field:
Function LoadPlugins:Int(path$) path=Replace(path,"/","") If Right(path,1)<>"" path=path+"" dir=ReadDir(path) If Not dir Return Repeat file$=NextFile(dir) If file="" Exit If Lower(ExtractExt(file))="dll" programlog "Loading plugin "+quote(file)+"..." plugin:TPlugin=New TPlugin plugin.name=StripAll(file) plugin.library=LoadLibraryA(path+file$) If plugin.library plugin.GetClass=GetProcAddress(plugin.library,"PluginClass") If plugin.GetClass plugin.class=plugin.GetClass() EndIf FreeLibrary plugin.library plugin.library=0 EndIf EndIf Forever Return True EndFunction
I thought it was a pretty cool concept, and it works without a hitch in Max.