CopyMemory and Win2000

iskitua used Ask the Experts™
I am calling the CopyMemory function.  In 95 this code works just fne.  I move it to Win2000 and as soon as it hits this function it dies.  any ideas?

CopyMemory sGrpRc, TGrpIdStrct, Len(TGrpIdStrct)

Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( _
     ByVal hpvDest As String, hpvSource As Any, ByVal cbCopy As Long)

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I think this stuff should just work, are you sure that sGrpRc is at least cbCopy bytes long?
Here's my API definition for that function:

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Note the As Any on the destination.  You are limiting to string.


I tried as Any.  Still the same results.
Found if I set the sGrpRc = Space(Len(TGrpIdStrct))
it works.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial