Re: C# prototype of C: void**
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 4 Aug 2005 13:48:38 -0400
I would declare it like this:
// The assmption is that it returns an integer.
[DllImport("some.dll")]
private static extern int imgSnap(int sid, ref IntPtr bufAddr);
Pointers are typically passed around in IntPtr variables, and since you
have a pointer to a pointer, you need to pass it by ref.
However, accessing this in C# will require you to marshal the values in
memory from unmanaged to managed code, which can get costly for 1/2 million
bytes.
You might want to consider using unsafe code here and casting the
pointer to a byte array, and performing whatever operation you have to do in
there.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<frankh@xxxxxxxxxxxx> wrote in message
news:1123177279.875587.220400@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I want to access a function implemented in a C-dll with the following
> prototype:
> rval = imgSnap(SESSION_ID sid, void** bufAddr)
> Now:
> 1. How would the "void** bufAddr" part look like in the corresponding
> C# prototype?
> 2. How do I call this C# method (rval is uint, sid is int)?
>
> "bufAddr" exists allready, it must not be allocated, and I don't want
> to copy data. imgSnap shall simply write its half a million bytes from
> &&bufAddr on.
>
> Any idea?
>
.
- Follow-Ups:
- Re: C# prototype of C: void**
- From: frankh
- Re: C# prototype of C: void**
- References:
- C# prototype of C: void**
- From: frankh
- C# prototype of C: void**
- Prev by Date: RE: Targeting .NET v1.1 with Visual C# Express Edition Beta 2?
- Next by Date: RE: Info!
- Previous by thread: C# prototype of C: void**
- Next by thread: Re: C# prototype of C: void**
- Index(es):
Relevant Pages
|
|