- 原因:
- 我需要把项目解决方案目录下的pdb文件ilk文件删掉,来保证修改项目的依赖顺序后,能够正确地编译工程。
- 而每次都手动到文件夹下去删除太烦了,所以想到了VS2008的外部工具的添加,这样只要把这个命令放到工具栏上,点击一下就可以删除这些文件了。
- 但是我在Windows目录下又没有找到del命令的文件,直接用cmd又不知道怎么写。
- 于是就想到了system()函数。既然手上有锤子,所以……
- 代码:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main(int argc, char ** argv)
{
std::string strCommand;
for (int i = 1; i < argc; ++i)
{
strCommand += std::string(argv[i], strlen(argv[i]));
strCommand += " ";
}
if (!strCommand.empty())
{
system(strCommand.c_str());
}
else
{
cout << "Usage: CommandTools command [options]\n\texample: CommandTools del *.*\n" << endl;
}
return 0;
}