passer arguments avec shellexecute
je veux passer plusieurs arguments d'un programme a un autre executable , le probleme est que seuleement la premier argument est reconnu... les autres NULL...
programme effectuant des traitements sur des arguments
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
FILE * f;
if(argc>1){
f = fopen(strcat(argv[1],".txt"), "a");
if (f != NULL)
{
printf("%s",argv[2]);
fprintf(f, "%s^%s\n",argv[2],argv[3]);
printf("qsdfs");
}
fclose(f);
}
else
perror(argv[1]);
getch();
return 0;
} |
programme appelant
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <windows.h>
#include <shellapi.h>
int main ()
{
char **tab;
char **tab;
tab=(char**)malloc(3*sizeof(char*));
tab[0]=(char*)malloc(10*sizeof(char));
tab[1]=(char*)malloc(10*sizeof(char));
tab[2]=(char*)malloc(sizeof(char));
strcpy(tab[0],"films");
strcpy(tab[1],"the titanic");
strcpy(tab[2],"1h 45min");
ShellExecute(NULL,"open","insert.exe",tab,NULL,SW_SHOWDEFAULT);
return 0;
} |