Re: C# prototype of C: void**



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?
>


.



Relevant Pages

  • Re: UserName of a process
    ... Prisy ... > SID_AND_ATTRIBUTES, which has two fields, Sid and Attributes. ... > is the pointer to the SID. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: UserName of a process
    ... want to get the username for first. ... SID_AND_ATTRIBUTES, which has two fields, Sid and Attributes. ... is the pointer to the SID. ...
    (microsoft.public.dotnet.languages.csharp)
  • Mouse Pointer
    ... When I switch to the console ctrl-alt-f1 and go back to Xwindow ... shows up the Xwindow X pointer on the center of the screen but the ... PD this happens with Sarge and SID too ...
    (Debian-User)
  • How to get a pointer to a SID from an ACE
    ... a pointer to an Access Control Entry and from that gets a pointer to a ... a SidStart field that's used to get a pointer to the SID. ...
    (microsoft.public.win2000.security)
  • How to get a pointer to a SID from an ACE
    ... a pointer to an Access Control Entry and from that gets a pointer to a ... a SidStart field that's used to get a pointer to the SID. ...
    (microsoft.public.win2000.security)