???????python????Ч????????????????????????????????????????Ч???????????????????????????c??c++??????????c??c++??????python??????????????????????python???Щ???????????????????????????????????Plugin??????????????????????????????б???????????????????????c??????python????????python??c??????????????c??python?????????????????????????????
???????????
?????????c??????python?????????????????????python???????????????python?????????python???????libs?е?python27.lib???????????????????????????п??????google?????????c???????python???Щ??????????????????????python??????μ?include?????????include???С??????????????????Щ???????????????????????????????????
???????python?????
??????c?????python????????????????????include Python.h???????????????????????????python?????????????
????1 Py_SetPythonHome("D:Python27");
????2 Py_Initialize();
????Py_SetPythonHome??????????????python???·???????python???·????Py_Initialize????????????????python????????????????python??????????c?????
????????python???
??????python??????????????????????python??????c?е??y??????е?????????漸?????裺
????1?????PyImport_ImportModule????????飻
????2?????PyObject_GetAttrString??????????????????
????3?????Py_VaBuildValue????????????
????4?????PyObject_CallObject?????????????
????5?????PyArg_Parse????????????????
?????????????????????????е????????????????????д????????????????5?????裬??????????£?
1 int PyModuleRunFunction(const char *module?? const char *function??
2                         const char *result_format?? void *result?? const char *args_format?? ...)
3 {
4
5     PyObject *pmodule?? *pfunction?? *args?? *presult;
6
7     pmodule = PyImport_ImportModule(const_cast<char *>(module));
8     if (!pmodule)
9     {
10         PyObject *type = PyErr_Occurred();
11         if (type == PyExc_NameError)
12         {
13             PyErr_Clear();
14             return 0;
15         }
16
17         PyError("PyModuleRunFunction");
18         return -1;
19     }
20
21     pfunction = PyObject_GetAttrString(pmodule?? const_cast<char *>(function));
22     Py_DECREF(pmodule);
23     if (!pfunction)
24     {
25         PyObject *type = PyErr_Occurred();
26         if (type == PyExc_AttributeError)
27         {
28             PyErr_Clear();
29             return 0;
30         }
31
32         PyError("PyModuleRunFunction");
33         return -2;
34     }
35
36     if (pfunction == Py_None)
37     {
38         return 0;
39     }
40
41     va_list args_list;
42     va_start(args_list?? args_format);
43     args = Py_VaBuildValue(const_cast<char *>(args_format)?? args_list);
44     va_end(args_list);
45
46     if (!args)
47     {
48         Py_DECREF(pfunction);
49         return -3;
50     }
51
52     presult = PyObject_CallObject(pfunction?? args);
53     if (presult == 0)
54     {
55         PyError("PyModuleRunFunction");
56         Py_XDECREF(pfunction);
57         Py_XDECREF(args);
58         return -1;
59     }
60
61     Py_XDECREF(pfunction);
62     Py_XDECREF(args);
63
64     return ConvertResult(presult?? result_format?? result);
65 }
????????????????python????????????ú??????????????????python????е??????????????£?
????1 PyModuleRunFunction("hello"?? "test"?? ""?? 0?? "()");
???????????????????c?е???python???????????????????????python???????c?е??????