Results 1 to 18 of 18

Thread: [RESOLVED] Avoiding Memory Leaks - CopyMemory

Threaded View

  1. #15
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: [RESOLVED] Avoiding Memory Leaks - CopyMemory

    I am getting a little out of touch but, I assume you both know that when passing strings to API, VB makes a temporary ANSI copy of the string and passes the temporary copy instead. By passing the first element ByRef VB knows you are passing a reference to something which contains a string so it makes a temporary ANSI copy of the first element (and just the first element) and passes that. Hence apparent garbage. If you followed that string pointer I bet you find an ANSI string.

    The moral of the story should perhaps be, be careful with ByRef strings and API.
    Last edited by Milk; Feb 10th, 2011 at 08:50 AM. Reason: went a bit comma crazy
    W o t . S i g

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width