现在的位置: 首页 > 综合 > 正文

7月2-6号-rc文件的解析

2013年10月05日 ⁄ 综合 ⁄ 共 6748字 ⁄ 字号 评论关闭

#include<iostream.h>
#include<afx.h>
#include<string.h>
#include<stdlib.h>
#include<fstream.h>
#include"TORC.h"

void createrc(LPSTR rcifile,LPSTR savefile,CString& strrc);
int SetVersion(LPSTR prci,LPCTSTR prc,WORD wLocale) ; // #001
 

void main()
{
    LCID  lLocale;
 WORD  wLocale;
 CString r;
    char  str[30]="e:\\Sample\\Sample33_EXE.rci";

    char  output[10]="d:\\1";
 

   createrc((LPSTR)str,(LPSTR)output,r);

    cout<<"r:"<<r<<endl;
   
    lLocale = GetThreadLocale();       // #001
 wLocale = LANGIDFROMLCID(lLocale);
 cout<<wLocale<<endl;

   SetVersion((LPSTR)str,(LPCTSTR)r,wLocale);

}

void createrc(LPSTR rcifile,LPSTR savefile,CString& strrc)
{
    char  drive[20]="";
    char  dir[30]="";
    char  fname[10]="";
    char  ext[5]="";
    char  a[50]="";
    char  b[50]="";
 cout<<"dnef:"<<rcifile<<endl;
 lstrcpy((LPSTR)a,(LPSTR)rcifile);
/// a[strlen(rcifile)+1]='\0';
 cout<<a<<endl;
 lstrcpy((LPSTR)b,(LPSTR)savefile);
     _splitpath(a, drive, dir,fname, ext);

 strncat(fname,".rc",strlen(".rc"));
    cout<<fname<<endl;
  strncat(b,"\\",2);

   strncat(b,fname,strlen(fname));
   fstream f;
   f.open(b,ios::out);
   strrc=(LPCTSTR)b;
  

}

