highmarks
asked on
how to execute an .exe file(created in VC++) from C program
Hi!
I have created an .exe file using VC++6.0 with MFC Appwizard (size 560Kb)
Now I have tried executing taht exe from my c program using
execv("c:\test.exe",NULL) and also fork it gives me this error.
Debug Assertion failed expression argvector!=NULL
Can someone suggest me how to execute this.
Thanks.
I have created an .exe file using VC++6.0 with MFC Appwizard (size 560Kb)
Now I have tried executing taht exe from my c program using
execv("c:\test.exe",NULL) and also fork it gives me this error.
Debug Assertion failed expression argvector!=NULL
Can someone suggest me how to execute this.
Thanks.
ASKER
HI!
I have tried that too but does not work.
Actually I have written a code for systray icon when I double click that icon exe should run.
Now it's giving me error of c:\sample....invalid path??????
I have tried that too but does not work.
Actually I have written a code for systray icon when I double click that icon exe should run.
Now it's giving me error of c:\sample....invalid path??????
// You need more than one argument in last variable of execv,
// but last arguement needs to be null.
#include <stdio.h>
#include <process.h>
void main(){
char *args[3],pn[50];
args[0] = "whatever";
args[1] = "blah blah";
args[2] = NULL;
printf(" Enter executable's path: ");
gets(pn);
int x = execv(/*"c:\\temp\\name.ex e"*/pn,arg s) ;
printf("\n execv output error # %d\n\n ",x);
}
// If you want to do this in assembly got to:
// http://www.geocities.com/freehafer/pl2.html#EXEC
// but last arguement needs to be null.
#include <stdio.h>
#include <process.h>
void main(){
char *args[3],pn[50];
args[0] = "whatever";
args[1] = "blah blah";
args[2] = NULL;
printf(" Enter executable's path: ");
gets(pn);
int x = execv(/*"c:\\temp\\name.ex
printf("\n execv output error # %d\n\n ",x);
}
// If you want to do this in assembly got to:
// http://www.geocities.com/freehafer/pl2.html#EXEC
// IF YOU HAD TO EXECUTE THE FOLLOWING PROGRAM:
#include "stdio.h"//printf
#include "windows.h"//toupper BYTE
void main(int argc, char **argv)
{
printf("The character entered is: %c!",argv[1][0]);
printf("\nIts integral representation is: %i!",int((toupper(argv[1][ 0])-'A') +1));
printf("\nIts upper case character representation after conversion from byte is: %c!",'A' + BYTE((toupper(argv[1][0])- 'A') +1) - 1);
}
// YOU WOULD WRITE:
// name.exe a
// AT THE COMMAND LINE TO OUTPUT a 1 A
// BUT args[0] DOES NOT NECESSARILY HAVE TO
// BE THE PROGRAM NAME THOUGH IT USUALLY IS,
// YET args[1] HAS TO BE THE LOWER CASE a.
#include <stdio.h>
#include <process.h>
void main(){
char *args[3];
args[0] = "junk";//"c:\\temp\\x.exe" ;
args[1] = "a:";
args[2] = NULL;
printf(" Enter executable's path: ");
int x = execv("c:\\temp\\x.exe",ar gs) ;
printf("\n execv output error # %d\n\n ",x);
}
#include "stdio.h"//printf
#include "windows.h"//toupper BYTE
void main(int argc, char **argv)
{
printf("The character entered is: %c!",argv[1][0]);
printf("\nIts integral representation is: %i!",int((toupper(argv[1][
printf("\nIts upper case character representation after conversion from byte is: %c!",'A' + BYTE((toupper(argv[1][0])-
}
// YOU WOULD WRITE:
// name.exe a
// AT THE COMMAND LINE TO OUTPUT a 1 A
// BUT args[0] DOES NOT NECESSARILY HAVE TO
// BE THE PROGRAM NAME THOUGH IT USUALLY IS,
// YET args[1] HAS TO BE THE LOWER CASE a.
#include <stdio.h>
#include <process.h>
void main(){
char *args[3];
args[0] = "junk";//"c:\\temp\\x.exe"
args[1] = "a:";
args[2] = NULL;
printf(" Enter executable's path: ");
int x = execv("c:\\temp\\x.exe",ar
printf("\n execv output error # %d\n\n ",x);
}
ASKER
Hi! All
I have got the answer regarding it is
WinExec(.....)
I have got the answer regarding it is
WinExec(.....)
Thank you for your thoughtful evaluation of my answer.
Hi highmarks!!!!
hope u got the answer
Evaluate this answers or delete these questions please
hope u got the answer
Evaluate this answers or delete these questions please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
to execv("c:\\test.exe",NULL)