AddVersion

    void AddVersion()

    {

       TCHAR szAppPath[MAX_PATH] = {0};  

       GetModuleFileName(NULL, szAppPath, MAX_PATH);  

 

       VS_FIXEDFILEINFO *VInfo;  

       UINT i;  

       TCHAR *buf;  

       int ma,mj,r,b;  

       i = GetFileVersionInfoSize(szAppPath, 0);  

       buf=   new   TCHAR[i];  

 

 

 

       if (GetFileVersionInfo(szAppPath, 0, i, buf) != 0)  

       {

           if (VerQueryValue(buf,_T("\\"),(LPVOID*)&VInfo,&i))  

           {  

              ma = VInfo->dwFileVersionMS >> 16;  

              mj = VInfo->dwFileVersionMS & 0xffff;  

              r = VInfo->dwFileVersionLS >> 16;  

              b = VInfo->dwFileVersionLS &0xffff;  

              _stprintf(buf,_T("%d.%2.2d.%2.2d.%4.4d"), ma,mj,r,b);

 

           }  

       }   

 

       TCHAR str[MAX_PATH];

       GetWindowText(str,MAX_PATH-1);

       lstrcat(str,_T("-"));

       lstrcat(str,buf);

 

       SetWindowText(str);

 

       delete []buf;   

    }

posted on 2010-07-18 11:45  devcfei  阅读(181)  评论(0编辑  收藏  举报