From: david@... Date: 2005-11-02T03:18:54+09:00 Subject: Using LoadLibrary from within an extension I am having an issue where LoadLibrary works fine on my system in a normal C application but not inside an extension (it always returns NULL no matter what). The same call (translated to dlopen) works fine under linux though so I'm not sure if it's a specific issue to Windows extensions. For testing purposes I'm loading a hard coded library but under linux I have also tested passing in the name and that works fine. Here's the function that's being called from Ruby along with the relevant variable declarations and imports. #include "ruby.h" #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include HINSTANCE library_handle; #else #include void* library_handle; #endif static VALUE set_library(VALUE self, VALUE lib_name) { library_name = STR2CSTR(lib_name); #ifdef WIN32 library_handle = LoadLibrary("alleg40.dll"); #else library_handle = dlopen("libc.so.6", RTLD_LAZY); #endif if(library_handle == NULL) { rb_raise(rb_eArgError, "Library could not be opened"); return Qfalse; } return Qtrue; } TIA, David Koontz