当前位置: 首页>>代码示例>>C++>>正文


C++ GetFileVersionInfoSize函数代码示例

本文整理汇总了C++中GetFileVersionInfoSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFileVersionInfoSize函数的具体用法?C++ GetFileVersionInfoSize怎么用?C++ GetFileVersionInfoSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetFileVersionInfoSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: malloc

// Returns the version, as two unsigned longs, of the passed in path.
// If there is an error, or the version can't be determined, this will
// return null.
// It is the callers responsibility to free the return value if it is
// non-null.
DWORD *getVersion(const char *path) {
    int        handle;
    int        size;

    if ((size = GetFileVersionInfoSize((char *)path, &handle)) > 0) {
        void     *data;

        data = malloc(size);
        if (GetFileVersionInfo((char *)path, 0, size, data)) {
            VS_FIXEDFILEINFO     info;
            void                 *infoData;
            int                  infoLength;

            if (VerQueryValue(data, "\\", &infoData, &infoLength)) {
                VS_FIXEDFILEINFO   *defaultInfo = (VS_FIXEDFILEINFO *)infoData;
                unsigned long      *retValue = (DWORD *)malloc(sizeof(DWORD)
                                                               * 2);

                retValue[0] = defaultInfo->dwFileVersionMS;
                retValue[1] = defaultInfo->dwFileVersionLS;
                return retValue;
            }
        }
    }
    return NULL;
}
开发者ID:EricDeCoff,项目名称:Android-KeyStore,代码行数:31,代码来源:versionChecker.c

示例2: GetFileVersionInfoSize

CString CGnucleusDoc::GetVersionInfo(void)
{
	char szAppName[_MAX_PATH];
	DWORD dwHandle, dwSize;
	CString version = "9.9.9.9";

	if( GetModuleFileName(AfxGetInstanceHandle(), szAppName, sizeof(szAppName)) )
	{
		dwHandle = 0;
		dwSize = GetFileVersionInfoSize(szAppName, &dwHandle);
		if( dwSize != 0L )
		{
			UINT uVerInfoSize;
			LPVOID lpStr;
			LPVOID lpVerInfo = new BYTE[dwSize];
			if( GetFileVersionInfo(szAppName, NULL, dwSize, lpVerInfo) )
			{
				if( VerQueryValue(lpVerInfo, "\\StringFileInfo\\040904B0\\ProductVersion", &lpStr, &uVerInfoSize) )
					version = reinterpret_cast<char *>(lpStr);
			}
			delete[] lpVerInfo;
		}
	}

	return version;

}
开发者ID:swax,项目名称:Gnucleus,代码行数:27,代码来源:GnucleusDoc.cpp

示例3: assert

void FileVersionInfo::_readVersion()
{	
	DWORD dwLen, dwUnUsed;
	LPTSTR lpVI = NULL;

	assert(m_file.size() >0);
	
	dwLen = GetFileVersionInfoSize(m_file.c_str(), &dwUnUsed);

	if (dwLen > 0)
	{
		lpVI = (LPTSTR) GlobalAlloc(GPTR, dwLen);
	}

	if (lpVI != NULL)
	{		
		VS_FIXEDFILEINFO *lpFfi;
		wchar_t szBuffer[2048];
		UINT uLen = 0;

		GetFileVersionInfo(m_file.c_str(), NULL, dwLen, lpVI);

		if (VerQueryValue(lpVI , L"\\" , (LPVOID *)&lpFfi , &uLen))
		{
			swprintf_s(szBuffer, L"%d.%d.%d.%d", HIWORD(lpFfi->dwProductVersionMS), LOWORD(lpFfi->dwProductVersionMS), 
				HIWORD(lpFfi->dwProductVersionLS), LOWORD(lpFfi->dwProductVersionLS));
			m_version = szBuffer;
			m_majorVersion =  HIWORD(lpFfi->dwProductVersionMS);
		}

		GlobalFree((HGLOBAL)lpVI);
	}

	g_log.Log(L"FileVersionInfo::ReadVersion. File '%s' version '%s'", (wchar_t*) m_file.c_str(), (wchar_t*) m_version.c_str());	
}
开发者ID:NoAntzWk,项目名称:CatalanitzadorPerAWindows,代码行数:35,代码来源:FileVersionInfo.cpp

示例4: getBtDllFileName

