[ctypes-commit] ctypes/docs/manual tutorial.txt,1.18,1.19
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-04-19 18:14:45
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17323 Modified Files: tutorial.txt Log Message: LoadLibrary, CDLL, functions exported by ordinals. Index: tutorial.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/tutorial.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tutorial.txt 19 Apr 2006 17:43:15 -0000 1.18 --- tutorial.txt 19 Apr 2006 18:14:39 -0000 1.19 *************** *** 44,59 **** >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX ! <CDLL '/lib/libc.so.6', handle ... at ...> ! >>> CDLL("libc.so.6") ! <CDLL '/lib/libc.so.6', handle ... at ...> >>> - **Note:** in older versions, the ``LoadLibrary`` method should be used - instead. - - This tutorial uses windows in its examples, however, functions from - the standard C library like ``strchr`` and ``printf`` should also work - on Linux and other systems. - Accessing functions from loaded dlls --- 44,53 ---- >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX ! <CDLL 'libc.so.6', handle ... at ...> ! >>> libc = CDLL("libc.so.6") ! >>> libc ! <CDLL 'libc.so.6', handle ... at ...> >>> Accessing functions from loaded dlls *************** *** 73,77 **** func = _StdcallFuncPtr(name, self) AttributeError: function 'MyOwnFunction' not found ! Note that win32 system dlls like ``kernel32`` and ``user32`` often --- 67,71 ---- func = _StdcallFuncPtr(name, self) AttributeError: function 'MyOwnFunction' not found ! >>> Note that win32 system dlls like ``kernel32`` and ``user32`` often *************** *** 96,100 **** Sometimes, dlls export functions with names which aren't valid Python identifiers, like ``"??2@YAPAXI@Z"``. In this case you have to use ! ``getattr`` to retrieve the function (XXX Better example?):: >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS --- 90,94 ---- Sometimes, dlls export functions with names which aren't valid Python identifiers, like ``"??2@YAPAXI@Z"``. In this case you have to use ! ``getattr`` to retrieve the function:: >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS *************** *** 102,105 **** --- 96,107 ---- >>> + On Windows, some dlls export functions not by name but by ordinal. + These functions can be accessed by indexing the dll object with the + odinal number:: + + >>> cdll.kernel32[1] # doctest: +WINDOWS + <_FuncPtr object ar 0x...> + >>> cdll.kernel32[0] # doctest: +WINDOWS + >>> Calling functions |