關於部落格
研究所升學、程式語言資訊、C/C++、Python、Perl、Shell、MySQL、PHP、CSS、VBA、JavaScript
  • 81049

    累積人氣

  • 2

    今日人氣

    0

    追蹤人氣

使用Windows API來取得編輯程式的版本的相關資訊 ---GetFileVersionInfo

BOOL GetFileVersion() { char cPath[MAX_PATH], cSubBlock[MAX_PATH]; DWORD dwHandle, dwInfoSize; UINT uTranslate = 0; Translate *lpTranslate; //Find file module path if(!GetModuleFileName(NULL, cPath, sizeof(cPath))) { printf("Can't find file path.n"); return FALSE; } //Get file version size dwInfoSize = GetFileVersionInfoSize(cPath, &dwHandle); if(dwInfoSize == 0) { return FALSE; } //Allocate buffer and retrieve version information char *cpInfoBuf = new char[dwInfoSize]; if(!cpInfoBuf) { return FALSE; } if(!GetFileVersionInfo(cPath, 0, dwInfoSize, cpInfoBuf)) { delete [] cpInfoBuf; return FALSE; } //Get the language setting first if(!VerQueryValue(cpInfoBuf, _TEXT("VarFileInfoTranslation"), (LPVOID*)&lpTranslate, &uTranslate)) { delete [] cpInfoBuf; return FALSE; } // Read the file description for each language and code page. CHAR *cpBuffer = NULL; UINT uBytes=0; CHAR *szpVersion[] = { "CompanyName", "FileVersion", "LegalCopyright", "PrivateBuild", "Comments", "InternalName", "ProductName", "ProductVersion", "FileDescription", "LegalTrademarks", "OriginalFilename", "SpecialBuild" }; for(int i = 0 ; i < 12 ; i++) { sprintf( cSubBlock, _TEXT("StringFileInfo%04x%04x%s"), lpTranslate[0].wLanguage, lpTranslate[0].wCodePage, szpVersion[i]); if(!VerQueryValue(cpInfoBuf, cSubBlock, (LPVOID* )&cpBuffer, &uBytes)) { printf("Warning : The file is no version information.n"); return FALSE; } m_csFileInfo[i] = cpBuffer; } *cpBuffer = NULL; delete [] cpInfoBuf; return TRUE; }
相簿設定
標籤設定
相簿狀態