Newsgroup: it.comp.lang.c++
Titolo: Lanciare altre applicazioni dalla propria in BCB: come si fa?

Ciao a tutti :)
Sto cercando un modo per "convincere" il programmino che sto scrivendo
a lanciare un'altro eseguibile... :->
Ho provato con la famiglia "exec..." ma c'è un inconveniente: Windows
termina prima il mio programma e poi lancia l'eseguibile richiesto.
Come posso fare a lanciare (dal mio programma) un qualsiasi eseguibile
senza terminare la mia applicazione?
Tnx a lot a chi vorrà rispondermi :)
Vale			Francesco

 a lanciare un'altro eseguibile... :->
Prova con funzioni API come WinExec() e compagnia.
EMG



Meglio decisamente la compagnia :-). WinExec() e' obsoleto e dovrebbe
essere evitato nei programmi a 32 bit. Meglio CreateProcess(), ideale
ShellExecute().
Davide Marcato.
----------------------------------------------------
| -- Freelance International Consultant
| -- Win32/MFC/COM Development & Training
| -- Technical Writer & Speaker
----------------------------------------------------
| -- Email: 
mar...@programmers.net
| -- Web: 
http://www.DavideMarcato.com
----------------------------------------------------

Ciao a tutti :)


Vale Francesco
/**************Creating Processes*********************
The CreateProcess function creates a new process,
which runs independently of the creating process.
However, for simplicity, the relationship is referred
to as a parent-child relationship.
The following code fragment demonstrates how to create a process.
If CreateProcess succeeds, it returns a PROCESS_INFORMATION
structure containing handles and identifiers for the new process
and its primary thread. The thread and process handles are created
with full access rights, although access can be restricted if you
specify security descriptors.
When you no longer need these handles, close them by using the
CloseHandle function.
You can also create a process using the CreateProcessAsUser function.
This function allows you to specify the security context of the user
account in which the process will execute.
******************************************************/
#include <windows.h>
void ExecCmd()
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    // Start the child process.
    if( !CreateProcess( NULL, // No module name (use command line).
        "NOTEPAD.EXE", // Command line.
        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 )             // Pointer to PROCESS_INFORMATION structure.
    )
    {
        //CreateProcess failed.
    }
    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );
    // Close process and thread handles.
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
}

 ShellExecute().
Purtroppo io conosco, e neanche troppo approfonditamente, solo la
piattaforma WIN16. Comunque ShellExecute() c'è anche su WIN16
(CreateProcess() no...).
EMG