martin11_ar
asked on
system function on windows NT
Can I use the system function in a GUI program on Windows NT ?
I´m trying but it doesn´t work well. It doesn´t call the program that i´m invoking.How ever it return NO ERROR in errno variable.
I´m trying but it doesn´t work well. It doesn´t call the program that i´m invoking.How ever it return NO ERROR in errno variable.
BTW, *how*are you trying to use 'system()'?
ASKER
I´m invoking the gcc compiler and other command line programs.
And i´m trying to call a bat file too , but anything works well.
And i´m trying to call a bat file too , but anything works well.
Hmm, try the above function.
ASKER
it call the compiler but don´t find the file that i pass as first parameter.
>>but don´t find the file that i pass as first parameter
It seems that you are not correctly specifying the file or are working in a different directory? Where is your application located and where are the files you want to compile?
It seems that you are not correctly specifying the file or are working in a different directory? Where is your application located and where are the files you want to compile?
ASKER
I´m indicating the complete path for the gcc , and i tried with the complete path and only the file name for the file to compile but don´t work.The gcc and the c file are in the same directory, but it´s different that the application directory.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much.
Excellent solution!!!
Excellent solution!!!
Yes, sure - I would not recommentd that, however. Better use sth. like
DWORD ExecuteAndWaitForCompletio
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
BOOL bRes;
DWORD dwCode = 0;
MSG msg;
ZeroMemory ( &si, sizeof ( STARTUPINFO));
si.cb = sizeof ( STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
bRes = CreateProcess ( NULL,
pszCmd,
NULL,
NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi
);
while ( WAIT_OBJECT_0 != MsgWaitForMultipleObjects ( 1,
&pi.hProcess,
FALSE,
s INFINITE,
QS_ALLINPUT
)
)
{
while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE))
{
DispatchMessage ( &msg);
}
}
GetExitCodeProcess ( pi.hProcess, &dwCode);
CloseHandle ( pi.hProcess);
CloseHandle ( pi.hThread);
return ( dwCode);
}