c语言如何打开一个可执行文件 命令

来源:百度知道 编辑:UC知道 时间:2024/07/06 17:30:02

如果是VC用API:WinExec,ShellExecute,CreateProcess,CreateProcessAs
如果是TC,或者其它C,C++,用system

都可以实现

在dos下用system(c:\文件路径)就可以
在 Windows 下用
winexec
createprocess
fopen("xxx.exe","b")也可以吧,这个没试过。

system("c:\\test.exe");

DOS系统中直接输入文件路径
windows中
1.进入tubor.c
2.程序如下:
main()
{
FILE *fp;
char filename[40];
printf("Plese input the file add:");/*在这里输入文件路径,如:c;\system32*/
if((fp=fopen(filename),"rb")==NULL)
printf("Error!Can't find the file!");/*在着两句语句中,首先,一二进制只读的方式打开路径为filename的文件,在判断它是否为空(就是该文件不存在),如果不存在则输出Error!Can't find the file!*/
}

我在把无注释的程序贴上
main()
{
FILE *fp;
char filename[40];
printf("Plese input the file add:");
if((fp=fopen(filename),"rb")==NULL)
printf("Error!Can't find the file!");
}
满意不 呵