_Hex function (VO28Run)

This forum is meant for questions and discussions about the X# language and tools
Post Reply
stefan.ungemach
Posts: 71
Joined: Thu Jul 15, 2021 10:46 am
Location: Germany

_Hex function (VO28Run)

Post by stefan.ungemach »

Hi all,

it seems that the VO28Run function _Hex isn't implemented yet. Does anyone have a suggestion how to write this part of my code (I've posted the whole entity for better understanding of what I want do do) VO code properly in X#:

LOCAL ptrLanguage AS WORD PTR
LOCAL DIM aName[256] AS BYTE
LOCAL DIM aHex[8] AS BYTE
LOCAL ptrValue AS PTR

dwSize := GetFileVersionInfoSize( pszFile, @dwZero )

IF dwSize > 0

ptrInfo := MemAlloc( dwSize )

IF MemCheckPtr( ptrInfo, dwSize )

dwLangSize := 4 * _SIZEOF(WORD)
ptrLanguage := MemAlloc( dwLangSize )

IF MemCheckPtr( ptrLanguage, dwLangSize )

IF GetFileVersionInfo( pszFile, 0, dwSize, ptrInfo )

IF !VerQueryValue( ptrInfo, String2Psz( ;
"VarFileInfoTranslation" ),;
@ptrLanguage, @dwLangSize )
dwLangSize := 0
ENDIF

MemCopy( @aName[1], PTR( _CAST, "StringFileInfo" ), 18 )

IF dwLangSize >= 2
_Hex( ptrLanguage[1], @aHex[1] )
MemCopy( @aName[19], @aHex[5], 4 )
_Hex( ptrLanguage[2], @aHex[1] )
MemCopy( @aName[23], @aHex[5], 4 )

ELSE
// As default: Lang = US English, CharSet= Windows Multilingual
MemCopy( @aName[19], PTR( _CAST, "040904E4" ), 8 )

ENDIF

MemCopy( @aName[27], PTR( _CAST, "" ), 2 )
MemCopy( @aName[29], PTR( _CAST, pszValueName ), PszLen( pszValueName ))

ptrValue := MemAlloc( dwValueLength )

IF MemCheckPtr( ptrValue, dwValueLength )
IF VerQueryValue( ptrInfo, PSZ( _CAST, @aName[1] ), @ptrValue, @dwValueLength )
MemCopy( ptrValueBuffer, ptrValue, dwValueLength )
lSucceed := TRUE

ENDIF
MemFree( ptrValue )
ENDIF

ENDIF

MemFree( ptrLanguage )

ENDIF

MemFree( ptrInfo )

ENDIF
ENDIF

RETURN lSucceed
User avatar
robert
Posts: 4473
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

_Hex function (VO28Run)

Post by robert »

Stefan

AFAIK the function _Hex sets the address that was passed a second argument to the HEX value of the first argument.
In your code however you are setting 4 elements of aHex, but you are not using them at all.
So what happens if you simply comment out that code?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
stefan.ungemach
Posts: 71
Joined: Thu Jul 15, 2021 10:46 am
Location: Germany

_Hex function (VO28Run)

Post by stefan.ungemach »

Robert,

thanks for explaining. You're right, commenting out should do no harm.

CU Stefan
Post Reply