+ // ctors
+ wxDynamicLibrary() { m_library = 0; }
+ wxDynamicLibrary(const wxString& name) { Load(name); }
+
+ // return TRUE if the library was loaded successfully
+ bool IsLoaded() const { return m_library != 0; }
+ operator bool() const { return IsLoaded(); }
+
+ // load the library with the given name (full or not), return TRUE on
+ // success
+ bool Load(const wxString& name)
+ {
+ m_library = wxDllLoader::LoadLibrary(name);
+
+ return IsLoaded();
+ }
+
+ // unload the library, also done automatically in dtor
+ void Unload()
+ {
+ if ( IsLoaded() )
+ wxDllLoader::UnloadLibrary(m_library);
+ }
+
+ // load a symbol from the library, return NULL if an error occured or
+ // symbol wasn't found
+ void *GetSymbol(const wxString& name) const
+ {
+ wxCHECK_MSG( IsLoaded(), NULL,
+ _T("can't load symbol from unloaded library") );
+
+ return wxDllLoader::GetSymbol(m_library, name);
+ }
+
+ // unload the library
+ //
+ // NB: dtor is not virtual, don't derive from this class
+ ~wxDynamicLibrary() { Unload(); }
+
+private:
+ // the handle to DLL or NULL
+ wxDllType m_library;