Re: passing buffer to unmanaged dll function

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Pascal Cloup (pcloup_at_biogesta.fr)
Date: 04/05/04


Date: Mon, 5 Apr 2004 10:20:38 +0200

Hi Ying-Shen,

Thanks for your advices.

The different tries which i made show that with the second method all works
fine, this is not the case with the first (?).
It remains one doubt in my mind; all the functions in these dll generally
returns immediatly but continues to use the buffer that was tansmmitted as
argument.
What happens if the .net moves the buffer for whatever reason that it is?
Is it necessary and possible to "lock " the buffer?

Thanks again

Pascal Cloup

""Ying-Shen Yu[MSFT]"" <v-yiy@online.microsoft.com> a écrit dans le message
de news:uZDxKltGEHA.1988@cpmsftngxa06.phx.gbl...
> Hi Pascal,
>
>
>
> Basically for an array of short, I suggest you using the second method,
> since in the first method you need allocate and release the unmanaged heap
> by your self.
> Using the 2nd method, CLR will managed the resource, it can even optimize
> the marshalling by pinning the short array object in the managed heap
> instead of copying it to unmanaged heap first. For more information on
this
> issue, you may take a look at docuement:
> <Blittable and Non-Blittable Types>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
> l/cpconBlittableNon-BlittableTypes.asp
>
>
>
> Feel free to let me know if you have any thing unclear about this issue.
>
> Have a nice day!
>
> Ying-Shen Yu [MSFT]
> Microsoft community Support
> Get Secure! - www.microsoft.com/security
>
> This posting is provided "AS IS" with no warranties and confers no rights.
> This mail should not be replied directly, please remove the word "online"
> before sending mail.
>