今天看到一篇博文,说如何把VC2005工程转VC2003
其实用手工完成也很简单。文章最后将给出方法。先把博文转载如下。
今天在老外的网站上找到一个小工具 testConvert.exe, 能把VC2005的工程转换为VC2003,实在是爽,而且还给了源码。。哈哈 http://dl2.csdn.net/down4/20070718/18143940621.zip
举个例子
D:/dx9/ 目录下 有 xxx.vcproj,是VC2005生成的
进入cmd控制台,
testConvert d:/dx9/***.vcproj
ok,就行了。
// code
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
#include
"
stdafx.h
"
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
#include
<
atlrx.h
>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
#include
<
string
>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
using
namespace
std;
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
int
_tmain(
int
argc, _TCHAR
*
argv[])
{
if(2 != argc){
cout << " usage : theExe <file>" << endl;
return -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//read file to memory
string strProject = argv[1];
FILE* fp = NULL;
if(NULL == (fp = fopen(strProject.c_str(), "r"))){
cout << " cannot find the project" << endl;
return -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
string strText;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
while(!feof(fp)){
strText += fgetc(fp);
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
fclose(fp);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//replace it
CAtlRegExp<> oRegExp;
oRegExp.Parse("Version="[7-9].[0-9]0"");
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
CAtlREMatchContext<> oMatchContext;
if (!oRegExp.Match(strText.c_str(), &oMatchContext))
{
cout << " invalidate format" << endl;
return -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
string strNewText = strText.substr(0, strText.size() - lstrlen(oMatchContext.m_Match.szStart)) + "Version="7.00"" +
strText.substr(strText.size() - lstrlen(oMatchContext.m_Match.szEnd), -1);
//backup
string strBackProject = strProject + "_old";
CopyFile(strProject.c_str(), strBackProject.c_str(),FALSE);
//dump it to disk
if(NULL == (fp = fopen(strProject.c_str(), "r+"))){
cout << " cannot find the project" << endl;
return -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
fwrite(strNewText.c_str(),1,strNewText.size() - 1, fp);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
fclose(fp);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
return 0;
}
我经常使用的手工转换方法。
其实只要修改两个文件就可以了。
1是.sln,记事本打开项目的sln文件,修改Format Version 9.00 为 Format Version 8.00
然后是.vcproj文件,修改Version="8.00"为Version="7.10"
这样就可以用VC2003打开VC2005的工程项目了。