int vmsBtSupport::getBtDllVersion()
{
	static int ver = -1;
	if (ver != -1)
		return ver;

	CString str = getBtDllFileName ().c_str ();

	if (GetFileAttributes (str) == DWORD (-1))
		return ver = INT_MAX;
	
	DWORD dw;
	DWORD dwSize = GetFileVersionInfoSize (str, &dw);
	if (dwSize == 0)
		return ver = 0;
	LPVOID pvVer = _alloca (dwSize);
	ZeroMemory (pvVer, dwSize);
	if (FALSE == GetFileVersionInfo (str, 0, dwSize, pvVer))
		return ver = 0;
	
	VS_FIXEDFILEINFO *pFileInfo = NULL;
	UINT u;
	if (FALSE == VerQueryValue (pvVer, _T ("\\"), (LPVOID*)&pFileInfo, &u))
		return ver = 0;
	
	return ver = pFileInfo->dwFileVersionLS >> 16;
}
开发者ID:HackLinux,项目名称:Free-Download-Manager-vs2010,代码行数:27,代码来源:vmsBtSupport.cpp

示例5: GetFileVersion

static CComBSTR GetFileVersion(const TCHAR* cszFilePath)
{
	CComBSTR strVersion;

	TCHAR szFilePath[MAX_PATH]; _tcscpy(szFilePath, cszFilePath);
	DWORD hVersionInfo;
	DWORD cbVersionInfo = GetFileVersionInfoSize(szFilePath, &hVersionInfo);
	if(cbVersionInfo > 0)
	{
		char *rgchVersionInfo = new char[cbVersionInfo];
		if(GetFileVersionInfo(szFilePath, hVersionInfo, cbVersionInfo, rgchVersionInfo))
		{
			UINT cbFixedFileInfo;
			VS_FIXEDFILEINFO* pffiFixedFileInfo;

			if(VerQueryValue(rgchVersionInfo, "\\", (void**)&pffiFixedFileInfo, &cbFixedFileInfo))
			{
				int ver_major = HIWORD( pffiFixedFileInfo->dwFileVersionMS ) ;
				int ver_minor = LOWORD( pffiFixedFileInfo->dwFileVersionMS ) ;
				int ver_build = HIWORD( pffiFixedFileInfo->dwFileVersionLS ) ;
				int ver_year  = LOWORD( pffiFixedFileInfo->dwFileVersionLS ) ;

				char szVersion[12 * 4 + 3 + 1];
				wsprintf(szVersion, "%d.%d.%d.%d", ver_major, ver_minor, ver_build, ver_year);

				strVersion = szVersion;
			}
		}
		delete rgchVersionInfo;
	}

	return strVersion ;
}
开发者ID:pjtpj,项目名称:ImageUpload,代码行数:33,代码来源:DCSettings.cpp

示例6: GetFileVersionInfoSize

String TfrmMain::refreshVersion()
{
    DWORD dwHandle = 0, dwVersionInfoSize;
    UINT uLength;
    LPVOID pFileInfo, ptr;
    String sOut; // 리턴될 버전 정보.

    String filename = Application->ExeName;

    dwVersionInfoSize = GetFileVersionInfoSize(filename.c_str(), &dwHandle);

    pFileInfo = (LPVOID) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwVersionInfoSize);

    GetFileVersionInfo(filename.c_str(), dwHandle, dwVersionInfoSize, pFileInfo);
    VerQueryValue(pFileInfo, TEXT("\\VarFileInfo\\Translation"), &ptr, &uLength);

    WORD *id = (WORD *) ptr;
    String sQuery =  "FileVersion";//{"CompanyName", "FileDescription", "FileVersion", "InternalName", "LegalCopyright", "LegalTradeMarks", "OriginalFileName", "ProductName", "ProductVersion", "Comments"};
    String szString = "\\StringFileInfo\\" + IntToHex(id[0], 4) + IntToHex(id[1], 4) + "\\" + sQuery;

    VerQueryValue(pFileInfo, szString.c_str(), &ptr, &uLength);
    sOut = String((wchar_t *) ptr);
    HeapFree(GetProcessHeap(), 0, pFileInfo );
    return sOut;
}
开发者ID:japgo,项目名称:mygithub,代码行数:25,代码来源:fMain.cpp

示例7: GetFileVersionInfoSize

