获取文件版本(IE)
GetFileInfo
CUIAction::GetFileVersion2
GetSystemDirectory WCHAR szConfigFile[MAX_PATH + 1];
::GetSystemDirectory(szConfigFile, MAX_PATH);
::PathAppend(szConfigFile, FileBootCleanConfigFileName); void GetApplicationVersion(char * strVersion)
{
TCHAR szFullPath[MAX_PATH];
DWORD dwVerInfoSize = 0;
DWORD dwVerHnd;
VS_FIXEDFILEINFO * pFileInfo; GetModuleFileName(NULL, szFullPath, sizeof(szFullPath));
dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
if (dwVerInfoSize)
{
// If we were able to get the information, process it:
HANDLE hMem;
LPVOID lpvMem;
unsigned int uInfoSize = 0; hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
lpvMem = GlobalLock(hMem);
GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem); ::VerQueryValue(lpvMem, (LPTSTR)("\\"), (void**)&pFileInfo, &uInfoSize); WORD m_nProdVersion[4]; // Product version from the FILEVERSION of the version info resource
m_nProdVersion[0] = HIWORD(pFileInfo->dwProductVersionMS);
m_nProdVersion[1] = LOWORD(pFileInfo->dwProductVersionMS);
m_nProdVersion[2] = HIWORD(pFileInfo->dwProductVersionLS);
m_nProdVersion[3] = LOWORD(pFileInfo->dwProductVersionLS); sprintf(strVersion, "%d.%d.%d.%d",
m_nProdVersion[0], m_nProdVersion[1],m_nProdVersion[2],m_nProdVersion[3]); GlobalUnlock(hMem);
GlobalFree(hMem);
}
else
{
strcpy(strVersion, "1.0");
}
}
BOOL CModuleVersion::GetDLLVersionInfo(LPCTSTR filename)
{
m_translation.charset = 1252; // default = ANSI code page
memset((VS_FIXEDFILEINFO*)this, 0, sizeof(VS_FIXEDFILEINFO)); // get module handle
//HMODULE hModule = LoadLibrary(filename);
//if (hModule==NULL)
// return FALSE; // some times, LoadLibrary may fail , --- by bbcallen
HMODULE hModule = LoadLibraryEx(filename, NULL, LOAD_LIBRARY_AS_DATAFILE);
if (hModule==NULL)
return FALSE; // read file version info
DWORD dwDummyHandle; // will always be set to zero
DWORD len = GetFileVersionInfoSize(filename, &dwDummyHandle);
if (len <= 0)
{
FreeLibrary(hModule);
return FALSE;
} BYTE* pbData = new BYTE[len]; // allocate version info
if (!pbData)
{
FreeLibrary(hModule);
return FALSE;
} m_atpVersionInfo.Attach(pbData);
if (!::GetFileVersionInfo(filename, 0, len, m_atpVersionInfo))
{
FreeLibrary(hModule);
return FALSE;
} LPVOID lpvi;
UINT iLen;
if (!VerQueryValue(m_atpVersionInfo, _T("\\"), &lpvi, &iLen))
{
FreeLibrary(hModule);
return FALSE;
} // copy fixed info to myself, which am derived from VS_FIXEDFILEINFO
*(VS_FIXEDFILEINFO*)this = *(VS_FIXEDFILEINFO*)lpvi; // Get translation info
if (VerQueryValue(m_atpVersionInfo,
_T("\\VarFileInfo\\Translation"), &lpvi, &iLen) && iLen >= 4) {
m_translation = *(TRANSLATION*)lpvi;
}
FreeLibrary(hModule);
return dwSignature == VS_FFI_SIGNATURE;
}
CString CGlobalFun::getIEVersion()
{
TCHAR szFilename[] = _T("mshtml.dll"); DWORD dwMajorVersion =0, dwMinorVersion = 0; DWORD dwBuildNumber =0, dwRevisionNumber = 0; DWORD dwHandle = 0; DWORD dwVerInfoSize = GetFileVersionInfoSize(szFilename, &dwHandle); if (dwVerInfoSize) {
LPVOID lpBuffer = LocalAlloc(LPTR, dwVerInfoSize);
if (lpBuffer)
{
if (GetFileVersionInfo(szFilename, dwHandle, dwVerInfoSize, lpBuffer))
{
VS_FIXEDFILEINFO * lpFixedFileInfo = NULL;
UINT nFixedFileInfoSize = 0;
if (VerQueryValue(lpBuffer, TEXT("\\"), (LPVOID*)&lpFixedFileInfo, &nFixedFileInfoSize) &&(nFixedFileInfoSize))
{
dwMajorVersion = HIWORD(lpFixedFileInfo->dwFileVersionMS);
dwMinorVersion = LOWORD(lpFixedFileInfo->dwFileVersionMS);
dwBuildNumber = HIWORD(lpFixedFileInfo->dwFileVersionLS);
dwRevisionNumber = LOWORD(lpFixedFileInfo->dwFileVersionLS);
}
}
LocalFree(lpBuffer);
} }
CString strVersion;
strVersion.Format(_T("MSIE %d.%d"),dwMajorVersion,dwMinorVersion);
/*printf("mshtml.dll VersionInfo: \n\tMajorVersion=%d\n\tMinorVersion=%d\n\tBuildNumber=%d\n\tRevisionNumber=%d\n", dwMajorVersion, dwMinorVersion, dwBuildNumber, dwRevisionNumber); */ return strVersion;
}
HRESULT CBootCheckTool::CopyDriverIfNew(LPCWSTR lpszNewDriver)
{
WCHAR szOldDriver[MAX_PATH + 1];
UINT uRet = ::GetSystemDirectory(szOldDriver, MAX_PATH);
if (!uRet)
return GetLastError() ? AtlHresultFromLastError() : E_FAIL; ::PathAppend(szOldDriver, L"Drivers");
::PathAppend(szOldDriver, BC_DriverFileName); ULARGE_INTEGER uiOldVersion = GetDllVersion(szOldDriver);
ULARGE_INTEGER uiNewVersion = GetDllVersion(lpszNewDriver); if (uiNewVersion.QuadPart <= uiOldVersion.QuadPart)
return S_FALSE; // 不需要拷贝 // 拷贝较新的版本
BOOL br = ::CopyFile(lpszNewDriver, szOldDriver, FALSE);
if (!br)
return GetLastError() ? AtlHresultFromLastError() : E_FAIL; return S_OK;
} ULARGE_INTEGER CBootCheckTool::GetDllVersion(LPCWSTR lpszFilePath)
{
BOOL bRet = FALSE;
DWORD dwHandle = 0;
DWORD dwFileInfoSize = 0;
VS_FIXEDFILEINFO *pFixFileInfo = NULL;
TCHAR *pszFileInfo = NULL;
UINT uLen = 0;
ULARGE_INTEGER uiVersion;
uiVersion.HighPart = 0;
uiVersion.LowPart = 0; dwFileInfoSize = ::GetFileVersionInfoSize(lpszFilePath, &dwHandle);
if (dwFileInfoSize == 0)
goto Exit0; pszFileInfo = new TCHAR[dwFileInfoSize];
if (pszFileInfo == NULL)
goto Exit0; bRet = ::GetFileVersionInfo(lpszFilePath, dwHandle, dwFileInfoSize, pszFileInfo);
if (!bRet)
goto Exit0; bRet = ::VerQueryValue(pszFileInfo, _T("\\"), (LPVOID *)&pFixFileInfo, &uLen);
if (!bRet)
goto Exit0; if (uLen > 0)
{
uiVersion.HighPart = pFixFileInfo->dwFileVersionMS;
uiVersion.LowPart = pFixFileInfo->dwFileVersionLS;
} Exit0:
if (pszFileInfo)
{
delete pszFileInfo;
pszFileInfo = NULL;
} return uiVersion;
}
获取文件版本(IE)的更多相关文章
- Powershell 获取文件版本信息
获取文件版本信息,通过FileVersionInfo::GetVersioninfo(file) 来获取信息 function Check-DdpstoreFileVersion{ $Ddpstore ...
- C#获取文件版本、文件大小等信息
使用以下C#程序代码可以非常方便地获取Windows系统中任意一个文件(尤其是可执行文件)的文件版本.文件大小.版权.产品名称等信息.所获取到的信息类似于在Windows操作系统中右键点击该文件,然后 ...
- C#获取文件版本信息
使用FileVersionInfo获取版本信息 FileVersionInfo info = FileVersionInfo.GetVersionInfo(Application.Current.St ...
- SharePoint online 获取文件版本记录
endpoint: _api/web/GetFileByServerRelativeUrl('/allDoc/xxx.pdf')/Versions 问题: 第一次使用,无论在本地还是o365上,都只返 ...
- C# 获取文件版本
var versionInfo = FileVersionInfo.GetVersionInfo(filePath); String productVersion = versionInfo.Prod ...
- WIN32 API 获取文件版本信息
CString strVersion; CString strPath(_T("xxxxxxxx.exe")); // 读文件信息 DWORD dwVerHnd = 0; DWOR ...
- win32api 获取文件版本信息
#coding:utf-8 myPath="C:\\ime" import os from win32api import GetFileVersionInfo, LOWORD, ...
- VB 获取文件版本
Function GetVer(FilePathName As String) As String If FilePathName = Nothing Or FilePathName = " ...
- SVN使用_获取某版本后改动的文件列表
本章将讲解如何通过svn命令获取某版本后改动的所有文件 一键操作,告别svn log的繁杂对比工作. 1:安装SVN命令行工具Subversion(不是TortoiseSVN) 下载Subversio ...
随机推荐
- sql语句查询重复值
select * from user where name in (select name from user group by name having count(*)>1)
- Android零基础入门第50节:StackView卡片堆叠
原文:Android零基础入门第50节:StackView卡片堆叠 上一期学习了AdapterViewFilpper的使用,你已经掌握了吗?本期开始学习StackView的使用. 一.认识StackV ...
- How to create my own self signed certificate chain?
--Refer to https://superuser.com/questions/126121/how-to-create-my-own-certificate-chain for detail. ...
- QSettings 用法总结(很好用)
原文 http://hi.baidu.com/fightiger/blog/item/ba69a434f36e18add1a2d350.html 用户对应用程序经常有这样的要求:要求它能记住它的se ...
- c#透明panel
先看下效果 纯透明的pane,然后设置一个半透明的图片,可以看出来显示了父控件的button 看代码 public partial class PanelEx : Panel { protected ...
- ThoughtWorks 面试备忘录
ThoughtWorks 面试备忘录 前言 前段时间 ThoughtWorks 在网上和拉勾网合作搞了一次网络招聘,名为抛弃简历!让代码说话!,可谓赚足了眼球,很多程序猿纷纷摩拳擦掌.踊跃提交代码,在 ...
- 代理Delegate的小应用(使用setModelData设置下拉日期对话框)
前言 在平时关于表格一类的的控件使用中,不可避免需要修改每个Item的值,通过在Item中嵌入不同的控件对编辑的内容进行限定,然而在表格的Item中插入的控件始终显示,当表格中item项很多的时候,会 ...
- 【Linux】Linux 环境下splite以及一些正则使用
由于在windows下,遍历目录,想查找满足条件的文件: dir /s > ..\fileresult.txt 结果得到的文件过大,999多MB的txt: split -b 10k date.f ...
- Django预备知识
http协议 url: 协议://域名(IP)+端口(80)/路径?参数(a=1&b=2) 示例:https://www.baidu.com/s/?wd=aaa MVC M:mdoel 与数据 ...
- UI-grid 表格内容可编辑(enableCellEdit可指定列编辑)
在网上搜索了很多关于UI-Grid的问题 很遗憾好少啊啊啊 不过有API还是比较欣慰的 官方API:UI Grid 还有一位大佬的翻译的中文API:angularjs ui-grid中文api 行编辑 ...