Get File Version in your code
来源:互联网 发布:拟态防御 知乎 编辑:程序博客网 时间:2024/05/16 04:42
////////////////////////////////////////////////////////////////// File: version.cpp// Description: Sample code for getting version info// Created: 2008-1-4// Author: Ken Zhang// E-Mail: cpp.china@hotmail.com/////////////////////////////////////////////////////////////////* The following code shows how to get FILEINFO value from resource file. These WIN32 functions will be used: * GetFileVersionInfo * GetFileVersionInfoSize * VerQueryValue * GetModuleFileName */#include <windows.h>#include <tchar.h>#include <string>#include <iostream>#pragma comment(lib, "version.lib")using namespace std;bool GetFileVersion(HMODULE hModule, WORD *pBuffer){ TCHAR fname[MAX_PATH]; VS_FIXEDFILEINFO *pVi; DWORD dwHandle; string str; if (::GetModuleFileName(hModule, fname, MAX_PATH)) { int size = GetFileVersionInfoSize(fname, &dwHandle); if (size > 0) { BYTE *buffer = new BYTE[size]; if (GetFileVersionInfo(fname, dwHandle, size, buffer)) { if (VerQueryValue(buffer, _T("//"), (LPVOID *)&pVi, (PUINT)&size)) { pBuffer[0] = HIWORD(pVi->dwFileVersionMS); pBuffer[1] = LOWORD(pVi->dwFileVersionMS); pBuffer[2] = HIWORD(pVi->dwFileVersionLS); pBuffer[3] = LOWORD(pVi->dwFileVersionLS); delete buffer; return true; } } delete buffer; } } return false;}string GetFileVersion(HMODULE hModule){ string str; WORD buffer[4]; if (GetFileVersion(hModule, buffer)) { char str2[32]; for (int i = 0; i < sizeof(buffer)/sizeof(WORD); i++) { itoa(buffer[i], str2, 10); str += str2; if (i != sizeof(buffer)/sizeof(WORD) - 1) { str += "."; } } } return str;}void main(){ cout << "Current version is: " << GetFileVersion(::GetModuleHandle(NULL)) << endl;}
- Get File Version in your code
- Get Your Database Under Version Control
- The entitlements specified in your application’s Code Signing Entitlements file do not match those
- The entitlements specified in your application’s Code Signing Entitlements file do not match ...
- The entitlements specified in your application’s Code Signing Entitlements file do not match those s
- “The entitlements specified in your application’s Code Signing Entitlements file do not match those
- The entitlements specified in your application’s Code Signing Entitlements file do not match those s
- The entitlements specified in your application’s Code Signing Entitlements file do not match those s
- The entitlements specified in your application’s Code Signing Entitlements file do not match those s
- method to The entitlements specified in your application’s Code Signing Entitlements file do not mat
- The entitlements specified in your application’s Code Signing Entitlements file do not match those s
- The entitlements specified in your application’s Code Signing Entitlements file do not match those s
- The entitlements specified in your application’s Code Signing Entitlements file do not match those .
- The entitlements specified in your application’s Code Signing Entitlements file do not match those s
- 真机调试The entitlements specified in your application’s Code Signing Entitlements file do not match tho
- 真机调试The entitlements specified in your application’s Code Signing Entitlements file do not match tho
- iOS真机调试报错,The entitlements specified in your application’s Code Signing Entitlements file do not mat
- Use Weka in your Java code
- 热爱用c/c++写代码的请加入群:67620078
- 编写SQL:看似简单,实际超难的SQL语句!
- 一种躲避运行时代码校验的方法
- 修改statspack 生成报告脚本
- 关于接口中常量的访问方法
- Get File Version in your code
- 执行缓存以优化SQL Server的内存占用
- C#截屏并发送到邮箱
- 实例图解:摄影构图大实话
- 如何提高执行力度
- DOM4J中文问题 Invalid byte 1 of 1-byte UTF-8 sequence.
- AJAX UpdateProgressBar
- 学习笔记:sql server 的触发器概念及使用(2)
- 变态才能成功