📄 dllload.tex
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Name: dllload.tex%% Purpose: wxDllLoader documentation%% Author: Vadim Zeitlin%% Modified by:%% Created: 02.04.00%% RCS-ID: $Id: dllload.tex,v 1.11 2005/04/08 14:33:31 MW Exp $%% Copyright: (c) Vadim Zeitlin%% License: wxWindows license%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{\class{wxDllLoader}}\label{wxdllloader}\textbf{Deprecation note: } This class is deprecated since version 2.4 and isnot compiled in by default in version 2.6 and will be removed in 2.8. Pleaseuse \helpref{wxDynamicLibrary}{wxdynamiclibrary} instead.wxDllLoader is a class providing an interface similar to Unix's {\ttdlopen()}. It is used by the wxLibrary framework and manages the actualloading of shared libraries and the resolving of symbols in them. There are noinstances of this class, it simply serves as a namespace for its static memberfunctions.Please note that class \helpref{wxDynamicLibrary}{wxdynamiclibrary} provides alternative, friendlier interface to wxDllLoader.The terms {\it DLL} and {\it shared library/object} will both be used in thedocumentation to refer to the same thing: a {\tt .dll} file under Windows or {\tt .so} or {\tt .sl} one under Unix.Example of using this class to dynamically load the {\tt strlen()} function:\begin{verbatim}#if defined(__WXMSW__) static const wxChar *LIB_NAME = _T("kernel32"); static const wxChar *FUNC_NAME = _T("lstrlenA");#elif defined(__UNIX__) static const wxChar *LIB_NAME = _T("/lib/libc-2.0.7.so"); static const wxChar *FUNC_NAME = _T("strlen");#endif wxDllType dllHandle = wxDllLoader::LoadLibrary(LIB_NAME); if ( !dllHandle ) { ... error ... } else { typedef int (*strlenType)(char *); strlenType pfnStrlen = (strlenType)wxDllLoader::GetSymbol(dllHandle, FUNC_NAME); if ( !pfnStrlen ) { ... error ... } else { if ( pfnStrlen("foo") != 3 ) { ... error ... } else { ... ok! ... } } wxDllLoader::UnloadLibrary(dllHandle); }\end{verbatim}\wxheading{Derived from}No base class\wxheading{Include files}<wx/dynlib.h>\wxheading{Data structures}This header defines a platform-dependent {\tt wxDllType} typedef which storesa handle to a loaded DLLs on the given platform.\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxDllLoader::GetDllExt}\label{wxdllloadergetdllext}\func{static wxString}{GetDllExt}{\void}Returns the string containing the usual extension for shared libraries for thegiven systems (including the leading dot if not empty).For example, this function will return {\tt ".dll"} under Windows or (usually) {\tt ".so"} under Unix.\membersection{wxDllLoader::GetProgramHandle}\label{wxdllloadergetprogramhandle}\func{wxDllType}{GetProgramHandle}{\void}This function returns a valid handle for the main program itself. Notice thatthe {\tt NULL} return value is valid for some systems (i.e. doesn't mean thatthe function failed).{\bf NB:} This function is Unix specific. It will always fail under Windowsor OS/2.\membersection{wxDllLoader::GetSymbol}\label{wxdllloadergetsymbol}\func{void *}{GetSymbol}{\param{wxDllType }{dllHandle}, \param{const wxString\& }{name}}This function resolves a symbol in a loaded DLL, such as a variable orfunction name.Returned value will be {\tt NULL} if the symbol was not found in the DLL or ifan error occurred.\wxheading{Parameters}\docparam{dllHandle}{Valid handle previously returned by \helpref{LoadLibrary}{wxdllloaderloadlibrary}}\docparam{name}{Name of the symbol.}\membersection{wxDllLoader::LoadLibrary}\label{wxdllloaderloadlibrary}\func{wxDllType}{LoadLibrary}{\param{const wxString \& }{libname}, \param{bool* }{success = NULL}}This function loads a shared library into memory, with {\it libname} being thename of the library: it may be either the full name including path and(platform-dependent) extension, just the basename (no path and no extension)or a basename with extension. In the last two cases, the library will besearched in all standard locations.Returns a handle to the loaded DLL. Use {\it success} parameter to test if itis valid. If the handle is valid, the library must be unloaded later with \helpref{UnloadLibrary}{wxdllloaderunloadlibrary}.\wxheading{Parameters}\docparam{libname}{Name of the shared object to load.}\docparam{success}{May point to a bool variable which will be set to true orfalse; may also be {\tt NULL}.}\membersection{wxDllLoader::UnloadLibrary}\label{wxdllloaderunloadlibrary}\func{void}{UnloadLibrary}{\param{wxDllType }{dllhandle}}This function unloads the shared library. The handle {\it dllhandle} must havebeen returned by \helpref{LoadLibrary}{wxdllloaderloadlibrary} previously.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -