如何在C#中实现非托管回调函数?

时间:2017-01-15 09:45:54

标签: c# c

如何实现下面的C#代码?这是来自非托管C / C ++ DLL的回调函数。

extern void (*NdProcSamples)(word dc, word phase, word sum_st, const NdPackChan *chans);//This function is in Third party(C/C++ DLL).

typedef void (*TProcSamples)(word dc, word phase, word sum_st, const NdPackChan *chans); //Call back Fucntion

TProcSamples *pProcSamples;

pProcSamples = (TProcSamples*) GetProcAddress(drv_lib, "NdProcSamples") //Gets address of function

*pProcSamples = NdProcSamples;

// Function below gets called by driver(DLL)

void NdProcSamples(word dc, word phase, word sum_st, const NdPackChan *chans)
{

    //logic goes here 

}

0 个答案:

没有答案