|
-
Nov 5th, 2007, 10:14 AM
#1
Thread Starter
New Member
[RESOLVED] Understanding the CopyMemory method
This may sound like a silly question, but I've been having trouble reading an 8-byte REG_BINARY value from the registry and converting it to a Double. After extensive trial and error, I've discovered that the CopyMemory API is capable of doing that coversion. I've implemented it in the following way:
Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
' Irrelevant code...
Dim KeyHandle&, DataType&, BufferSize&, st$, lng&, bn() As Byte, dbl#
' Irrelevant code...
Case REG_BINARY
ReDim bn(0 To BufferSize - 1) As Byte
Call RegQueryValueEx(KeyHandle, Name, 0&, 0&, bn(0), BufferSize)
CopyMemory dbl, bn(0), CLng(UBound(bn) + 1)
RegistryRead = dbl
That way, a REG_BINARY value of hex:1c,0e,9a,bf,fe,3f,73,40 reads as 307.999694444444.
What I wanted to know is how exactly it is done. If I wanted, for instance, to manually convert (calc.exe?) the hexadecimal values above to the decimal result, how would I do that?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|