Click here to Skip to main content
15,891,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Loading Bitmap Into Picture Control Pin
SandipG 23-Apr-12 22:51
SandipG 23-Apr-12 22:51 
AnswerRe: Loading Bitmap Into Picture Control Pin
AmbiguousName23-Apr-12 23:31
AmbiguousName23-Apr-12 23:31 
GeneralRe: Loading Bitmap Into Picture Control Pin
enhzflep24-Apr-12 0:54
enhzflep24-Apr-12 0:54 
GeneralRe: Loading Bitmap Into Picture Control Pin
AmbiguousName24-Apr-12 1:02
AmbiguousName24-Apr-12 1:02 
QuestionThe entry point GetFileVersionInfoSizeEx Pin
jkirkerx23-Apr-12 13:23
professionaljkirkerx23-Apr-12 13:23 
AnswerRe: The entry point GetFileVersionInfoSizeEx Pin
Richard Andrew x6423-Apr-12 14:02
professionalRichard Andrew x6423-Apr-12 14:02 
GeneralRe: The entry point GetFileVersionInfoSizeEx Pin
jkirkerx23-Apr-12 15:10
professionaljkirkerx23-Apr-12 15:10 
GeneralRe: The entry point GetFileVersionInfoSizeEx Pin
JohnCz24-Apr-12 9:29
JohnCz24-Apr-12 9:29 
Actually is not as easy as it looks.
Unless you really need to retrieve localized version info size, use GetFileVersionInfoSize instead GetFileVersionInfoSizeEx. GetFileVersionInfoSize is available starting with Windows 2000. You do not have to call LoadLibrary and GetProcAddress since your module (exe) is linked implicitly with Version.lib.

To write robust code you would have to write more than simple GetProcAddress.
If you really want to use both, depending on the operating system, you will have to retrieve proc address depending on OS version and load appropriate procedure address, since Version.lib contains both: ASCII and UNICODE versions of the functions.
If your app is built as ANSII you would have to use ANSI version of the function: GetFileVersionInfoSizeExW or GetFileVersionInfoSizeW depending on what system your app is running on.
For unicode build you will have to explicitly request UNICODE versions: GetFileVersionInfoSizeExW or GetFileVersionInfoSizeA.
Something like this:

C++
//#define _USE_EXPLICIT
void GetFileVersionLenInfo()
{
	OSVERSIONINFO osvi = {sizeof(OSVERSIONINFO)};
	DWORD dwHandle = 8000;
	DWORD dwVer = 0;
	GetVersionEx(&osvi);
	HINSTANCE hInst = NULL;

#ifdef _USE_EXPLICIT

	typedef DWORD (CALLBACK* lpfnGETFILEVERSIONINFOSIZEEX)(DWORD, LPCTSTR, LPDWORD);
	typedef DWORD (CALLBACK* lpfnGETFILEVERSIONINFOSIZE)(LPCTSTR, LPDWORD);
	//typedef UINT (CALLBACK* LPFNDLLFUNC1)(DWORD,UINT);

	hInst = LoadLibrary(_T("VERSION.dll"));

	if(osvi.dwMajorVersion > 5)
	{
#ifdef UNICODE
		lpfnGETFILEVERSIONINFOSIZEEX lpfnGetFileVersionInfoSizeEx = (lpfnGETFILEVERSIONINFOSIZEEX)GetProcAddress(hInst, "GetFileVersionInfoSizeExW");
#else  
		lpfnGETFILEVERSIONINFOSIZEEX lpfnGetFileVersionInfoSizeEx = (lpfnGETFILEVERSIONINFOSIZEEX)GetProcAddress(hInst, "GetFileVersionInfoSizeExA");
#endif //  UNICODE

		dwVer = lpfnGetFileVersionInfoSizeEx(FILE_VER_GET_NEUTRAL, 
			_T("C:\\Program Files\\Beyond Compare 2\\BC2.exe"),
			&dwHandle);
		return;
	}

#ifdef UNICODE
	lpfnGETFILEVERSIONINFOSIZE lpfnGetFileVersionInfoSize = (lpfnGETFILEVERSIONINFOSIZE)GetProcAddress(hInst, "GetFileVersionInfoSizeW");
#else
	lpfnGETFILEVERSIONINFOSIZE lpfnGetFileVersionInfoSize = (lpfnGETFILEVERSIONINFOSIZE)GetProcAddress(hInst, "GetFileVersionInfoSizeA");
#endif //  UNICODE
	dwVer = lpfnGetFileVersionInfoSize(
		_T("C:\\Program Files\\Beyond Compare 2\\BC2.exe"), 
		&dwHandle);


#else
	dwVer = GetFileVersionInfoSize(
		_T("C:\\Program Files\\Beyond Compare 2\\BC22.exe"), 
		&dwHandle);
	DWORD dwError = GetLastError();
#endif
}


Uncomment _USE_EXPLICITTo compile using explicit link that checks for the OS version and loads appropriate versions of functions depending on UNICODE being defined or not.
JohnCz

GeneralRe: The entry point GetFileVersionInfoSizeEx Pin
jkirkerx24-Apr-12 10:11
professionaljkirkerx24-Apr-12 10:11 
AnswerRe: The entry point GetFileVersionInfoSizeEx Pin
JohnCz25-Apr-12 1:15
JohnCz25-Apr-12 1:15 
GeneralRe: The entry point GetFileVersionInfoSizeEx Pin
jkirkerx25-Apr-12 6:11
professionaljkirkerx25-Apr-12 6:11 
GeneralRe: The entry point GetFileVersionInfoSizeEx Pin
JohnCz25-Apr-12 8:04
JohnCz25-Apr-12 8:04 
GeneralRe: The entry point GetFileVersionInfoSizeEx Pin
jkirkerx25-Apr-12 9:10
professionaljkirkerx25-Apr-12 9:10 
QuestionTabControl In MFC Pin
002comp22-Apr-12 23:59
002comp22-Apr-12 23:59 
AnswerRe: TabControl In MFC Pin
Chandrasekharan P23-Apr-12 0:04
Chandrasekharan P23-Apr-12 0:04 
GeneralRe: TabControl In MFC Pin
002comp23-Apr-12 0:57
002comp23-Apr-12 0:57 
GeneralRe: TabControl In MFC Pin
Richard MacCutchan23-Apr-12 1:54
mveRichard MacCutchan23-Apr-12 1:54 
GeneralRe: TabControl In MFC Pin
JohnCz24-Apr-12 2:13
JohnCz24-Apr-12 2:13 
QuestionWhat does #pragma pack(0) do Pin
yu-jian22-Apr-12 6:28
yu-jian22-Apr-12 6:28 
AnswerRe: What does #pragma pack(0) do Pin
Chris Losinger22-Apr-12 6:39
professionalChris Losinger22-Apr-12 6:39 
GeneralRe: What does #pragma pack(0) do Pin
Erudite_Eric22-Apr-12 7:52
Erudite_Eric22-Apr-12 7:52 
GeneralRe: What does #pragma pack(0) do Pin
Chris Losinger22-Apr-12 8:15
professionalChris Losinger22-Apr-12 8:15 
GeneralRe: What does #pragma pack(0) do Pin
Erudite_Eric22-Apr-12 22:36
Erudite_Eric22-Apr-12 22:36 
AnswerRe: What does #pragma pack(0) do Pin
Lakamraju Raghuram22-Apr-12 7:47
Lakamraju Raghuram22-Apr-12 7:47 
GeneralRe: What does #pragma pack(0) do Pin
Erudite_Eric22-Apr-12 7:53
Erudite_Eric22-Apr-12 7:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.