如何从dll函数到python获取参数

2024-09-30 23:39:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个包含这个函数的DLL文件

signed int __stdcall EncodeInit(unsigned int a1, int a2, int a3, int a4)
{
  signed int result; // eax@1

  result = 55;
  *(_DWORD *)a2 = (signed __int64)((double)a1 / 1.37 - 25.0 - 23.0 - 2.0 - 6.0);
  return result;
}

我试图从Python调用此函数:

import ctypes
from ctypes import cdll

# Load DLL into memory.

hllDll = cdll.LoadLibrary("E:\\sap mobile\\Bin32\\dbencod11.dll")
a1 = ctypes.c_int32(1)
print hllDll.EncodeInit(11, a1, 31, 4)

但我有个错误:

WindowsError: exception: access violation writing 0x00000001

因为a1是常量。如何解决此问题?你知道吗


Tags: 文件函数importa2a1resultctypesint