我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用ctypes.cdll.load()。
def test(): from ctypes import cdll if os.name == "nt": print cdll.msvcrt print cdll.load("msvcrt") print find_library("msvcrt") if os.name == "posix": # find and load_version print find_library("m") print find_library("c") print find_library("bz2") # getattr ## print cdll.m ## print cdll.bz2 # load if sys.platform == "darwin": print cdll.LoadLibrary("libm.dylib") print cdll.LoadLibrary("libcrypto.dylib") print cdll.LoadLibrary("libSystem.dylib") print cdll.LoadLibrary("System.framework/System") else: print cdll.LoadLibrary("libm.so") print cdll.LoadLibrary("libcrypt.so") print find_library("crypt")
def test(): from ctypes import cdll if os.name == "nt": print(cdll.msvcrt) print(cdll.load("msvcrt")) print(find_library("msvcrt")) if os.name == "posix": # find and load_version print(find_library("m")) print(find_library("c")) print(find_library("bz2")) # getattr ## print cdll.m ## print cdll.bz2 # load if sys.platform == "darwin": print(cdll.LoadLibrary("libm.dylib")) print(cdll.LoadLibrary("libcrypto.dylib")) print(cdll.LoadLibrary("libSystem.dylib")) print(cdll.LoadLibrary("System.framework/System")) else: print(cdll.LoadLibrary("libm.so")) print(cdll.LoadLibrary("libcrypt.so")) print(find_library("crypt"))
def test(): from ctypes import cdll if os.name == "nt": sys.stdout.write('%s\n' % (cdll.msvcrt,)) sys.stdout.write('%s\n' % (cdll.load("msvcrt"),)) sys.stdout.write('%s\n' % (find_library("msvcrt"),)) if os.name == "posix": # find and load_version sys.stdout.write('%s\n' % (find_library("m"),)) sys.stdout.write('%s\n' % (find_library("c"),)) sys.stdout.write('%s\n' % (find_library("bz2"),)) # getattr ## print_ cdll.m ## print_ cdll.bz2 # load if sys.platform == "darwin": sys.stdout.write('%s\n' % (cdll.LoadLibrary("libm.dylib"),)) sys.stdout.write('%s\n' % (cdll.LoadLibrary("libcrypto.dylib"),)) sys.stdout.write('%s\n' % (cdll.LoadLibrary("libSystem.dylib"),)) sys.stdout.write('%s\n' % (cdll.LoadLibrary("System.framework/System"),)) else: sys.stdout.write('%s\n' % (cdll.LoadLibrary("libm.so"),)) sys.stdout.write('%s\n' % (cdll.LoadLibrary("libcrypt.so"),)) sys.stdout.write('%s\n' % (find_library("crypt"),))