1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxDllLoader documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) Vadim Zeitlin
9 %% License: wxWidgets license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxDllLoader
}}\label{wxdllloader
}
14 wxDllLoader is a class providing an interface similar to Unix's
{\tt
15 dlopen()
}. It is used by the wxLibrary framework and manages the actual
16 loading of shared libraries and the resolving of symbols in them. There are no
17 instances of this class, it simply serves as a namespace for its static member
20 Please note that class
\helpref{wxDynamicLibrary
}{wxdynamiclibrary
} provides
21 alternative, friendlier interface to wxDllLoader.
23 The terms
{\it DLL
} and
{\it shared library/object
} will both be used in the
24 documentation to refer to the same thing: a
{\tt .dll
} file under Windows or
25 {\tt .so
} or
{\tt .sl
} one under Unix.
27 Example of using this class to dynamically load the
{\tt strlen()
} function:
30 #if defined(__WXMSW__)
31 static const wxChar *LIB_NAME = _T("kernel32");
32 static const wxChar *FUNC_NAME = _T("lstrlenA");
33 #elif defined(__UNIX__)
34 static const wxChar *LIB_NAME = _T("/lib/libc-
2.0.7.so");
35 static const wxChar *FUNC_NAME = _T("strlen");
38 wxDllType dllHandle = wxDllLoader::LoadLibrary(LIB_NAME);
45 typedef int
(*strlenType)(char *);
46 strlenType pfnStrlen = (strlenType)wxDllLoader::GetSymbol(dllHandle, FUNC_NAME);
53 if ( pfnStrlen("foo") !=
3 )
63 wxDllLoader::UnloadLibrary(dllHandle);
67 \wxheading{Derived from
}
71 \wxheading{Include files
}
75 \wxheading{Data structures
}
77 This header defines a platform-dependent
{\tt wxDllType
} typedef which stores
78 a handle to a loaded DLLs on the given platform.
80 \latexignore{\rtfignore{\wxheading{Members
}}}
82 \membersection{wxDllLoader::GetDllExt
}\label{wxdllloadergetdllext
}
84 \func{static wxString
}{GetDllExt
}{\void}
86 Returns the string containing the usual extension for shared libraries for the
87 given systems (including the leading dot if not empty).
89 For example, this function will return
{\tt ".dll"
} under Windows or (usually)
90 {\tt ".so"
} under Unix.
92 \membersection{wxDllLoader::GetProgramHandle
}\label{wxdllloadergetprogramhandle
}
94 \func{wxDllType
}{GetProgramHandle
}{\void}
96 This function returns a valid handle for the main program itself. Notice that
97 the
{\tt NULL
} return value is valid for some systems (i.e. doesn't mean that
100 {\bf NB:
} This function is Unix specific. It will always fail under Windows
103 \membersection{wxDllLoader::GetSymbol
}\label{wxdllloadergetsymbol
}
105 \func{void *
}{GetSymbol
}{\param{wxDllType
}{dllHandle
},
\param{const wxString\&
}{name
}}
107 This function resolves a symbol in a loaded DLL, such as a variable or
110 Returned value will be
{\tt NULL
} if the symbol was not found in the DLL or if
113 \wxheading{Parameters
}
115 \docparam{dllHandle
}{Valid handle previously returned by
116 \helpref{LoadLibrary
}{wxdllloaderloadlibrary
}}
118 \docparam{name
}{Name of the symbol.
}
120 \membersection{wxDllLoader::LoadLibrary
}\label{wxdllloaderloadlibrary
}
122 \func{wxDllType
}{LoadLibrary
}{\param{const wxString \&
}{libname
},
\param{bool*
}{success = NULL
}}
124 This function loads a shared library into memory, with
{\it libname
} being the
125 name of the library: it may be either the full name including path and
126 (platform-dependent) extension, just the basename (no path and no extension)
127 or a basename with extension. In the last two cases, the library will be
128 searched in all standard locations.
130 Returns a handle to the loaded DLL. Use
{\it success
} parameter to test if it
131 is valid. If the handle is valid, the library must be unloaded later with
132 \helpref{UnloadLibrary
}{wxdllloaderunloadlibrary
}.
134 \wxheading{Parameters
}
136 \docparam{libname
}{Name of the shared object to load.
}
138 \docparam{success
}{May point to a bool variable which will be set to true or
139 false; may also be
{\tt NULL
}.
}
141 \membersection{wxDllLoader::UnloadLibrary
}\label{wxdllloaderunloadlibrary
}
143 \func{void
}{UnloadLibrary
}{\param{wxDllType
}{dllhandle
}}
145 This function unloads the shared library. The handle
{\it dllhandle
} must have
146 been returned by
\helpref{LoadLibrary
}{wxdllloaderloadlibrary
} previously.