Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: ganondolf en 1 Octubre 2014, 01:32 am



Título: Almacenar valor retornado en python en c++
Publicado por: ganondolf en 1 Octubre 2014, 01:32 am
Quiero ver la posibilidad de saber si es que se puede almacenar en una variable en c++ un valor retornado en python

codigo actual c++
Código:
int main(int argc, char *argv[]){
        
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "C:\\Users\\asd\\Desktop\\proyecto1\\python\\main.py";        
ShExecInfo.lpParameters = "";  
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);

WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
} [code]
[/code]


Título: Re: Almacenar valor retornado en python en c++
Publicado por: MeCraniDOS en 1 Octubre 2014, 18:58 pm
Un metodo un poco chapuzas es guardar con python el resultado en un fichero, y leerlo desde C  :rolleyes:

Sino puedes leer sobre como incrustrar Python en C, y utilizar la funcion en python llamandola desde C

https://docs.python.org/2/c-api/ (https://docs.python.org/2/c-api/)

Saludos