BOOL CModuleVersion::GetFileVersionInfo(LPCTSTR filename)
{
    // read file version info
    DWORD dwDummyHandle;
    // will always be set to zero
    DWORD len = GetFileVersionInfoSize( (LPTSTR)filename, &dwDummyHandle);
    if ( len <= 0 )
        return (FALSE);
    m_pVersionInfo = new BYTE[len]; // allocate version info
    if ( !::GetFileVersionInfo( (LPTSTR) filename, 0, len, m_pVersionInfo) )
        return (FALSE);

    LPVOID lpvi;
    UINT iLen;

    if ( !VerQueryValue(m_pVersionInfo, _T("\\"), &lpvi, &iLen) )
        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_pVersionInfo, _T("\\VarFileInfo\\Translation"),
                       &lpvi, &iLen) && iLen >= 4 )
    {
        m_translation = *(TRANSLATION*)lpvi;
        //TRACE("code page = %d\n", m_translation.charset);
    }
    return (dwSignature == VS_FFI_SIGNATURE);	
}
开发者ID:AlexS2172,项目名称:IVRM,代码行数:30,代码来源:ModulVer.cpp

示例8: GetFileCorporation

BOOL GetFileCorporation(PWCHAR pszFileName, PWCHAR pszFileCorporation)
{
    ULONG uLen;
    PVOID buf;
    PLANGUAGE_CODE_PAGE lpTranslate;
    UINT uTranslate;
    WCHAR szSubBlock[260];
    PVOID szInfo;
    UINT uLen1;

    if (pszFileName == NULL)   return FALSE;

    uLen = GetFileVersionInfoSize(pszFileName, 0);   
    if (uLen <= 0)  return FALSE;

    buf = GlobalAlloc(GPTR, uLen);  
    if (!GetFileVersionInfo(pszFileName, NULL, uLen, buf))   
    {   
        GlobalFree(buf);
        return FALSE;  
    }  
    VerQueryValue(buf, L"\\VarFileInfo\\Translation", 
                  (LPVOID*)&lpTranslate, &uTranslate); 
    wsprintf(szSubBlock, L"\\StringFileInfo\\%04x%04x\\CompanyName", 
                        lpTranslate[0].wLanguage, lpTranslate[0].wCodePage); 
    if(VerQueryValue(buf,szSubBlock, &szInfo, &uLen1) == FALSE)   
    {   
        GlobalFree(buf);
        return FALSE;
    }  
    wcscpy(pszFileCorporation, (PWCHAR)szInfo);
    GlobalFree(buf);
    return TRUE;
}
开发者ID:agostinopanico,项目名称:scdetective,代码行数:34,代码来源:File.cpp

示例9: GetDllVersion

