Eli*_*ght 7 python ctypes msvcrt
在Windows中,ctypes.cdll.msvcrt导入ctypes模块时对象自动存在,并且它根据文档表示msvcrtMicrosoft C++运行时库.
但是,我注意到还有一个find_msvcrt函数"return the filename of the VC runtype library used by Python".
它进一步指出, "If you need to free memory, for example, allocated by an extension module with a call to the free(void *), it is important that you use the function in the same library that allocated the memory."
所以我的问题是,ctypes.cdll.msvcrt我已经拥有的库与我可以使用该find_msvcrt函数加载的库之间的区别是什么?在什么具体情况下他们可能不是同一个图书馆?
Mar*_*wis 10
它不仅ctypes.cdll.msvcrt自动存在,而且ctypes.cdll.anything自动存在,并在第一次访问时加载,加载anything.dll.所以ctypes.cdll.msvcrt加载msvcrt.dll,这是一个作为Windows的一部分提供的库.它不是Python链接的C运行时,因此您不应该调用malloc/free msvcrt.
例如,对于Python 2.6/3.1,您应该使用ctypes.cdll.msvcr90.由于这会随着时间的推移而改变,因此find_msvcrt()为您提供应该使用的库的名称(然后加载ctypes.CDLL).
以下是Microsoft CRT的几个不同版本的名称,作为MSC,VC++,平台SDK或Windows的一部分在各个点发布:crtdll.dll,msvcrt.dll,msvcrt4.dll,msvcr70.dll,msvcr71. dll,msvcr80.dll,msvcr90.dll.
| 归档时间: |
|
| 查看次数: |
2199 次 |
| 最近记录: |