Link to home
Start Free TrialLog in
Avatar of TungVan
TungVan

asked on

read binary file to buffer using globalalloc/copymemory



Hi,

Here is part of my code:


__________________________________________________________________________________________________________________
Open file For Binary Access Write As fileTemp
Put fileTemp, , m_version
m_FileNumber = fileTemp

If m_FileNumber <> 0 Then
   
        memory_handle = GlobalAlloc(GMEM_MOVEABLE, LOF(m_FileNumber))

        If memory_handle Then

            memory_pointer = GlobalLock(memory_handle)

            CopyMemory ByVal memory_pointer, m_FileNumber, _
                LOF(m_FileNumber)

            GlobalUnlock memory_handle

        End If

       
    End If

__________________________________________________________________________________________________________________


Is it the good way to do it?

And how can i watch the value that memory_pointer is pointing to?
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TungVan
TungVan

ASKER



I try to serialize/deserialize instance of object class to the memory in vb6...

One of its use is for clipboard:

I want to serialize the object to the memory, and pass the memory pointer to the clipboard for copying