从 Python 文本传递完整的 LPCSTR 到 C++ DLL

2024-06-28 16:24:43 发布

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

我有一个简单的c++dll,它调用MessageBox来显示文本

#include <Windows.h>

#define LIBDLL extern "C" __declspec(dllexport)

LIBDLL void Display(LPCTSTR lpInput) {
    MessageBox(0, lpInput, 0, 0);
}

bool __stdcall DllMain(void* hModule, unsigned long dwReason, void* lpReserved) {
switch (dwReason)
{

case 1:
    break;
case 0:
    break;

case 2:
    break;

case 3:
    break;

}

return true;
}

而Python代码只向dll中的显示传递一个字符串,如下所示

^{pr2}$

它只显示第一个字母,即使我使用的是std::cout

MessageBox output

如何让它显示我传递给它的所有文本?在


Tags: 文本includewindowsexterndllcasebreakvoid