Python 3.2 PyRun_SimpleString - 它在哪里?

时间:2012-07-23 22:50:07

标签: c++ python-3.x

我正在尝试将应用程序与Python的自定义发行版一起发布(添加了模块和我自己的扩展)。

为了保持简单而不存在与潜在的现有安装发生冲突的风险,我认为最好的方法是从我的应用程序下的子目录中运送\ PythonLS \。*和。\ Lib *。*树。 \ MyApp的\的Python \

我只直接调用3个Py *函数: (代码是C ++ Builder ......)

typedef void (__stdcall *PY_SETPYTHONHOME) (wchar_t *);
PY_SETPYTHONHOME Py_SetPythonHome;

typedef void (__stdcall *PY_INITIALIZE) ();
PY_INITIALIZE Py_Initialize;

typedef int (__stdcall *PYRUN_SIMPLESTRING) (const char *);
PYRUN_SIMPLESTRING PyRun_SimpleString;




HMODULE py_dll_hndle;
py_dll_hndle = ::LoadLibrary((ExtractFilePath(Application->ExeName) + "Python\\DLLS\\python3.dll").c_str());
ShowMessage(py_dll_hndle == NULL ? L"Bah" : L"Yay");     // Result: "Yay"


Py_SetPythonHome = (PY_SETPYTHONHOME) ::GetProcAddress(py_dll_hndle, "Py_SetPythonHome");
ShowMessage(Py_SetPythonHome == NULL ? L"Bah" : L"Yay");     // Result: "Yay"


Py_Initialize = (PY_INITIALIZE) ::GetProcAddress(py_dll_hndle, "Py_Initialize");
ShowMessage(Py_Initialize == NULL ? L"Bah" : L"Yay");     // Result: "Yay"


PyRun_SimpleString = (PYRUN_SIMPLESTRING) ::GetProcAddress(py_dll_hndle, "PyRun_SimpleString");
ShowMessage(GetLastError());     // Result: "127" (ERROR_PROC_NOT_FOUND)
ShowMessage(PyRun_SimpleString == NULL ? L"Bah" : L"Yay");     // Result: "Bah"

PyRun_SimpleString不存在?我一直在寻找使用http://www.nirsoft.net/ DLL导出查看器...它不在那里。我很困惑......那是什么呢?

1 个答案:

答案 0 :(得分:4)

有两个DLL的python3.dll和python32.dll。第一个是第二个的子集。 python32.dll只有一个副本 - 隐藏在我的\ Windows \ SysWOW64 \目录中,而python3.dll也位于c:\ Python32 \ DLLs目录中。

使用python32.dll而不是python3.dll解决了这个问题。

虽然有一些部分重复,但仍然是一个谜......