使用python中的ctypes模块可以很方便的调用windows的dll(也包括linux下的so等文件)

引入ctypes库 有两种方法

from ctypes import *
import ctypes

加载DLL

stdcall调用约定:两种加载方式

Objdll = ctypes.windll.LoadLibrary("dllpath")
Objdll = ctypes.WinDLL("dll")

cdecl调用约定:也有两种加载方式

Objdll = ctypes.cdll.LoadLibrary("dllpath")
Objdll = ctypes.CDLL("dll")

引入ctypes库的方法不同,对应不同的加载DLL方式

第一种:

from ctypes import *

Objdll = ctypes.WinDLL("dll")
#或者
Objdll = ctypes.CDLL("dll")

第二种:

import ctypes

Objdll = ctypes.windll.LoadLibrary("dllpath")
#或者
Objdll = ctypes.cdll.LoadLibrary("dllpath")

Python 报错:NameError: name 'ctypes' is not defined的更多相关文章

  1. 报错NameError: name ‘null’ is not defined的解决方法

    报错NameError: name 'null' is not defined的解决方法 eval()介绍 eval()函数十分强大,官方demo解释为:将字符串str当成有效的表达式来求值并返回计算 ...

  2. Python,报错NameError: name 'math' is not defined

    1 #-*- coding : utf-8 -*- 2 import math 3 4 def move(x, y, step, angle=0): 5 nx = x + step * math.co ...

  3. py+selenium 报错NameError: name 'NoSuchElementException' is not defined【已解决】

     报错:NameError: name 'NoSuchElementException' is not defined  如图 解决方法: 头部加一句:from selenium.common.exc ...

  4. python2执行程序报错:NameError: name 'y' is not defined

    然后运行一直报错 这个错误,是由于版本不同造成的语法错误,在python3中,输入可以使用input,但如果你的版本是python2,那么此时input就得改成raw_input,否则你输入数据会被当 ...

  5. Python2.7错误处理FileNotFoundError报错NameError: name 'FileNotFoundError' is not defined

    错误信息如下: 原因是FileNotFoundError是python3.0中的写法,而Python2.7中应写为IOError.

  6. [报错]-NameError: name 'NAN' is not defined

    部分数据输出为NaN,处理这部分异常数据使用isnan()函数 from math import isnan isnan(z) 参考: https://www.cnblogs.com/itdyb/p/ ...

  7. Python报错总结丶自定义报错

    Python报错总结: 常见异常 1,NameError: name 'a' is not defined:未定义函数名             2,IndentationError: uninden ...

  8. Python报错module 'scipy.misc' has no attribute 'xxx'

    Python报错module 'scipy.misc' has no attribute 'imresize' 解决办法: 安装Pillow包,命令如下: pip install Pillow 然后重 ...

  9. selenium python 报错“ unable to find binary in default location”

    selenium python 报错如下: raise exception_class(message, screen, stacktrace)selenium.common.exceptions.W ...

  10. 解决Python报错:local variable 'xxx' referenced before assignment(引)

    解决Python报错:local variable 'xxx' referenced before assignment(引) 解决Python报错:local variable 'xxx' refe ...

随机推荐

  1. ABAP基础4:模块化

    子程序定义 以form开始,以endform结束,用perform语句调用,from语句可以在程序内部/外部,perform一定要写在前面 perform. from. 子程序模块 endform. ...

  2. GreenPlum执行gpfdist报错:libssl.so.1.0.0: cannot open shared object file: No such file or directory

    当你报这个错时,是因为你执行 ./gpfdist 时默认去找寻/usr/lib64的环境依赖,没有去找寻你gpfdist安装目录中lib的目录. 解决方法: 根据报错提示,将你gpfdist安装目录中 ...

  3. J2EE项目中,servlet跳转到相应的JSP页面后,JSP页面丢失了样式效果

    原因: js和css的引用路径是相对路径.跳转后路径改变. 解决方法: 先在head标签中加入一下代码 <% String path = request.getContextPath(); St ...

  4. ShoneSharp语言(S#)的设计和使用介绍系列(11)—“类”披炫服靓妆化成“表”

    ShoneSharp语言(S#)的设计和使用介绍 系列(11)—“类”披炫服靓妆化成“表” 作者:Shone 声明:原创文章欢迎转载,但请注明出处,https://www.cnblogs.com/Sh ...

  5. 软链接 vs. 硬链接

    ​链接大家都用过,比如 Windows 中的快捷方式就是一种链接,可是 Linux 里又分硬链接和软链接,它们表示什么意思,又有什么区别呢,本文来给大家做一个解释. Inode 索引节点 要想理解硬链 ...

  6. 将BeyondCompare设置为TortoiseSVN的扩展比较工具

    1)点击鼠标右键 -> 点击TortoiseSVN -> Settings,如下图: 2)选择Diff Viewer - > 选择External(并配置好参数),具体如下图: 3) ...

  7. TP5.0验证器使用方法

    比如我要在分类做一个验证器,首先要在你的后台模块先建立一个文件夹,比如我的后台模块是admin,那么你要在admin里面建立一个validate的文件夹然后再建立一个对应的php文件如下图 文件里面的 ...

  8. Java 对象的封装,继承,抽象,接口写法

    面向对象的封装写法        关键字 private class A    {        private int a=1;        private void work()         ...

  9. 漫谈碎片化学习(Fragmentation learning)

    碎片化学习(Fragmentation Learning) 从一个互联网小段子讲起: 某天,美国情报部门FBI应奥巴马的要求,做相关汇报:“报告总统,经FBI分析,中国‘短信’中35%是节日祝福语,2 ...

  10. 线程池 & 线程调度

    线程池1. 第四种获取线程的方法:线程池,一个 ExecutorService,它使用可能的几个池线程之 一执行每个提交的任务, 通常使用 Executors 工厂方法配置. 2. 线程池可以解决两个 ...