P/Invoke for pointer to pointer argument.

  • Thread starter Thread starter Can Balioglu
  • Start date Start date
C

Can Balioglu

Hi,

I need to call the native function DnsQuery(..., PDNS_RECORD
*ppQueryResultsSet,...). The problem is; the function allocates a block of
memory and initializes it with the DNS query results and returns a pointer
to pointer to refer to this unmanaged memory area. I already created the
wrapper struct type representing a DNS_RECORD, but how do I have to call
DnsQuery? In some way the data needs to be marshaled to the managed memory
but I could not figure it out how.
 
but how do I have to call
DnsQuery? In some way the data needs to be marshaled to the managed memory
but I could not figure it out how.

Declare the parameter as an out IntPtr. Use Marshal.PtrToStructure to
dereference the pointer.



Mattias
 
Back
Top