L
lightdoll
hello everyone.
i have made a dll of c++/cli, then i want to exchange structure between
c++/cli and c.
this is the structure
typedef struct tagExchange
{
int m_nIndex;
float m_fValue;
} exchagned;
first , c will use the dll made by c++/cli.
then c will pass a function pointer to c++/cli like callback function.
because i want to use the callback like event.
typedef void (*EXCHANGED)(int nCount, exchagned stIndex[]);// callback
function.
static void NotifyToC(System::Object ^sender, Dictionary<int, _CRequested^>
^requested)
{
int nLength = requestedIndex->Count;
array<exchagned *>^ arrIndex = gcnew array<exchagned; *>(nLength);
int nCount = 0;
_CRequested^ requested;
for each(KeyValuePair<int, _CRequested^>^ pair in requested)
{
arrIndex[nCount] = new exchagned();
arrIndex[nCount]->m_nIndex = pair->Key;
requestedItem =(_CRequested^) pair->Value;
arrIndex[nCount]->m_fValue =requestedItem->m_fValue;
nCount++;
}
pin_ptr<exchagned*> p1 = &arrIndex[0]; --
|-> here is my problem.
// gCallBackofExchanged(nCount, arrIndex);--
}
so how can i solve this problem.
i have made a dll of c++/cli, then i want to exchange structure between
c++/cli and c.
this is the structure
typedef struct tagExchange
{
int m_nIndex;
float m_fValue;
} exchagned;
first , c will use the dll made by c++/cli.
then c will pass a function pointer to c++/cli like callback function.
because i want to use the callback like event.
typedef void (*EXCHANGED)(int nCount, exchagned stIndex[]);// callback
function.
static void NotifyToC(System::Object ^sender, Dictionary<int, _CRequested^>
^requested)
{
int nLength = requestedIndex->Count;
array<exchagned *>^ arrIndex = gcnew array<exchagned; *>(nLength);
int nCount = 0;
_CRequested^ requested;
for each(KeyValuePair<int, _CRequested^>^ pair in requested)
{
arrIndex[nCount] = new exchagned();
arrIndex[nCount]->m_nIndex = pair->Key;
requestedItem =(_CRequested^) pair->Value;
arrIndex[nCount]->m_fValue =requestedItem->m_fValue;
nCount++;
}
pin_ptr<exchagned*> p1 = &arrIndex[0]; --
|-> here is my problem.
// gCallBackofExchanged(nCount, arrIndex);--
}
so how can i solve this problem.