I am trying to write a very simple program to replace an existing executable. He should slightly reject his arguments and execute the original program with new arguments. It should be automatically and quietly launched by a third-party library.
It works fine, but a console window appears to display the output of the called program. I need the console window not to be. I do not care about the program exit.
My initial attempt was configured as a console application, so I decided to fix it by writing a new Windows GUI application that did the same. But it still pops up on the console. I assume that the original command is marked as a console application, and therefore Windows automatically provides it with a console window to run. I also tried replacing my initial call to _exec () with a call to system (), just in case. No help.
Does anyone know how I can remove this console window?
Here is my code:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
char* lpCmdLine,
int nCmdShow)
{
char *argString, *executable;
std::vector< std::string > newArgs;
char const ** newArgsP = new char const*[newArgs.size() + 1];
for (unsigned int i = 0; i < newArgs.size(); ++i)
{
newArgsP[i] = newArgs[i].c_str();
}
newArgsP[newArgs.size()] = NULL;
int rv = _execv(executable, newArgsP);
if (rv)
{
return -1;
}
}
source
share