int SetVersion(LPSTR prci,LPCTSTR prc,WORD wLocale)  // #001
{
 CString strInternalName;
 CString strBaseName;
 CString strWrite;
 CString strFile;
 CString strRci;
// CString str;
// char strInput[40]="";
   
 int nFMajor,nPMajor;
 int nFMinor,nPMinor;
 int nFRelease,nPRelease;

    CVISRci m_Rci;
 m_Rci.m_strRciFile=prci;
  
 cout<<prci<<endl;
   
 
    fstream pFile;
 pFile.open(prc,ios::out);
 // EXE僼傽僀儖偺応崌偼ICON傪掕媊偡傞
 
// if(strstr(prc,"EXE"))
// {
//  pFile.write(EXEICON,strlen(EXEICON));       // COB85EXE icon pro45.ico
//  pFile.write(RC_ENTER,strlen(RC_ENTER));
// }

 pFile.write(RC_VERINFO,strlen(RC_VERINFO));        // "1 VERSIONINFO\r\n"

 nFMajor = 1;
 nFMinor = 0;
 nFRelease = 0;
 nPMajor = 1;
 nPMinor = 0;
 nPRelease = 0;
 

  nFMajor = m_Rci.GetFileVersionMajor();
  nFMinor = m_Rci.GetFileVersionMinor();
  nFRelease = m_Rci.GetFileVersionRelease();

  nPMajor = m_Rci.GetProductVersionMajor();
  nPMinor = m_Rci.GetProductVersionMinor();
  nPRelease = m_Rci.GetProductVersionRelease();
 

 strWrite.Format(RC_FILEVERSION,nFMajor,nFMinor,nFRelease);
  pFile.write((LPCTSTR)strWrite,strlen(strWrite)); // "FILEVERSION %s"

 strWrite.Format(RC_PRODUCTVERSION,nPMajor,nPMinor,nPRelease);
  pFile.write((LPCTSTR)strWrite,strlen(strWrite)); // "PRODUCTVERSION %s"

  pFile.write(RC_FILEFLAGMASK,strlen(RC_FILEFLAGMASK));   // "FILEFLAGSMASK 0x3FL\r\n"
 //if(m_bDebug)
 //  pFile.write(RC_FILEFLAGS_DEBUG,strlen(RC_FILEFLAGS_DEBUG));  // "FILEFLAGS     0x1L\r\n"
// else
 //  pFile.write(RC_FILEFLAGS,strlen(RC_FILEFLAGS));  // "FILEFLAGS     0x0L\r\n"

  pFile.write(RC_FILEOS,strlen(RC_FILEOS));         // "FILEOS        0x4L\r\n"
  pFile.write(RC_FILETYPE,strlen(RC_FILETYPE));       // "FILETYPE      0x2L\r\n"
 pFile.write(RC_FILESUBTYPE,strlen(RC_FILESUBTYPE));    // "FILESUBTYPE   0x0L\r\n"

  pFile.write(RC_BEGIN,strlen(RC_BEGIN));
  pFile.write(RC_BLANK4,strlen(RC_BLANK4));
 pFile.write(RC_BLOCKSTRING,strlen(RC_BLOCKSTRING));
 pFile.write(RC_BLANK4,strlen(RC_BLANK4));
  pFile.write(RC_BEGIN,strlen(RC_BEGIN));

  pFile.write(RC_BLANK8,strlen(RC_BLANK8));

// #002 S
 strWrite.Format(RC_BLOCKLANG,wLocale);
 pFile.write((LPCTSTR)strWrite,strlen(strWrite));
// pFile->Write(RC_BLOCKLANG);
// #002 E

  pFile.write(RC_BLANK8,strlen(RC_BLANK8));
 pFile.write(RC_BEGIN,strlen(RC_BEGIN));

 pFile.write(RC_BLANK12,strlen(RC_BLANK12));
 strWrite.Format(RC_VAL_FILEVER,nFMajor,nFMinor,nFRelease);
  pFile.write((LPCTSTR)strWrite,strlen(strWrite));

  pFile.write(RC_BLANK12,strlen(RC_BLANK12));
 strWrite.Format(RC_VAL_PRODUCTVER,nPMajor,nPMinor,nPRelease);
  pFile.write((LPCTSTR)strWrite,strlen(strWrite));

 /*if(m_bRciExist) {
  strRci.Empty();
  m_Rci.GetFileDescription(strRci);
  if(!strRci.IsEmpty()) {
   str.Empty();
   m_Com.AddDblQuottoDblQuot((LPCTSTR)strRci,str);  // 2000.2.15
   m_Com.AddYentoYen((LPCTSTR)str,strRci);          // 2000.2.15
   pFile.write(RC_BLANK12,strlen(RC_BLANK12));
   strWrite.Format(RC_VAL_DESCRIPTION,(LPCTSTR)strRci);
   pFile.write((LPCTSTR)strWrite,strlen(strWrite));
  }

  strRci.Empty();
  m_Rci.GetCompanyName(strRci);
  if(!strRci.IsEmpty()) {
   str.Empty();
   m_Com.AddDblQuottoDblQuot((LPCTSTR)strRci,str);  // 2000.2.15
   m_Com.AddYentoYen((LPCTSTR)str,strRci);          // 2000.2.15
   pFile.write(RC_BLANK12,strlen(RC_BLANK12));
   strWrite.Format(RC_VAL_COMPANY,(LPCTSTR)strRci);
   pFile.write((LPCTSTR)strWrite,strlen(strWrite));
  }

  strRci.Empty();
  m_Rci.GetProductName(strRci);
  if(!strRci.IsEmpty()) {
   str.Empty();
   m_Com.AddDblQuottoDblQuot((LPCTSTR)strRci,str);  // 2000.2.15
   m_Com.AddYentoYen((LPCTSTR)str,strRci);          // 2000.2.15
   pFile.write(RC_BLANK12,strlen(RC_BLANK12));
   strWrite.Format(RC_VAL_PRODUCTNAME,(LPCTSTR)strRci);
   pFile.write((LPCTSTR)strWrite,strlen(strWrite));
  }

  strRci.Empty();
  m_Rci.GetLegalCopyright(strRci);
  if(!strRci.IsEmpty()) {
   str.Empty();
   m_Com.AddDblQuottoDblQuot((LPCTSTR)strRci,str);  // 2000.2.15
   m_Com.AddYentoYen((LPCTSTR)str,strRci);          // 2000.2.15
    pFile.write(RC_BLANK12,strlen(RC_BLANK12));
   strWrite.Format(RC_VAL_COPYRIGHT,(LPCTSTR)strRci);
   pFile.write((LPCTSTR)strWrite,strlen(strWrite));
  }

  strRci.Empty();
  m_Rci.GetComment(strRci);
  if(!strRci.IsEmpty()) {
   str.Empty();
   m_Com.AddDblQuottoDblQuot((LPCTSTR)strRci,str);  // 2000.2.15
   m_Com.AddYentoYen((LPCTSTR)str,strRci);          // 2000.2.15
   pFile.write(RC_BLANK12,strlen(RC_BLANK12));
   strWrite.Format(RC_VAL_COMMENTS,(LPCTSTR)strRci);
   pFile.write((LPCTSTR)strWrite,strlen(strWrite));
  }
 }*/

 //m_Com.GetFileName((LPCTSTR)m_strInput,strBaseName); // 俤倃俤乛俢俴俴柤偺僷僗傪庢傞
 //strFile = strBaseName="pe.exe";
    m_Rci.GetOriginalFileName(strFile);
    // m_Com.CutStrType(strBaseName);   // 奼挘巕愗傝庢傝
 //strInternalName = strBaseName;    // InternalName嶌惉
     m_Rci.GetInternalName(strInternalName);
  pFile.write(RC_BLANK12,strlen(RC_BLANK12));
 strWrite.Format(RC_VAL_INTERNAL,(LPCTSTR)strInternalName);
 pFile.write((LPCTSTR)strWrite,strlen(strWrite));

  pFile.write(RC_BLANK12,strlen(RC_BLANK12));
     strWrite.Format(RC_VAL_ORG,(LPCTSTR)strFile);
  pFile.write((LPCTSTR)strWrite,strlen(strWrite));

   // if(m_bCsiExist) {                // COM僒乕僶偺応崌
   //  pFile.write(RC_BLANK12);
//  pFile.write(RC_VAL_OLEREG,strlen(RC_VAL_OLEREG)); // OLESelefRegister
// }

  pFile.write(RC_BLANK8,strlen(RC_BLANK8));
  pFile.write(RC_END,strlen(RC_END));

  pFile.write(RC_BLANK4,strlen(RC_BLANK4));
     pFile.write(RC_END,strlen(RC_END));

     pFile.write(RC_BLANK4,strlen(RC_BLANK4));
  pFile.write(RC_BLOCKVAR,strlen(RC_BLOCKVAR));

     pFile.write(RC_BLANK4,strlen(RC_BLANK4));
  pFile.write(RC_BEGIN,strlen(RC_BEGIN));

     pFile.write(RC_BLANK8,strlen(RC_BLANK8));

// #002 S
 strWrite.Format(RC_VAL_TRANS,wLocale);
 pFile.write((LPCTSTR)strWrite,strlen(strWrite));
// pFile->Write(RC_VAL_TRANS);
// #002 E

 pFile.write(RC_BLANK4,strlen(RC_BLANK4));
  pFile.write(RC_END,strlen(RC_END));

 pFile.write(RC_END,strlen(RC_END));
 return 1;
}

 

抱歉!评论已关闭.