使用ctype将参数传递到dll。

2024-04-26 03:31:48 发布

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

当不需要传入任何参数时,它都可以工作,使用相同的dll。但当我必须传递int或char*时,就会出现错误。我遵循了Python的ctype文档说明。C/C++代码如下,

typedef int LNI;


#if !defined(RC_INCLUDE)

#if !defined(_DLLEXPORT_)

// If _DLLEXPORT_ is not defined then the default is to import.
#if defined(__cplusplus)
#define DLLENTRY extern "C" __declspec(dllimport)
#define STDENTRY extern "C" __declspec(dllimport) HRESULT WINAPI
#define STDENTRY_(type) extern "C" __declspec(dllimport) type WINAPI
#else
#define DLLENTRY __declspec(dllimport)
#define STDENTRY __declspec(dllimport) HRESULT WINAPI
#define STDENTRY_(type) __declspec(dllimport) type WINAPI
#endif

#else  // _DLLEXPORT_
// Else if _DLLEXPORT_ is defined then we've been told to export.

#if defined(__cplusplus)
#define DLLENTRY extern "C" __declspec(dllexport)
#define STDENTRY extern "C" __declspec(dllexport) HRESULT WINAPI
#define STDENTRY_(type) extern "C" __declspec(dllexport) type WINAPI
#else
#define DLLENTRY __declspec(dllexport)
#define STDENTRY __declspec(dllexport) HRESULT WINAPI
#define STDENTRY_(type) __declspec(dllexport) type WINAPI
#endif

#endif // _DLLEXPORT_

// Here is the list of service APIs offered by the DLL (using the
//   appropriate entry API declaration macros just #defined above).
STDENTRY_(LNI)     ldv_open(char* device_name);

我试图使用Python2.7访问ldv\u open,但我仍然得到“ValueError:Procedure called with not enough arguments<;4 byte missing>;或错误的调用约定”。我仔细研究了这个问题,并尝试了我找到的每一个解决办法。仍然没有解决办法。有人能告诉我我做错了什么吗?在

^{pr2}$

Tags: theifistypeexternplusdefineddefine