I am currently working on a program that runs a program specified by the user. passed as the wstring entered by the user. My question is how to get it to throw an exception or check if "passIn" is vaild. Currently, if the user logs into "notepad.exe", he starts it correctly, but if they enter something fake, such as "asdf" or something in this direction, he still creates a process.
try {
wchar_t* commandLine = new wchar_t [CP_MAX_COMMANDLINE];
wcsncpy_s(commandLine, CP_MAX_COMMANDLINE, passedIn.c_str(), passedIn.size() +1);
CreateProcess(NULL,
commandLine,
NULL, NULL,
false,CREATE_NEW_CONSOLE,NULL,
NULL,
&sinfo,
&pi);
delete [] commandLine;
}
catch (int e) {
cout << "An exception occurred. Exception Nr. " << e << endl;
}
I hoped that my capture would seize him, but that is not so. Is there anything I can do to check if it is vaild?
Thank!
source
share