通过python操作dll

木头的喵喵拖孩

调用 dll 里的函数

1
2
3
4
5
6
7
8
9
10
from ctypes import *
import os

# 加载当前目录下的my.dll
current_path = current_directory = os.path.dirname(os.path.realpath(__file__))
os.add_dll_directory(current_path)
dll = windll.LoadLibrary(r"my.dll")

# 调用dll里的函数,需要事先知道函数名称和参数
dll.funcname(arg1, arg2)

查看 dll 里的所有函数

1
2
3
from ctypes import *
dll = windll.LoadLibrary("path.dll")
print(dir(dll))
  • 标题: 通过python操作dll
  • 作者: 木头的喵喵拖孩
  • 创建于: 2023-11-15 10:19:05
  • 更新于: 2024-05-21 10:56:15
  • 链接: https://blog.xx-xx.top/2023/11/15/通过python操作dll/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。