#include <iostream>
#include <iostream>
#include <windows.h>
#include <fstream>
#include <direct.h>
#include <shlobj.h>
#include <sstream>
#include <tchar.h>
#include <cstdlib>
using namespace std;
int main ()
{
ofstream file;
TCHAR appData[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(NULL,
CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE,
NULL,
SHGFP_TYPE_CURRENT,
appData)))
wcout << appData << endl;
std::basic_ostringstream<TCHAR> file_path;
file_path << appData << _TEXT("\\截图.bat");
file.open(file_path.str().c_str());
file<<"start snippingtool\n";
file.close();
system("%USERPROFILE%\\Desktop\\截图.bat") ;
return 0;
}
它会在桌面上添加一个bat。
根据需要可更改。