// python.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include static int numargs=0; /* Return the number of arguments of the application command line */ static PyObject* emb_numargs(PyObject *self, PyObject *args) { if(!PyArg_ParseTuple(args, ":numargs")) return NULL; return Py_BuildValue("i", numargs); } static PyMethodDef EmbMethods[] = { {"numargs", emb_numargs, METH_VARARGS, "Return the number of arguments received by the process."}, {NULL, NULL, 0, NULL} }; static PyModuleDef EmbModule = { PyModuleDef_HEAD_INIT, "emb", NULL, -1, EmbMethods, NULL, NULL, NULL, NULL }; int _tmain(int argc, _TCHAR* argv[]) { Py_Initialize(); numargs = argc; PyModule_Create(&EmbModule); PyRun_SimpleString("import emb\nprint(\"Number of arguments\", emb.numargs())"); Py_Finalize(); return 0; }