]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dynlib.tex
added copy constr
[wxWidgets.git] / docs / latex / wx / dynlib.tex
CommitLineData
f3845e88
VZ
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: dynlib.tex
defbed48 3%% Purpose: wxDynamicLibrary and wxDynamicLibraryDetails documentation
f3845e88
VZ
4%% Author: Vadim Zeitlin
5%% Modified by:
6%% Created: 14.01.02 (extracted from dllload.tex)
7%% RCS-ID: $Id$
8%% Copyright: (c) Vadim Zeitlin
8795498c 9%% License: wxWindows license
f3845e88
VZ
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12\section{\class{wxDynamicLibrary}}\label{wxdynamiclibrary}
13
14wxDynamicLibrary is a class representing dynamically loadable library
169948a0
VZ
15(Windows DLL, shared library under Unix etc.). Just create an object of
16this class to load a library and don't worry about unloading it -- it will be
17done in the objects destructor automatically.
f3845e88 18
defbed48 19\wxheading{Derived from}
f3845e88 20
defbed48
VZ
21No base class.
22
23\wxheading{Include files}
24
25<wx/dynlib.h>
26
a7af285d
VZ
27\wxheading{Library}
28
29\helpref{wxBase}{librarieslist}
30
defbed48
VZ
31(only available if \texttt{wxUSE\_DYNLIB\_CLASS} is set to $1$)
32
33\latexignore{\rtfignore{\wxheading{Members}}}
a018a119 34
f3845e88
VZ
35\membersection{wxDynamicLibrary::wxDynamicLibrary}\label{wxdynamiclibrarywxdynamiclibrary}
36
37\func{}{wxDynamicLibrary}{\void}
38
169948a0 39\func{}{wxDynamicLibrary}{\param{const wxString\& }{name}, \param{int }{flags = wxDL\_DEFAULT}}
f3845e88
VZ
40
41Constructor. Second form calls \helpref{Load}{wxdynamiclibraryload}.
42
a018a119 43
169948a0
VZ
44\membersection{wxDynamicLibrary::CanonicalizeName}\label{wxdynamiclibrarycanonicalizename}
45
08890e27 46\func{static wxString}{CanonicalizeName}{\param{const wxString\& }{name}, \param{wxDynamicLibraryCategory}{ cat = wxDL\_LIBRARY}}
169948a0
VZ
47
48Returns the platform-specific full name for the library called \arg{name}. E.g.
49it adds a {\tt ".dll"} extension under Windows and {\tt "lib"} prefix and
50{\tt ".so"}, {\tt ".sl"} or maybe {\tt ".dylib"} extension under Unix.
51
52The possible values for \arg{cat} are:
5bb31e35 53
169948a0
VZ
54\begin{twocollist}
55 \twocolitem{wxDL\_LIBRARY}{normal library}
56 \twocolitem{wxDL\_MODULE}{a loadable module or plugin}
57\end{twocollist}
58
59\wxheading{See also}
60
61\helpref{CanonicalizePluginName}{wxdynamiclibrarycanonicalizepluginname}
62
63
a018a119 64
169948a0
VZ
65\membersection{wxDynamicLibrary::CanonicalizePluginName}\label{wxdynamiclibrarycanonicalizepluginname}
66
08890e27 67\func{static wxString}{CanonicalizePluginName}{\param{const wxString\& }{name}, \param{wxPluginCategory}{ cat = wxDL\_PLUGIN\_GUI}}
169948a0
VZ
68
69This function does the same thing as
fc2171bd 70\helpref{CanonicalizeName}{wxdynamiclibrarycanonicalizename} but for wxWidgets
169948a0
VZ
71plugins. The only difference is that compiler and version information are added
72to the name to ensure that the plugin which is going to be loaded will be
73compatible with the main program.
74
75The possible values for \arg{cat} are:
5bb31e35 76
169948a0
VZ
77\begin{twocollist}
78 \twocolitem{wxDL\_PLUGIN\_GUI}{plugin which uses GUI classes (default)}
79 \twocolitem{wxDL\_PLUGIN\_BASE}{plugin which only uses wxBase}
80\end{twocollist}
81
a018a119 82
9ae2ec95
VZ
83\membersection{wxDynamicLibrary::Detach}\label{wxdynamiclibrarydetach}
84
85\func{wxDllType}{Detach}{\void}
86
87Detaches this object from its library handle, i.e. the object will not unload
88the library any longer in its destructor but it is now the callers
43e8916f 89responsibility to do this using \helpref{Unload}{wxdynamiclibraryunload}.
169948a0 90
a018a119 91
169948a0
VZ
92\membersection{wxDynamicLibrary::GetSymbol}\label{wxdynamiclibrarygetsymbol}
93
a018a119 94\constfunc{void *}{GetSymbol}{\param{const wxString\& }{name}}
169948a0
VZ
95
96Returns pointer to symbol {\it name} in the library or NULL if the library
97contains no such symbol.
98
99\wxheading{See also}
100
101\helpref{wxDYNLIB\_FUNCTION}{wxdynlibfunction}
102
a018a119 103
93ed8ff7
VZ
104\membersection{wxDynamicLibrary::GetSymbolAorW}\label{wxdynamiclibrarygetsymbolaorw}
105
106\constfunc{void *}{GetSymbolAorW}{\param{const wxString\& }{name}}
107
108This function is available only under Windows as it is only useful when
109dynamically loading symbols from standard Windows DLLs. Such functions have
110either \texttt{'A'} (in ANSI build) or \texttt{'W'} (in Unicode, or wide
111character build) suffix if they take string parameters. Using this function you
112can use just the base name of the function and the correct suffix is appende
113automatically depending on the current build. Otherwise, this method is
114identical to \helpref{GetSymbol}{wxdynamiclibrarygetsymbol}.
115
116
6d94009f
VZ
117\membersection{wxDynamicLibrary::GetProgramHandle}\label{wxdynamiclibrarygetprogramhandle}
118
119\func{static wxDllType}{GetProgramHandle}{\void}
120
121Return a valid handle for the main program itself or \texttt{NULL} if symbols
122from the main program can't be loaded on this platform.
123
124
a018a119
VZ
125\membersection{wxDynamicLibrary::HasSymbol}\label{wxdynamiclibraryhassymbol}
126
127\constfunc{bool}{HasSymbol}{\param{const wxString\& }{name}}
128
129Returns \true if the symbol with the given \arg{name} is present in the dynamic
130library, \false otherwise. Unlike \helpref{GetSymbol}{wxdynamiclibrarygetsymbol},
131this function doesn't log an error message if the symbol is not found.
132
133\newsince{2.5.4}
134
135
f3845e88
VZ
136\membersection{wxDynamicLibrary::IsLoaded}\label{wxdynamiclibraryisloaded}
137
138\constfunc{bool}{IsLoaded}{\void}
139
169948a0
VZ
140Returns \true if the library was successfully loaded, \false otherwise.
141
a018a119 142
defbed48
VZ
143\membersection{wxDynamicLibrary::ListLoaded}\label{wxdynamiclibrarylistloaded}
144
145\func{static wxDynamicLibraryDetailsArray}{ListLoaded}{\void}
146
147This static method returns an \helpref{array}{wxarray} containing the details
148of all modules loaded into the address space of the current project, the array
149elements are object of \texttt{wxDynamicLibraryDetails} class. The array will
43e8916f 150be empty if an error occurred.
defbed48 151
297ebe6b
VZ
152This method is currently implemented only under Win32 and Linux and is useful
153mostly for diagnostics purposes.
defbed48
VZ
154
155
f3845e88
VZ
156\membersection{wxDynamicLibrary::Load}\label{wxdynamiclibraryload}
157
169948a0 158\func{bool}{Load}{\param{const wxString\& }{name}, \param{int }{flags = wxDL\_DEFAULT}}
f3845e88 159
169948a0
VZ
160Loads DLL with the given \arg{name} into memory. The \arg{flags} argument can
161be a combination of the following bits:
d2c2afc9 162
169948a0
VZ
163\begin{twocollist}
164\twocolitem{wxDL\_LAZY}{equivalent of RTLD\_LAZY under Unix, ignored elsewhere}
165\twocolitem{wxDL\_NOW}{equivalent of RTLD\_NOW under Unix, ignored elsewhere}
166\twocolitem{wxDL\_GLOBAL}{equivalent of RTLD\_GLOBAL under Unix, ignored elsewhere}
167\twocolitem{wxDL\_VERBATIM}{don't try to append the appropriate extension to
168the library name (this is done by default).}
e62e17d7 169\twocolitem{wxDL\_DEFAULT}{default flags, same as wxDL\_NOW currently}
169948a0 170\end{twocollist}
f3845e88 171
169948a0 172Returns \true if the library was successfully loaded, \false otherwise.
f3845e88 173
a018a119 174
169948a0 175\membersection{wxDynamicLibrary::Unload}\label{wxdynamiclibraryunload}
f3845e88 176
169948a0 177\func{void}{Unload}{\void}
f3845e88 178
169948a0 179\func{static void}{Unload}{\param{wxDllType }{handle}}
f3845e88 180
169948a0
VZ
181Unloads the library from memory. wxDynamicLibrary object automatically calls
182this method from its destructor if it had been successfully loaded.
4104ed92 183
169948a0
VZ
184The second version is only used if you need to keep the library in memory
185during a longer period of time than the scope of the wxDynamicLibrary object.
186In this case you may call \helpref{Detach}{wxdynamiclibrarydetach} and store
187the handle somewhere and call this static method later to unload it.
f3845e88 188
defbed48
VZ
189%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190
191\section{\class{wxDynamicLibraryDetails}}\label{wxdynamiclibrarydetails}
192
193This class is used for the objects returned by
194\helpref{wxDynamicLibrary::ListLoaded}{wxdynamiclibrarylistloaded} method and
195contains the information about a single module loaded into the address space of
196the current process. A module in this context may be either a dynamic library
197or the main program itself.
198
199\wxheading{Derived from}
200
201No base class.
202
203\wxheading{Include files}
204
205<wx/dynlib.h>
206
a7af285d
VZ
207\wxheading{Library}
208
209\helpref{wxBase}{librarieslist}
210
defbed48
VZ
211(only available if \texttt{wxUSE\_DYNLIB\_CLASS} is set to $1$)
212
213\latexignore{\rtfignore{\wxheading{Members}}}
214
215\membersection{wxDynamicLibraryDetails::GetName}\label{wxdynamiclibrarygetname}
216
217\constfunc{wxString}{GetName}{\void}
218
219Returns the base name of this module, e.g. \texttt{kernel32.dll} or
220\texttt{libc-2.3.2.so}.
221
222
223\membersection{wxDynamicLibraryDetails::GetPath}\label{wxdynamiclibrarygetpath}
224
225\constfunc{wxString}{GetPath}{\void}
226
227Returns the full path of this module if available, e.g.
228\texttt{c:$\backslash$windows$\backslash$system32$\backslash$kernel32.dll} or
229\texttt{/lib/libc-2.3.2.so}.
230
231
232\membersection{wxDynamicLibraryDetails::GetAddress}\label{wxdynamiclibrarygetaddress}
233
234\constfunc{bool}{GetAddress}{\param{void **}{addr}, \param{size\_t }{*len}}
235
236Retrieves the load address and the size of this module.
237
238\wxheading{Parameters}
239
240\docparam{addr}{the pointer to the location to return load address in, may be
241\texttt{NULL}}
242
243\docparam{len}{pointer to the location to return the size of this module in
244memory in, may be \texttt{NULL}}
245
246\wxheading{Return value}
247
248\true if the load address and module size were retrieved, \false if this
249information is not available.
250
251
252\membersection{wxDynamicLibraryDetails::GetVersion}\label{wxdynamiclibrarygetversion}
253
254\constfunc{wxString}{GetVersion}{\void}
255
256Returns the version of this module, e.g. \texttt{5.2.3790.0} or
257\texttt{2.3.2}. The returned string is empty if the version information is not
258available.
259