首页 > 解决方案 > 如何使用 ctypes 接收 wchar_t * 字符串

问题描述

使用 ctypes 的类 Python 代码

我正在用python编写代码来使用一个dll。此 dll 请求以这种格式生成的密钥。我怎么能用python做到这一点?

C++

string Code = "1234567890987654321";
            const wchar_t* key;
            wstring keystr = std::wstring(Code.begin(), Code.end());
            key = keystr.c_str();

我试过这样的Python

Code = "1234567890987654321"
keystr = c_wchar_p(Code)
key = c.create_unicode_buffer(keystr)

标签: pythonpython-3.xwindowsctypes

解决方案


推荐阅读