zoukankan      html  css  js  c++  java
  • [VC]获取本地程序的版本信息信息

     1 CString CQwerApp::IS_GetAppVersion(char *AppName)
     2 {
     3 ////需要加上version.lib在link里
     4 CString   AppVersion;  
     5 //AppVersion=IS_GetAppCreateTime(AppName);  
     6    
     7 DWORD   RessourceVersionInfoSize;  
     8 DWORD   JustAJunkVariabel;  
     9 char*   VersionInfoPtr;  
    10 struct   LANGANDCODEPAGE   {  
    11       WORD   wLanguage;  
    12       WORD   wCodePage;  
    13 }   *TranslationPtr;  
    14 char*   InformationPtr;  
    15 UINT     VersionInfoSize;  
    16 char     VersionValue[255];  
    17    
    18           RessourceVersionInfoSize=GetFileVersionInfoSize(AppName,&JustAJunkVariabel);  
    19           if(0!=RessourceVersionInfoSize)  
    20           {  
    21                   VersionInfoPtr=new   char[RessourceVersionInfoSize];  
    22                           if(GetFileVersionInfo(AppName,0,RessourceVersionInfoSize,VersionInfoPtr))  
    23                           {  
    24                           if(!VerQueryValue(  
    25                                   VersionInfoPtr,  
    26                                   TEXT("VarFileInfo\Translation"),  
    27                                           (LPVOID*)&TranslationPtr,  
    28                                           &VersionInfoSize))  
    29                                           {  
    30                           delete[]   VersionInfoPtr;  
    31                                                   return   AppVersion;  
    32                                           }  
    33                           }  
    34    
    35           //   retrieve   File   Description  
    36 wsprintf(VersionValue,  
    37                           TEXT(""),  
    38                           TranslationPtr[0].wLanguage,  
    39                           TranslationPtr[0].wCodePage);  
    40    
    41       if(!VerQueryValue(  
    42                           VersionInfoPtr,  
    43                                   VersionValue,  
    44                                   (LPVOID*)&InformationPtr,  
    45                                   &VersionInfoSize))  
    46                                   {  
    47                                   delete[]   VersionInfoPtr;  
    48                                           return   AppVersion;  
    49                                   }  
    50 if(strlen(InformationPtr)>0)   //Not   Null  
    51                           {  
    52                           AppVersion=CString(InformationPtr);  
    53                           }  
    54                           delete[]   VersionInfoPtr;  
    55           }  
    56           return   AppVersion;  
    57 
    58 }
  • 相关阅读:
    LeetCode 79. 单词搜索
    LeetCode 1143. 最长公共子序列
    LeetCode 55. 跳跃游戏
    LeetCode 48. 旋转图像
    LeetCode 93. 复原 IP 地址
    LeetCode 456. 132模式
    LeetCode 341. 扁平化嵌套列表迭代器
    LeetCode 73. 矩阵置零
    LeetCode 47. 全排列 II
    LeetCode 46. 全排列
  • 原文地址:https://www.cnblogs.com/gredswsh/p/get_version_information_about_local_programs.html
Copyright © 2011-2022 走看看