General information
Category:
Windows API functions
Title:
Convert a negative value into hexadecimal
When I needed to convert a negative value into hexadecimal to use it in a WinAPI function I used this routine based in a clever conversion function by Ed Rauh. It works like a charm in Windows 98, but in Windows XP I only get a "Declare DLL caused an exception" error. Anybody kwnows how to make this routine works in WinXP o has an alternative method?
Declare Integer RtlMoveMemory in Win32API String @lpDest, Long nSource, Integer nBytes
nNumber = -2141040952
cRes = Replicate(Chr(0), 4)
If RtlMoveMemory(@cRes, nNumber, 4) > 0
cHex = ""
cHex = cHex + Right(Transform(Asc(SubStr(cRes, 1, 1)), "@0"), 2)
cHex = cHex + Right(Transform(Asc(SubStr(cRes, 2, 1)), "@0"), 2)
cHex = cHex + Right(Transform(Asc(SubStr(cRes, 3, 1)), "@0"), 2)
cHex = cHex + Right(Transform(Asc(SubStr(cRes, 4, 1)), "@0"), 2)
? cHex
else
? "Error"
Endif
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only