|
| HOMEPAGE | INDICE FORUM | REGOLAMENTO | ::. | NEI PREFERITI | .:: | RSS Forum | RSS News | NEWS web | NEWS software | |
| PUBBLICITA' | | | ARTICOLI | WIN XP | VISTA | WIN 7 | REGISTRI | SOFTWARE | MANUALI | RECENSIONI | LINUX | HUMOR | HARDWARE | DOWNLOAD | | | CERCA nel FORUM » | |
06-06-2006, 23.42.23 | #1 |
Young Promise
Registrato: 04-02-2006
Messaggi: 2.114
|
[C/C++] Eseguire un file
C'è un modo per lanciare un programma "esterno" da un programma in C o C++ in modo da poter creare una specie di batch in C? |
07-06-2006, 01.01.03 | #2 |
Senior Member
Registrato: 20-01-2006
Messaggi: 334
|
Devi usare una API di windows "CreateProcess", ecco un esempio:
Codice:
#include <windows.h> #include <stdio.h> void main( VOID ) { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess( NULL, // No module name (use command line). "\"C:\\Program Files\\MyApp.exe\" -L -S", // 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. ) { printf( "CreateProcess failed (%d).\n", GetLastError() ); return; } // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); } |
07-06-2006, 08.58.15 | #3 | |
Guest
Messaggi: n/a
|
Re: [C/C++] Eseguire un file
Quota:
#include <stdlib.h> void main(){ System("Percorso file da eseguire"); } System invoca il percorso scelto...stai attento che se ha delle "\", le devi raddoppiare perché il compilatore potrebbe interpretarli come caratteri speciali |
|
07-06-2006, 15.36.03 | #4 |
Young Promise
Registrato: 04-02-2006
Messaggi: 2.114
|
(Y) grazie... credo che sceglierò la seconda soluzione, mi sembra più semplice ciao!!!
|
Utenti attualmente attivi che stanno leggendo questa discussione: 1 (0 utenti e 1 ospiti) | |
Strumenti discussione | |
|
|
Discussioni simili | ||||
Discussione | Autore discussione | Forum | Risposte | Ultimo messaggio |
File batch per eseguire backup? | _mikcio_ | Windows 7/Vista/XP/ 2003 | 2 | 15-01-2008 16.02.07 |
Windows security alert | imothep | Sicurezza&Privacy | 19 | 07-10-2007 14.58.43 |
[Win XP] Eseguire file batch al riavvio, si può? | mantes | Windows 7/Vista/XP/ 2003 | 7 | 25-08-2005 10.51.43 |
Imaging e Win Xp | Cico2000 | Windows 7/Vista/XP/ 2003 | 6 | 15-04-2005 19.01.01 |
problema con file .doc rovinato in office xp 2003...poi risolto... | cippico | Office suite | 0 | 30-04-2004 09.12.07 |