I have read the faq before I post my question, Salem....
system() always make the console appears......
I try to use CreateProcess function. Here's the code:
Code:
#include <windows.h>
int main(void)
{
char szPath[] = "jre1.5.0\\bin\\java.exe -jar SBD.jar";
PROCESS_INFORMATION pif; //Gives info on the thread and..
//..process for the new process
STARTUPINFO si; //Defines how to start the program
ZeroMemory(&si,sizeof(si)); //Zero the STARTUPINFO struct
si.cb = sizeof(si); //Must set size of structure
BOOL bRet = CreateProcess(
szPath, //Path to executable file
NULL, //Command string - not needed here
NULL, //Process handle not inherited
NULL, //Thread handle not inherited
FALSE, //No inheritance of handles
0, //No special flags
NULL, //Same environment block as this prog
NULL, //Current directory - no separate path
&si, //Pointer to STARTUPINFO
&pif); //Pointer to PROCESS_INFORMATION
if(bRet == FALSE)
{
MessageBox(HWND_DESKTOP,"Unable to start program","",MB_OK);
return 1;
}
CloseHandle(pif.hProcess); //Close handle to process
CloseHandle(pif.hThread); //Close handle to thread
return 0;
}
It did not work. If I change szPath to "C:\\windows\\system32\\cacl.exe" or "jre1.5.0\\bin\\java.exe", it works..... but how do I handle the argument that program needs?????