Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CopyMemory crashes app and VB.

Status
Not open for further replies.

gabster

Programmer
Oct 23, 2001
192
US
Hi all,

I have a program that suppose to scan an image, load it into memory and then grab it from there and send it to the server.
However the scan part works fine, also the load to memory also the calling the image from memory works fine.
The problem arise when I try to use CopyMemory api call.

Example (VB):


Private Sub SendToServer()
CopyMemory Text1.Text, hMem, hsize
End Sub


Where the "Text1.Text" is the destination, the hMem is the memory handle and the iSize is the size.

When I try to run it, it crashes not only the app but VB also - simply dissapears from the screen.
Here is how I drclare copyMemory:

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal cb As Long)

Thanks a lot,
Gabi.
 
I don't know VB, but i know how CopyMemory works. Dest and Src must be pointers and Text1.Text is definetely not a pointer.

--- markus
 
as McMerfy points out, change to pointer
The first parameter, Destination, must be large enough to hold Length bytes of Source; otherwise, a buffer overrun may occur.

CopyMemory(buf, pbData, min(cbData,BUFFER_SIZE)); Attitude is Everything
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top