Re: converting double pointer in C#
From: Mattias Sjögren (mattias.dont.want.spam_at_mvps.org)
Date: 03/26/04
- Next message: Nick: "Re: Newbie: Copying base class"
- Previous message: sadun: "associative arrays is c#"
- In reply to: John Gallagher: "converting double pointer in C#"
- Next in thread: John Gallagher: "Re: converting double pointer in C#"
- Reply: John Gallagher: "Re: converting double pointer in C#"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 26 Mar 2004 21:35:39 +0100
John,
I'd do it like this
[DllImport("kernel32.dll", EntryPoint="RtlMoveMemory")]
static extern void CopyMemory(IntPtr dest, IntPtr[] src, int cb);
IntPtr[] ptrs = new IntPtr[10];
for ( int i = 0; i < ptrs.Length; i++ )
ptrs[i] = Marshal.AllocHGlobal( 256 );
_list.test_list = Marshal.AllocHGlobal(10 * IntPtr.Size);
CopyMemory(_list.test_list, ptrs, 10 * IntPtr.Size);
And don't forget to free the memory when you're done.
Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
- Next message: Nick: "Re: Newbie: Copying base class"
- Previous message: sadun: "associative arrays is c#"
- In reply to: John Gallagher: "converting double pointer in C#"
- Next in thread: John Gallagher: "Re: converting double pointer in C#"
- Reply: John Gallagher: "Re: converting double pointer in C#"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|