I want to run Unhidden.exe in drive N: and send char to that program. I use function like this
Code:
system("N:/Unhidden.exe");
it can open Unhidden.exe but it run in visual studio 2010\Projects\ . I try to use command N: and Unhidden.exe in cmd it can run in drive N: . So I try to use function like this
system("N:");
system("Unhidden.exe");
but it not found Unhidden.exe . How to use 2 command in sytem() function ?
How to use CreateProcess . I read example and try to use the function like this
Code:
DWORD WINAPI hidden_file(LPVOID lp)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
LPTSTR szCmdline1 = _tcsdup(TEXT("N:/Unhidden.exe"));
CreateProcess(NULL, szCmdline1,
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi );
return 0;
}
Why do you use _tcsdup?
You don't need to duplicate this string.
But if you do want to call _tcsdup then you must somewhere call
Code:
free(szCmdline1);
to avoid memory leaks!
Second: you don't check the return value of CreateProcess. Thus you don't know whether it failed or succeeded. And if it failed then all your other attempts to work with the Unhidden.exe do not make any sense!
Originally Posted by mmc01
but when I send key Y with this code it run in visual studio 2010\Projects\
Bookmarks