0
Windows 7에서 Python Ctypes를 사용하여 C++ DLL에 액세스하고 있습니다. DLL 설명서가 있지만 실제로 열 수 없습니다. 함수를 사용하는 C++ 함수를 사용하려고합니다.이 함수는 부호없는 int와 void 포인터를 차례로 사용합니다.Ctypes - 파이썬에서 무효 포인터 전달
내가 마지막 줄에이 오류가이 코드를 실행 할 때마다import ctypes
import os
root = os.path.dirname(__file__)
lib = ctypes.WinDLL(os.path.join(root, 'x86', 'toupcam.dll')) #works
cam = lib.Toupcam_Open(None) #works
def f(event, ctx): #Python version of function to pass in
pass
#converting Python function to C function:
#CFUNTYPE params: return type, parameter types
func = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)(f)
res = lib.Toupcam_StartPullModeWithCallback(cam, func) #fails
:
OSError: exception: access violation writing 0x002CF330.
난 정말이 문제를 접근하는 방법을 알고하지 않기 때문에, 여기에 실패 짧은 코드 샘플입니다 Python 오류가 아닌 C++ 오류입니다. C++에서 온라인으로 찾은 비슷한 오류가 포인터와 관련되어 있기 때문에 내 무효 포인터와 관련이 있다고 생각합니다. Ctypes void 포인터에 문제가 있습니까? 아니면 잘못된 것이 있습니까?
빠른 구글은'Toupcam_StartPullModeWithCallback'은 카메라, 콜백, 컨텍스트라는 세 가지 인수를 취한다는 것을 보여줍니다. http://www.webastro.net/forum/archive/index.php/t-138355.html – kfsone