简体   繁体   English

在python ctypes中,“ c_ubyte”存在,但“ c_ubyte_p”不存在

[英]In python ctypes, “c_ubyte” existences, but “c_ubyte_p” does not exist

The problem has been bothering me for a few days. 问题困扰了我几天。 I use python call dll Dynamic link library. 我使用python调用dll动态链接库。 This is C++ callback function: 这是C ++回调函数:

typedef void(CALLBACK *fRealDataCallBack)(
  LONG      lRealHandle,
  DWORD     dwDataType,
  BYTE      *pBuffer,
  DWORD     dwBufSize,
  DWORD     dwUser
);

I redefined it in python like this: 我像这样在python中重新定义了它:

def realdatacallback(lRealHandle, dwDataType, fBuffer, dwBufSize, pUser):
    print("hi")

pRealDataInfoFv = CFUNCTYPE(c_long, c_int, c_char_p, c_int, c_void_p)
pRealDataInfoHandle = pRealDataInfoFv(realdatacallback)

There is something wrong with the code.Please look at the third parameter: BYTE *pBuffer. 代码有问题。请查看第三个参数:BYTE * pBuffer。 In ctypes, "c_ubyte" existences, but "c_ubyte_p" does not exist. 在ctypes中,存在“ c_ubyte”,但不存在“ c_ubyte_p”。 How can I fix this? 我怎样才能解决这个问题? Finally, I have to say that I'm not good at English. 最后,我不得不说我的英语不好。

在ctypes中,您可以使用POINTER(c_ubyte)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM