我正在尝试编写python代码来调用dll函数并停留在下面的函数中,我认为这与typedef回调函数或函数指针有关.
我已经测试了下面的代码,当调用回调函数时,python崩溃(窗口通知 - python.exe已停止响应),没有调试消息.
我很困惑,任何帮助将不胜感激:)
谢谢!
C:
#ifdef O_Win32
/** @cond */
#ifdef P_EXPORTS
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif // #ifdef P_EXPORTS
/** @endcond */
#endif // #ifdef O_Win32
// Type definition
typedef void (__stdcall *StatusCB)(int nErrorCode, int nSID, void *pArg);
//Function
void GetStatus(StatusCB StatusFn, void *pArg);
Run Code Online (Sandbox Code Playgroud)
蟒蛇:
from ctypes import *
def StatusCB(nErrorCode, nSID, pArg):
print 'Hello world'
def start():
lib = cdll.LoadLibrary('API.dll')
CMPFUNC = WINFUNCTYPE(c_int, c_int, c_void_p)
cmp_func = CMPFUNC(StatusCB)
status_func = lib.GetStatus
status_func(cmp_func)
Run Code Online (Sandbox Code Playgroud) 我正在构建一个使用react native的应用程序,并希望获得背景图像和滚动视图,它覆盖在背景图像之上,如雅虎天气应用程序.
但我无法让它发挥作用.
请帮忙.