charu123 wrote: lpData=(char*)malloc(sizeof(BUF)); I think this should be lpData=(char*)malloc(dwLen). charu123 wrote: sprintf (b,"MinorVersion: %d\n",LOWORD(pFileInfo->wProductVersionMS)); The compiler should have complained about this one as wProductVersionMS is not a valid member name. Other than that, and the lack of error checking, what you have should work. You do, however, seem to be confused as to when to use MFC and when not to. Unless there is no MFC equivalent for some Win32 function, it really makes no sense to mix the two. Here is a modified version of your code:
VS_FIXEDFILEINFO *pFileInfo;
LPCTSTR pszFile = "trial.html",
pszPath = "C:\\Documents and Settings\\bhoomika.WIPHP_DOMAIN\\Desktop";
CString strExecutable,
strResult;
DWORD dwHandle,
dwVerSize;
LPBYTE pBuffer;
UINT uBufLen;
FindExecutable(pszFile, pszPath, strExecutable.GetBuffer(_MAX_PATH));
strExecutable.ReleaseBuffer();
dwVerSize = GetFileVersionInfoSize(strExecutable, &dwHandle);
if (dwVerSize > 0)
{
pBuffer = new BYTE[dwVerSize];
if (NULL != pBuffer)
{
if (GetFileVersionInfo(strExecutable, dwHandle, dwVerSize, pBuffer) != FALSE)
{
if (VerQueryValue(pBuffer, "\\", (LPVOID *) &pFileInfo, &uBufLen) != FALSE)
{
strResult.Format("MajorVersion: %u\nMinorVersion: %u",
HIWORD(pFileInfo->dwProductVersionMS),
LOWORD(pFileInfo->dwProductVersionMS));
}
else
strResult.Format("VerQueryValue() failed. Error = %lu", GetLastError());
}
else
strResult.Format("GetFileVersionInfo() failed. Error = %lu", GetLastError());
delete \[\] pBuffer;
}
}
else
strResult.Format("GetFileVersionInfoSize() failed. Error = %lu", GetLastError());
AfxMessageBox(strResult);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow