OSError: access violation reading 0xXXXXXXXXXXX error when calling a DLL using ctypes

OSError: access violation reading 0xXXXXXXXXXXX error when calling a DLL using ctypes

我已经搜索过这个问题的答案,但总是找不到答案。我已经设法让几个 DLL 正常工作,但是这个给我带来了一些麻烦:

import ctypes
from ctypes import *
import my_module

dll = CDLL('C:\Path_to_dll')
MF = (b'C:\Path_to_file')

这不起作用:

PN = (b'parameter_name')
beginTime = ctypes.c_double(-value)
endTime = ctypes.c_double(+value)
DT_RETURNGMT = 0x0100
DT_FLOAT = 0x0001
convertType = (DT_RETURN|DT_BOOL)
Null = 0

dll.readPam.argtypes = POINTER(File), c_char_p, 
c_double, c_double, c_double, POINTER(TTag), c_ushort,
dll.readPam.restype = POINTER(Pam)

这是出现错误的地方:

g = dll.readPam(f, PN, beginTime, endTime, Null, Null, convertType)

OSError: exception: access violation reading 0x0000000000000000

我的问题是:指示无法读取的错误具体是什么?我该如何解决? dll 应该做的是在我键入时打印出数据值:

print(g)
print(g[0].tS[0].data)
dll.freePam(g)

我的问题已经解决了。在我使用完文件之前,我正在释放我的文件。所以我写的地方:

dll.freeFile(f)

我在不该释放文件的时候释放了文件。所以我删除了那行,现在它在我的代码末尾。具有讽刺意味的是,一旦我解决了这个问题 python 又给了我一个...