Get adress of 2d Array to IntPtr in C# -


i have c program want reprogram in c#.

in c program, function used accesses address of 2d array.

dll.h

int fg_addmem(fg_struct * fg, void *pbuffer, const size_t size, const frameindex_t bufferindex, dma_mem *memhandle); 

programm.cpp:

#include "dll.h" . . #define buffers 4 #define buffersize(1024*1024) static char buf[buffers+1][buffersize]  (int i=0; i<buffers; i++) { int ret = fg_addmem(fg, buf[i], buffersize, i, mhead); . . } 

now want programm in c#

first, created class import dll function on pinvoker addon

cam_siso.cs:

[dllimport ("fglib5.dll", setlasterror = true, callingconvention = callingconvention.cdecl)] public extern static int fg_addmem(intptr fg, intptr pbuffer, int size, int bufferindex, intptr memhandle); 

i'm created backgroundworker for-loop

application.cs:

int bufcnt=4; int buffersize = 1024*1024; backgroundworker worker_current_add_mem; . this.load += new eventhandler(this.add_mem_backgroundworker); . private void add_mem_backgroundworker(object sender, eventargs e) { . . worker_current_add_mem.dowork += new doworkeventhandler(worker_add_mem); } . private void worker_add_mem(object sender, doworkeventargs e) { char[,]buf = new char[bufcnt+1,buffersize]; for(int i=0; i<bufcnt; i++) { int ret = cam.siso.fg_addmem(fg, ??? , buffersize, i, mhead); . . } } 

so question is, how can pass address of 2d array intptr. in c, array incremented in first field add memory.

how proceed??

i tried gchandle , marshal.copy nothing works me.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -