[VC++ / MFC]
void ExecuteExternalFile(const char* csExecuteCommand)
{
STARTUPINFO sInfo;}
ZeroMemory(&sInfo,sizeof(sInfo));
sInfo.cb = sizeof(sInfo);
PROCESS_INFORMATION pInfo;
ZeroMemory(&pInfo,sizeof(pInfo));
sInfo.cb = sizeof(sInfo);
//Create the process here.
CreateProcess(0, //LPCWSTR lpszImageName,(char*)csExecuteCommand, //LPCWSTR lpszCmdLine,);
0, //LPSECURITY_ATTRIBUTES lpsaProcess,
0, //LPSECURITY_ATTRIBUTES lpsaThread,
TRUE, //BOOL fInheritHandles,
NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, //DWORD fdwCreate,
0, //LPVOID lpvEnvironment,
0, //LPWSTR lpszCurDir,
&sInfo,//LPSTARTUPINFOW lpsiStartInfo,
&pInfo//LPPROCESS_INFORMATION lppiProcInfo
// Wait until child processes exit.
WaitForSingleObject( pInfo.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pInfo.hProcess );
CloseHandle( pInfo.hThread );
[C#.NET]
private static bool GetVieKeywords(string csExecuteFile, string csExecuteParam)
{
try
{Process proc = new Process();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;proc.StartInfo.FileName = csExecuteFile;
proc.StartInfo.Arguments = csExecuteParam;
proc.Start();
proc.WaitForExit();
proc = null;}
catch (Exception)
{//Extract fail.
return false;}
return true;
}
No comments:
Post a Comment