const char* GetDllVersion(const char* filename)
{
    static TCHAR szVersion[32];	
    
    szVersion[0] = '\0';
    
    if(filename == NULL || filename[0] == '\0')
    {
        return szVersion;
    }
    
    DWORD dwHandle = 0;
    DWORD VersionInfoSize = GetFileVersionInfoSize(filename,&dwHandle);
    if(VersionInfoSize > 0)
    {
        void* pVersionInfo = new BYTE[VersionInfoSize];
        if(GetFileVersionInfo(filename, dwHandle, VersionInfoSize, pVersionInfo) == TRUE)
        {
            UINT uLen;
            VS_FIXEDFILEINFO *lpFfi;
            if(VerQueryValue(pVersionInfo, TEXT("\\"), (LPVOID *)&lpFfi, &uLen) == TRUE)
            {
                WORD w1, w2, w3, w4;
                w1 = (WORD)(lpFfi->dwFileVersionMS >> 16);
                w2 = (WORD)(lpFfi->dwFileVersionMS & 0xFFFF);
                w3 = (WORD)(lpFfi->dwFileVersionLS >> 16);
                w4 = (WORD)(lpFfi->dwFileVersionLS & 0xFFFF);
                wsprintf(szVersion,TEXT("%d.%d.%d.%d\0"),w1,w2,w3,w4);
            }
开发者ID:EQ4,项目名称:WavPack-DirectShow,代码行数:29,代码来源:WavPackDSDecoderAboutProp.cpp

示例10: GetFileVersion

//-----------------------------------------------------------------------------
// Name: GetFileVersion()
// Desc: Returns ULARGE_INTEGER with a file version of a file, or a failure code.
//-----------------------------------------------------------------------------
HRESULT GetFileVersion(TCHAR *szPath, ULARGE_INTEGER *pllFileVersion)
{
	if (szPath == NULL || pllFileVersion == NULL)
		return E_INVALIDARG;

	DWORD dwHandle;
	UINT  cb;
	cb = GetFileVersionInfoSize(szPath, &dwHandle);
	if (cb > 0)
	{
		BYTE *pFileVersionBuffer = new BYTE[cb];
		if (pFileVersionBuffer == NULL)
			return E_OUTOFMEMORY;

		if (GetFileVersionInfo(szPath, 0, cb, pFileVersionBuffer))
		{
			VS_FIXEDFILEINFO* pVersion = NULL;
			if (VerQueryValue(pFileVersionBuffer, TEXT("\\"), (VOID**)&pVersion, &cb) && pVersion != NULL)
			{
				pllFileVersion->HighPart = pVersion->dwFileVersionMS;
				pllFileVersion->LowPart  = pVersion->dwFileVersionLS;
				delete[] pFileVersionBuffer;
				return S_OK;
			}
		}

		delete[] pFileVersionBuffer;
	}

	return E_FAIL;
}
开发者ID:doorxp,项目名称:seed,代码行数:35,代码来源:DirectXVersion.cpp

示例11: _filename

mileversionimpl::mileversionimpl(const std::string &filename) : 
	_filename(filename), _haveinfo(false)
{
	VS_FIXEDFILEINFO *fileinfo;
	DWORD dummy;
	DWORD infoSize = GetFileVersionInfoSize(filename.c_str(), &dummy);
	if (infoSize > 0)
	{
		LPCSTR *buffer = new LPCSTR[infoSize];

		if (GetFileVersionInfo(filename.c_str(), dummy, infoSize, buffer))
		{
			LPVOID ptr;
			UINT len;

			if (VerQueryValue(buffer, "\\", &ptr, &len))
			{
				_haveinfo = true;
				fileinfo = (VS_FIXEDFILEINFO *)ptr;

				char vinfo[50];
				sprintf(vinfo, "%d.%d.%d.%d", 
					HIWORD(fileinfo->dwFileVersionMS), LOWORD(fileinfo->dwFileVersionMS),
					HIWORD(fileinfo->dwFileVersionLS), LOWORD(fileinfo->dwFileVersionLS));

				_fileversion = vinfo;
			}
		}

		delete [] buffer;
	}
}
开发者ID:RangelReale,项目名称:mileversion,代码行数:32,代码来源:mileversionimpl_WIN32.cpp

示例12: GetWindowsDirectory

int CAboutDlg::GetWindowsVersion(LPSTR strVersion)
{
	TCHAR lpszSysPath[512];	/* address of buffer for Windows directory	*/

	GetWindowsDirectory(lpszSysPath, 512);
	lstrcat(lpszSysPath,_T("\\system\\user.exe"));

	BYTE   abData[512];
	DWORD  handle;
	DWORD  dwSize;
	typedef struct tagLANGANDCP
	{
    	WORD wLanguage;
    	WORD wCodePage;
  	} LANGANDCP;
    LANGANDCP FAR  *lpBuffer;           // holds lang and codepage

	dwSize = GetFileVersionInfoSize(lpszSysPath, &handle);
#ifdef _DEBUG
	if(!dwSize)
		return 0;
#endif 

	GetFileVersionInfo(lpszSysPath, handle, dwSize, abData);

	VerQueryValue(abData, _T("\\VarFileInfo\\Translation"), (VOID FAR* FAR*)&lpBuffer, (UINT FAR *)&dwSize);
  	VerLanguageName (lpBuffer->wLanguage, strVersion, 512);

    return LOBYTE(LOWORD(GetVersion())); // windows version greater than 3.x?
}
开发者ID:CrawlingForward,项目名称:BWChess,代码行数:30,代码来源:AboutDlg.cpp

示例13: ishim_get_file_version

static int
ishim_get_file_version (const char * filepath, char * verout, int veroutlen)
{
	DWORD dwDummyHandle, len;
	BYTE * buf = 0;
	unsigned int verlen;
	LPVOID lpvi;
	VS_FIXEDFILEINFO fileInfo;

	if (!filepath || !filepath[0]) return 0;

	len = GetFileVersionInfoSize((char *)filepath, &dwDummyHandle);
	if (!len) return 0;
	buf = (BYTE *)malloc(len * sizeof(BYTE));
	if (!buf) return 0;
	GetFileVersionInfo((char *)filepath, 0, len, buf);
	VerQueryValue(buf, "\\", &lpvi, &verlen);
	fileInfo = *(VS_FIXEDFILEINFO*)lpvi;
	_snprintf(verout, veroutlen, "FV:%d.%d.%d.%d, PV:%d.%d.%d.%d"
		, HIWORD(fileInfo.dwFileVersionMS)
		, LOWORD(fileInfo.dwFileVersionMS)
		, HIWORD(fileInfo.dwFileVersionLS)
		, LOWORD(fileInfo.dwFileVersionLS)
		, HIWORD(fileInfo.dwProductVersionMS)
		, LOWORD(fileInfo.dwProductVersionMS)
		, HIWORD(fileInfo.dwProductVersionLS)
		, LOWORD(fileInfo.dwProductVersionLS));
	free(buf);
	return len;
}
开发者ID:MarcNo,项目名称:lifelines,代码行数:30,代码来源:intlshim.c

示例14: GetModuleFileName

void CXuser32App::GetVersionNumber(WORD nVersion[])
{
	TCHAR szPath[128];
	DWORD dwSize;
	
	nVersion[0] = nVersion[1] = nVersion[2] = nVersion[3] = 0;
	
	GetModuleFileName( NULL, szPath, 128 );
	dwSize = GetFileVersionInfoSize( szPath, &dwSize );
	
	if ( dwSize )
	{
		BYTE* pBuffer = new BYTE[ dwSize ];
		
		if ( GetFileVersionInfo( szPath, NULL, dwSize, pBuffer ) )
		{
			VS_FIXEDFILEINFO* pTable;
			
			if ( VerQueryValue( pBuffer, _T("\\"), (VOID**)&pTable, (UINT*)&dwSize ) )
			{
				nVersion[0] = (WORD)( pTable->dwFileVersionMS >> 16 );
				nVersion[1] = (WORD)( pTable->dwFileVersionMS & 0xFFFF );
				nVersion[2] = (WORD)( pTable->dwFileVersionLS >> 16 );
				nVersion[3] = (WORD)( pTable->dwFileVersionLS & 0xFFFF );
			}
		}
		
		delete [] pBuffer;
	}
开发者ID:pics860,项目名称:callcenter,代码行数:29,代码来源:Xuser32.cpp

示例15: GetModuleFileName

CSVPEqualizer::CSVPEqualizer(void)
:m_sys_44(NULL)
,m_sys_48(NULL)
,m_rate(0)
{
	if(1){
	CString path;
	GetModuleFileName(NULL, path.GetBuffer(MAX_PATH), MAX_PATH);
	path.ReleaseBuffer();
	path.MakeLower();
	//SVP_LogMsg3("%s", path);

	int Ret = -1;
	if( path.Find(_T("splayer")) >= 0 || path.Find(_T("svplayer")) >= 0 || path.Find(_T("mplayerc")) >= 0  ){
		DWORD             dwHandle;
		UINT              dwLen;
		UINT              uLen;
		UINT              cbTranslate;
		LPVOID            lpBuffer;

		dwLen  = GetFileVersionInfoSize(path, &dwHandle);

		TCHAR * lpData = (TCHAR*) malloc(dwLen);
		if(!lpData)
			return ;
		memset((char*)lpData, 0 , dwLen);


		/* GetFileVersionInfo() requires a char *, but the api doesn't
		* indicate that it will modify it */
		if(GetFileVersionInfo(path, dwHandle, dwLen, lpData) != 0)
		{
			

			// Read the file description for each language and code page.

			
				CString szParm( _T("\\StringFileInfo\\000004b0\\FileDescription") );

				if(VerQueryValue(lpData, szParm, &lpBuffer, &uLen) != 0)
				{

					CString szProductName((TCHAR*)lpBuffer);
					//SVP_LogMsg3("szProductName %s", szProductName);
					szProductName.MakeLower();

					if(szProductName.Find(_T("ÉäÊÖ")) >= 0 || szProductName.Find(_T("splayer")) >= 0 ){
						Ret = 3854;
						
					}
				}

		
		}
	}
		m_fyy =((Ret-14)%192 == 0);
		
	}
}
开发者ID:Fluffiest,项目名称:splayer,代码行数:59,代码来源:SVPEqualizer.cpp


注:本文中的GetFileVersionInfoSize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。