Quote
>unsigned int dummy[4];
Why are you using that? Just use the parameters directly like you were
earlier. They are all references, so they will always point to valid
variables. You are not gaining anything at all by using a separate array.
Just trying to debug exactly where the CodeGuard error is happening. I'll
change it back after this gets fixed.
Quote
>bld = dummy[3]; // <- CodeGuard: Attempt to access 2
>// bytes that is offset 8 which is
>// only 8 bytes long.
There is no way that can be happening given the code you have shown.
Something else has to be happening. Either CodeGuard is reporting the
wrong
code line to begin with, or you have another dummy or bld variable
somewhere
that is being accessed instead of the ones you have shown here.
Drats. Well, let me just paste in the entire little diddy. I think I
included all the info, but I could be mistaken.
//---------------------------------------------------------------------------
int TMainForm::GetFileVersion(INT_16U &maj, INT_16U &min,
INT_16U &rev, INT_16U &bld)
{
DWORD unused;
DWORD verSize;
LPVOID result;
char* ptr;
char* aboutVerInfoBuffer;
int i;
int iRet = 0;
unsigned int len;
unsigned int resultLen;
AnsiString aboutVerBaseString;
// First, get how big the VersionInfo buffer needs to be
// ParamStr(0) holds the complete path to the application
verSize = GetFileVersionInfoSize(ParamStr(0).c_str(), &unused);
if (verSize>0)
{
try
{
aboutVerInfoBuffer = new char[verSize + 1];
// Now, get the sort-of handle we'll use in further VerQueryValue
calls
if
(GetFileVersionInfo(ParamStr(0).c_str(),0,verSize,aboutVerInfoBuffer))
{ // Extract the language/translation information...
if (VerQueryValue(aboutVerInfoBuffer,
TEXT("\\VarFileInfo\\Translation"), &(void*)ptr, &len))
{ // ptr comes back as a ptr to two (16-bit) words containing the
two halves of
// the translation number required for StringFileInfo
aboutVerBaseString = AnsiString( "\\StringFileInfo\\")+
IntToHex(((WORD*)ptr)[0],4) +
IntToHex(((WORD*)ptr)[1],4) + "\\FileVersion";
if (VerQueryValue(aboutVerInfoBuffer, aboutVerBaseString.c_str(),
&result, &resultLen))
{
sscanf(AnsiString((char*)result, resultLen).c_str(),
"%u.%u.%u.%u", &maj, &min, &rev, &bld);
iRet = 1;
}
}
}
else {
AnsiString aErr = "GetFileVersion failed:\n" +
SysErrorMessage(::GetLastError());
MessageBox(Handle, aErr.c_str(), "GetFileVersion Error", MB_OK |
MB_ICONERROR);
}
}
__finally {
delete[] aboutVerInfoBuffer;
}
}
return iRet;
}