C++ umnamanged dll ref を呼び出そうとしています。C# アプリケーションからのクラス オブジェクト。VC++ で動作する DLL 関数呼び出し。
私のVC++コードは次のとおりです
class METHOD_TYPE CDeskApi
{
public:
CDeskApi(void);
/*
Description : Initiates a connection to NEST system
Parameters : 1. serialkey provided to implement the api
2. object of CDeskApiCallback implemented
Return : 0 in case of success and -1 in case of error
*/
int Initialise(char *serialkey, CDeskApiCallback* callback);
/*
Description : Request data from the server
Parameters : 1. symbol of interest
2. intervals of 1 min, multiples of 1 min, DAILY_PERIOD in case of daily.
3. data to be retrieved from. in no of seconds since epoch
4. identifier, which is returned in the callback
Return : 0 in case of success and -1 in case of error
*/
~CDeskApi(void);
};
class METHOD_TYPE CDeskApiCallback
{
public:
};
class Myhandler : public CDeskApiCallback
{
public:
virtual int quote_notify( const char* symbol, int size, Quotation *pQuotes, unsigned long echo)
{
return 0;
};
};
Myhandler handler;
void Cnest_desk_appDlg::OnBnClickedOk()
{
if(odesk.Initialise("VWAP", &handler))
{
AfxMessageBox("Error!");
return;//error
}
}
私のC#コードは次のとおりです
[DllImport("DeskApi.dll", EntryPoint = "?Initialise@CDeskApi@@QAEHPADPAVCDeskApiCallback@@@Z")]
static extern void DeskApiInitialize(IntPtr symbol, callback fn);
private delegate int callback(IntPtr symbol, int nMaxSize, ref Quotation pQuotes, ulong echo);
private callback mInstance;
private void btnFetch_Click(object sender, EventArgs e)
{
IntPtr ptrCString = (IntPtr)Marshal.StringToHGlobalAnsi(txtFetch.Text);
CallTest.DeskApiGetQuote(ptrCString,quote_notify);
Marshal.FreeHGlobal(ptrCString);
}
private int quote_notify(IntPtr symbol, int nMaxSize, ref Quotation pQuotes, ulong echo)
{
return 0;
}
C# ではすべて正常に動作しますが、quote_notify関数が呼び出されませんか?