Set path for request dlls
-
I created mymodule.so. I put it in plugins/myplugin folder. Created myplugin.rb in plugins.
myplugin.rbrequire 'myplugin/mymodule.so'
If I run myplugin.rb, I get a message box that is not found mylib1.dll and mylib2.dll.
How to specify where to find dlls?
Copying mylib1.dll and mylib2.dll in sketchup folder solves this problem, but I would like to specify the location of the directory with dlls. -
Solution
require 'myplugin/Win32API' LoadLibrary = Win32API.new("kernel32","LoadLibrary",["P"],"I") path='' # set path to dir with dlls dllname=path+'mylib1.dll' LoadLibrary.call(dllname) dllname=path+'mylib2.dll' LoadLibrary.call(dllname)
-
Most people (who run Su on PC,) already have a copy of Win32API.so where their $LOAD_PATH array can find it, so you should only need to:
require 'Win32API'
if it's already loaded, require will skip reloading it.You can even get more fancy, by first checking if it's loaded, because it defines the class Win32API, and classnames are constants ie:
unless (defined? Win32API)=='constant' %(#F0F0F0)[__]require 'Win32API' end
Also.. I think you must unload those DLLs when your plugin is done with them. Perhaps you might need to use a custom AppObserver implementing the onQuit callback, with your plugin.
Advertisement