• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetFileVersionInfoSize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ResetValues

void TFileVersionInfo::ReadValues(String fname)
{
	ResetValues();

	DWORD zeroval;
	int size = GetFileVersionInfoSize(fname.c_str(), (LPDWORD)&zeroval);
	if (!size)
	{
		FError = true;
		FErrorMsg = "GetFileVersionInfoSize() failed. " + ECC_DEBUGINFO;
		return;
	}

	char* buf = new char[size+1];

	try
	{
		if (GetFileVersionInfo(fname.c_str(), 0, size, (LPVOID)buf) == 0)
			ECC_THROW("GetFileVersionInfo() failed");

		/* Get language/codepage: */
		struct TeccLangAndCP
		{
			WORD wLanguage;
			WORD wCodePage;
		} *PeccLangAndCP;
		UINT LangLen;

		if (VerQueryValue(buf, "\\VarFileInfo\\Translation", (LPVOID*)&PeccLangAndCP, &LangLen) == 0)
			ECC_THROW("VerQueryValue() failed while retrieving language/codepage");

		/* Get a value: */
		String sub_blk = Format("\\StringFileInfo\\%.4x%.4x\\",
			ARRAYOFCONST((PeccLangAndCP->wLanguage, PeccLangAndCP->wCodePage)));

		void* val;
		unsigned int len;

		for (int i = 0; i < eccFVIKeyStringsCount; i++)
		{
			if (VerQueryValue(buf, String(sub_blk + TEccFVIKeyStrings[i]).c_str(), &val, &len))
				Values[i] = String((char*)val, len).TrimRight();
				//ECC_THROW("VerQueryValue() failed while retrieving value");
			else
				Values[i] = "Error retrieving value of '" + TEccFVIKeyStrings[i] + "'";
		}

		/* Ok: */
		delete[] buf;
		SplitVersionNumber();
	}
	catch(Exception &ex)
	{
		FError = true;
		FErrorMsg = ex.Message;
		delete[] buf;
	}
}
开发者ID:ChakaZulu,项目名称:ecc,代码行数:58,代码来源:eccFileVersionInfo.cpp


示例17: Load

bool ZVersionInfo::Load(LPCTSTR szModule)
{
  // Check for a NULL or empty string
  if (!szModule || TEXT('\0') == *szModule)
    return Load(HINSTANCE(NULL));

  // Ensure that there is no previous version information block allocated
  Unload();
  assert(!m_cbVerInfo);
  assert(!m_pVerInfo);
  assert(!m_pFixed);

  // Get the size of the version information of the specified module
  BYTE* pVerInfo = NULL;
  DWORD cbVerInfo, dummy;
  cbVerInfo = GetFileVersionInfoSize(const_cast<LPTSTR>(szModule), &dummy);
  if (cbVerInfo)
  {
    // Allocate space to hold the version information
    pVerInfo = new BYTE[cbVerInfo];
    if (!pVerInfo)
    {
      SetLastError(ERROR_NOT_ENOUGH_MEMORY);
      return false;
    }
  }
  else
    cbVerInfo = sizeof(*m_pFixed);

  // Attempt to load the version information block
  if (!GetFileVersionInfo(const_cast<LPTSTR>(szModule), 0, cbVerInfo, pVerInfo))
  {
    DWORD dwLastError = GetLastError();
    delete [] pVerInfo;
    SetLastError(dwLastError ? dwLastError : ERROR_NO_MORE_ITEMS);
    return false;
  }

  // Attempt to get a pointer to the fixed version information
  VS_FIXEDFILEINFO* pFixed = NULL;
  UINT cbFixed = 0;
  if (!VerQueryValue(pVerInfo, TEXT("\\"), (void**)&pFixed, &cbFixed) || cbFixed != sizeof(*pFixed))
  {
    DWORD dwLastError = GetLastError();
    delete [] pVerInfo;
    SetLastError(dwLastError);
    return false;
  }

  // Save the size of the version info and the allocated pointers
  m_cbVerInfo = cbVerInfo;
  m_pVerInfo  = pVerInfo;
  m_pFixed    = pFixed;

  // Indicate success
  SetLastError(0);
  return true;
}
开发者ID:Factoid,项目名称:alleg-core,代码行数:58,代码来源:VersionInfo.cpp


示例18: memset

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;
}
开发者ID:dudor,项目名称:pcmanager,代码行数:57,代码来源:fileversionex.cpp


示例19: LoadVersionResource

Result LoadVersionResource(const string& file, Version::VersionResource& resource)
{
  DWORD wtf;
  DWORD size = GetFileVersionInfoSize(file.c_str(), &wtf);
  LibCC::Blob<BYTE> bindata(size);
  GetFileVersionInfo(file.c_str(), 0, size, bindata.GetBuffer());
  BinaryMemory mem(bindata.GetBuffer(), size);
  return resource.Read(mem);
}
开发者ID:thenfour,项目名称:VerEdit,代码行数:9,代码来源:veredit.cpp


示例20: DumpResourcesToDisk

void DumpResourcesToDisk(const string& exe, const string& dump)
{
  DWORD wtf;
  DWORD size = GetFileVersionInfoSize(exe.c_str(), &wtf);
  LibCC::Blob<BYTE> bindata(size);
  GetFileVersionInfo(exe.c_str(), 0, size, bindata.GetBuffer());
  BinaryFile f(dump, true);
  f.Write(bindata.GetBuffer(), bindata.Size());
}
开发者ID:thenfour,项目名称:VerEdit,代码行数:9,代码来源:veredit.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetFireRate函数代码示例发布时间:2022-05-30
下一篇:
C++ GetFileType函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap