From: Markus R. <rol...@us...> - 2007-02-09 16:10:39
|
Update of /cvsroot/simspark/simspark/spark/salt In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv29924 Modified Files: Tag: WIN32 sharedlibrary.cpp Log Message: - implement shared library loading for the win32 platform Index: sharedlibrary.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/salt/sharedlibrary.cpp,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** sharedlibrary.cpp 22 Jan 2006 12:13:08 -0000 1.3 --- sharedlibrary.cpp 9 Feb 2007 16:10:27 -0000 1.3.2.1 *************** *** 21,29 **** */ #include "sharedlibrary.h" - #include <dlfcn.h> #include <iostream> using namespace salt; bool SharedLibrary::Open(const std::string &libName) --- 21,71 ---- */ #include "sharedlibrary.h" #include <iostream> + #ifdef WIN32 + #include <windows.h> + #else + #include <dlfcn.h> + #endif + using namespace salt; + #ifdef WIN32 + + bool SharedLibrary::Open(const std::string &libName) + { + if (mLibHandle) + { + Close(); + } + + #if INIT_DEBUG + std::cerr << "(SharedLibrary) Opening " << libName + ".so\n"; + #endif + mLibHandle = ::LoadLibrary((libName + ".dll").c_str()); + + return (mLibHandle!=NULL); + } + + void* SharedLibrary::GetProcAddress(const std::string &procName) + { + if (mLibHandle) + { + return ::GetProcAddress((HMODULE)mLibHandle, procName.c_str()); + } + return NULL; + } + + void SharedLibrary::Close() + { + if (mLibHandle) + { + ::FreeLibrary((HMODULE)mLibHandle); + mLibHandle = NULL; + } + } + + #else + bool SharedLibrary::Open(const std::string &libName) *************** *** 75,76 **** --- 117,120 ---- return mName; } + + #endif // WIN32 |