我对调用文件函数的评价:
除了写游戏时用到,其他的时候没屁用
肥肠不戳,大家试试。
前言:
上次投票,有9人投了<C++调用文件函数>,那我说道做到,就写一篇C++调用文件函数的博文
正文:
调用文件函数代码:ShellExecuteA(0, "open", "文件位置", 0, 0, 3);
函数需要加的头文件:#include<windows.h>
ShellExecuteA里的参数代表什么?
第一个参数:系统启动
第二个参数:open(中文:打开)打开
第三个参数:文件位置
第四个参数:默认0
第五个参数:默认0
第六个参数:0 隐藏 3 最小化 6 最大化 其他 正常
例子:
ShellExecuteA调用文件例子
1.
#include <bits/stdc++.h>
#include <windows.h> //ShellExecuteA需要的头文件
using namespace std;
int main(){
ShellExecuteA(0, "open", "D:\\a.txt", 0, 0, 3);
//以最小化模式打开D盘的a.txt文件。
return 0;
}
2.
#include <bits/stdc++.h>
#include <windows.h> //ShellExecuteA需要的头文件
using namespace std;
int main(){
ShellExecuteA(0, "open", "D:\\yuhaoteng666\\a.cpp", 0, 0, 6);
//以最大化模式打开位置为D:\yuhaoteng666的a.cpp文件。
return 0;
}
3.
#include <bits/stdc++.h>
#include <windows.h> //ShellExecuteA需要的头文件
using namespace std;
int main(){
ShellExecuteA(0, "open", "D:\\yuhaoteng666\\C++\\123.exe", 0, 0, 0);
//打开位置为D:\yuhaoteng666\C++的123.exe文件,并隐藏。
return 0;
}
ShellExecuteA函数的作用可不止调用文件哦!
例子:
1.
#include <bits/stdc++.h>
#include <windows.h> //ShellExecuteA需要的头文件
using namespace std;
int main(){
ShellExecuteA(0, "open", "www.baidu.com", 0, 0, 6);
//使用默认浏览器打开www.baidu.com(百度)网址,并最大化。
return 0;
}
2.
#include <bits/stdc++.h>
#include <windows.h> //ShellExecuteA需要的头文件
using namespace std;
int main(){
ShellExecuteA(0, "open", "blog.csdn.net", 0, 0, 6);
//使用默认浏览器打开blog.csdn.net(CSDN)网址,并最大化。
return 0;
}
3.
#include <bits/stdc++.h>
#include <windows.h> //ShellExecuteA需要的头文件
using namespace std;
int main(){
ShellExecuteA(0, "open", "notepad", 0, 0, 6);
//以最大化模式打开记事本(空白的)。
return 0;
}