123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #ifndef __PYTHON_HELPER__
- #define __PYTHON_HELPER__
- #pragma once
- #define THREAD_SIZE 100
- // 工作参数,用于工作者线程;
- typedef struct __WORK_PARAMTER__
- {
- HANDLE hThread; // 事件句柄;
- HANDLE hEvent; // 线程事件;
- BOOL bStatus; // 线程状态;
- TCHAR szScriptPath[MAX_PATH]; // 脚本路径;
- TCHAR szLogPath[MAX_PATH]; // 日志路径;
- // 重定向标准输出和标准错误;
- HANDLE hStdOutRead;
- HANDLE hStdOutWrite;
- HANDLE hStdErroWrite;
- }WorkParamter, *pWorkParamter;
- class CPythonHelper
- {
- public:
- CPythonHelper(void);
- ~CPythonHelper(void);
- public:
- // 添加脚本;
- // strScript: 脚本路径;
- // strLogPath: 日志路径;
- // nRunType: 运行方式, 0=嵌入C++ 1=子进程运行;
- bool AddPythonScript(std::string strScript, std::string strLogPath, int nRunType = 0);
- // 停止脚本运行;
- void StopScript();
- protected:
- // 工作者线程函数;
- static DWORD WINAPI _WorkerThread(LPVOID lpParam);
- };
- #endif //__PYTHON_HELPER__
|