/** * \file pyVlibrasUpdate.cpp * \authors Ezequiel Silva * \date outubro 2015 */ #include "pyVlibrasUpdate.h" void PyVlibrasUpdate::checkExe(char* strFunct, char* strstrParams) { STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInfo; char Args[4096]; char *pEnvCMD = NULL; char *pDefaultCMD = "CMD.EXE"; ULONG rc; memset(&StartupInfo, 0, sizeof(StartupInfo)); StartupInfo.cb = sizeof(STARTUPINFO); StartupInfo.dwFlags = STARTF_USESHOWWINDOW; StartupInfo.wShowWindow = SW_HIDE; Args[0] = 0; pEnvCMD = getenv("COMSPEC"); if(pEnvCMD){ strcpy(Args, pEnvCMD); } else{ strcpy(Args, pDefaultCMD); } // "/c" option - Do the command then terminate the command window strcat(Args, " /c "); //the application you would like to run from the command window strcat(Args, strFunct); strcat(Args, " "); //the parameters passed to the application being run from the command window. strcat(Args, strstrParams); if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) { return -1; } WaitForSingleObject(ProcessInfo.hProcess, INFINITE); if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) rc = 0; CloseHandle(ProcessInfo.hThread); CloseHandle(ProcessInfo.hProcess); } int PyVlibrasUpdate::install(char* strFunct, char* strstrParams) { STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInfo; char Args[4096]; char *pEnvCMD = NULL; char *pDefaultCMD = "CMD.EXE"; memset(&StartupInfo, 0, sizeof(StartupInfo)); StartupInfo.cb = sizeof(STARTUPINFO); StartupInfo.dwFlags = STARTF_USESHOWWINDOW; StartupInfo.wShowWindow = SW_HIDE; Args[0] = 0; pEnvCMD = getenv("COMSPEC"); if(pEnvCMD){ strcpy(Args, pEnvCMD); } else{ strcpy(Args, pDefaultCMD); } // "/c" option - Do the command then terminate the command window strcat(Args, " /c "); //the application you would like to run from the command window strcat(Args, strFunct); strcat(Args, " "); //the parameters passed to the application being run from the command window. strcat(Args, strstrParams); if (!CreateProcess( NULL, Args, NULL, NULL, FALSE,CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) { return -1; } return -1; }