Change the content of the file
2012-08-17 16:20
477 查看
LOG_INFO(L"更改RC版本信息..."); CopyRCtoTxt(); CoutAndReturnRC(0); int j=i; for(int k=0;k<j;k++) {i=0; string p=CoutAndReturnRC(k); LPWSTR sourcefile = new WCHAR[MAX_PATH]; LPWSTR objfile = new WCHAR[MAX_PATH]; ZeroMemory(sourcefile,MAX_PATH); /////////// 对申请空间清除 ZeroMemory(objfile,MAX_PATH); _TCHAR*arg1=L"Info.txt"; // _TCHAR* arg2=p; wcscat( sourcefile, arg1); //wcscat( objfile, arg2); CString ABC; ABC+=p.c_str(); CString wsSourceNum; CString wsSourceName; CString wsSourcecompanyname; CString wsStr; CStdioFileEx fileSource,fileDes,fileTemp; if (!fileSource.Open(sourcefile,CFile::modeRead)) { printf("%s","Open SourceFile is failed !"); LOG_ERROR(L"Open SourceFile is failed !"); return 1; } //LOG_INFO(L"开始读取资源信息"); while(fileSource.ReadString(wsStr)) { wsSourcecompanyname=wsStr; LOG_INFO(L"成功读取资源信息为:wsSourcecompanyname=%s",wsSourcecompanyname); break; } string tp= RenewInfo(); wsSourceNum = tp.c_str(); wsSourceName = tp.c_str(); fileSource.Flush(); fileSource.Close(); if (!fileDes.Open(ABC,CFile::modeReadWrite|CFile::typeText)) { printf("%s","Open DesFile is error!"); LOG_ERROR(L"Open DesFile is failed !"); return 1; } //CString DesNum; CString DesStr; CString DesFILEVERSION; CString DesFileVersion; CString DesPathName; CString DesPRODUCTVERSION; CString DesProductName; CString DesLegalCopyright; CString DesFileDescription; CString DesProductVersion; CString DesComlist0,DesComlist1,DesComlist2,DesComlist3; DesPathName = ABC; DesPathName+=".rc"; if (!fileTemp.Open(DesPathName,CFile::modeCreate|CFile::modeWrite)) { printf("%s","Creat New DesFile is Error"); LOG_ERROR(L"Creat New DesFile is failed !"); return 1; } while (fileDes.ReadString(DesStr)) { DesFILEVERSION = DesStr.Mid(0,13);//FILEVERSION,文件版本 DesFileVersion = DesStr.Mid(0,33);//VALUE "FileVersion",文件版本 DesPRODUCTVERSION = DesStr.Mid(0,16);//PRODUCTVERSION ,产品版本 DesProductVersion = DesStr.Mid(0,36);//VALUE "ProductVersion", 产品版本 DesProductName = DesStr.Mid(0,33);//VALUE "ProductName", 产品名称,<产品名> DesLegalCopyright = DesStr.Mid(0,36);//VALUE "LegalCopyright", 版权,<公司名称> //DesFileDescription= DesStr.Mid(0,37);//VALUE "FileDescription", 文件描述 DesComlist0 = " "; DesComlist0+="VALUE "; DesComlist0+='"'; DesComlist0+="ProductName"; DesComlist0+='"'; DesComlist0+=", "; DesComlist1 = " "; DesComlist1+="VALUE "; DesComlist1+='"'; DesComlist1+="ProductVersion"; DesComlist1+='"'; DesComlist1+=", "; DesComlist2 = " "; DesComlist2+="VALUE "; DesComlist2+='"'; DesComlist2+="FileVersion"; DesComlist2+='"'; DesComlist2+=", "; DesComlist3 = " "; DesComlist3+="VALUE "; DesComlist3+='"'; DesComlist3+="LegalCopyright"; DesComlist3+='"'; DesComlist3+=", "; if (DesFILEVERSION==L" FILEVERSION " ) { DesFILEVERSION+=wsSourceNum; DesFILEVERSION+="\r\n"; fileTemp.WriteString(DesFILEVERSION); LOG_INFO(L"查找到替换字符串:FILEVERSION,替换成功"); }else if (DesPRODUCTVERSION==" PRODUCTVERSION ") { DesPRODUCTVERSION+=wsSourceName; DesPRODUCTVERSION+="\r\n"; fileTemp.WriteString(DesPRODUCTVERSION); LOG_INFO(L"查找到替换字符串:PRODUCTVERSION,替换成功"); }else if (DesProductName==DesComlist0) { DesProductName+='"'; DesProductName+="<"; DesProductName+=wsSourcecompanyname; DesProductName+=">"; DesProductName+='"'; DesProductName+="\r\n"; fileTemp.WriteString(DesProductName); LOG_INFO(L"查找到替换字符串:ProductName,产品名称替换成功"); }else if (DesProductVersion==DesComlist1) { DesProductVersion+='"'; DesProductVersion+=wsSourceName; DesProductVersion+='"'; DesProductVersion+="\r\n"; fileTemp.WriteString(DesProductVersion); LOG_INFO(L"查找到替换字符串:DesProductVersion,产品版本替换成功"); }else if (DesFileVersion==DesComlist2) { DesFileVersion+='"'; DesFileVersion+=wsSourceNum; DesFileVersion+='"'; DesFileVersion+="\r\n"; fileTemp.WriteString(DesFileVersion); LOG_INFO(L"查找到替换字符串:FileVersion,替换成功"); }else if (DesLegalCopyright==DesComlist3) { DesLegalCopyright+='"'; DesLegalCopyright+="(C) <"; DesLegalCopyright+=wsSourcecompanyname; DesLegalCopyright+=">。保留所有权利。"; DesLegalCopyright+='"'; DesLegalCopyright+="\r\n"; fileTemp.WriteString(DesLegalCopyright); LOG_INFO(L"查找到替换字符串:LegalCopyright,版权替换成功"); }else { DesStr+="\r\n"; fileTemp.WriteString(DesStr); //LOG_INFO(L"没有查找到需要替换字符串"); } } fileDes.Flush(); fileDes.Close(); DeleteFile(ABC); fileTemp.Flush(); fileTemp.Close(); CFile::Rename(DesPathName,ABC);} wcout<<"版本RC修改成功..."<<endl; LOG_INFO(L"***********更改RC版本信息成功*****************"); //return 1;
相关文章推荐
- copy the content of a file to another file.
- PHPStorm解决Failed to change timestamp of the file
- javascript: change the content of table
- 如何窥探PDB的秘密?(How to Inspect the Content of a Program Database (PDB) File)
- android学习笔记:AndroidRuntime: java.lang.IllegalStateException: The content of the adapter has change
- PhpStorm日志报错:Failed to change timestamp of the file 'your.php'
- A script to change the background of pdf file!
- PHPStorm解决Failed to change timestamp of the file
- Linux,clear the content of linux file
- XML文件要有根标签(Extra content at the end of the document in file 错误)
- an out of memory error has occurred.Consult the 'running eclipse' section of the read me file for...
- 【Android】【ListView】The content of the adapter has changed
- resource is out of sync with the file system 解决方法
- struts2---The content of element type "package" must match "(result-types?,interceptors?,default-int
- 关于Listview中The content of the adapter has changed but ListView did not receive a notification......的
- WPF程序设计 :第三章 内容的概念(The Concept of Content)
- This page contains the following errors: error on line 1 at column 1: Extra content at the end of t
- 如何调整Dreamhost主机PHP上传尺寸的限制/How to change the maximal size of uploading in your Dreamhost
- 解决eclipse中出现Resource is out of sync with the file system问题
- [每日一题] 11gOCP 1z0-053 :2013-10-6 significance of the CHANGE FAILURE ..................25