Hi, would you please tell us the problem of our programming :
1¡B Variable declaration¡G
IHooksPtr *m_piHooks = NULL¡F
2¡BCOM initialization¡G
try
{
m_piHooks = new IHooksPtr("IESignal.Hooks.1");
m_pEvents = new EventSink(this);
LPUNKNOWN ****=m_pEvents->GetIDispatch(FALSE);
/*establish the connection*/
if(!AfxConnectionAdvise(*m_piHooks,__uuidof(_IHook sEvents),****,FALSE,&m_dwCookie))
{
// something bad happened
return FALSE;
}
}
catch (_com_error &e)
{
dump_com_error(e);
return FALSE;
}
3¡Bevent response connection
DISP_FUNCTION_ID(EventSink, "OnQuoteChanged", 2, OnQuoteChanged, VT_ERROR, VTS_BSTR)
DISP_FUNCTION_ID(EventSink, "OnBarsChanged", 3, OnBarsChanged, VT_ERROR, VTS_I4)
DISP_FUNCTION_ID(EventSink, "OnBarsReceived", 4, OnBarsReceived, VT_ERROR, VTS_I4)
4¡Bevent response
SCODE EventSink::OnQuoteChanged(LPTSTR symbol)
{
if(m_pListener) {
m_pListener->ES_OnQuoteChanged(symbol);
}
return S_OK;
}
5¡Bfunction body
void CBartchEsignalDlg::ES_OnQuoteChanged(LPCTSTR pszSymbol)
{
BasicQuote tBasicQuote = (*m_piHooks)->GetGetBasicQuote(pszSymbol);
}
Then the application throw exception and run down;
We use about 640 symbol, the exception always occurs at the time that the market is opening, the trading is very hot
1¡B Variable declaration¡G
IHooksPtr *m_piHooks = NULL¡F
2¡BCOM initialization¡G
try
{
m_piHooks = new IHooksPtr("IESignal.Hooks.1");
m_pEvents = new EventSink(this);
LPUNKNOWN ****=m_pEvents->GetIDispatch(FALSE);
/*establish the connection*/
if(!AfxConnectionAdvise(*m_piHooks,__uuidof(_IHook sEvents),****,FALSE,&m_dwCookie))
{
// something bad happened
return FALSE;
}
}
catch (_com_error &e)
{
dump_com_error(e);
return FALSE;
}
3¡Bevent response connection
DISP_FUNCTION_ID(EventSink, "OnQuoteChanged", 2, OnQuoteChanged, VT_ERROR, VTS_BSTR)
DISP_FUNCTION_ID(EventSink, "OnBarsChanged", 3, OnBarsChanged, VT_ERROR, VTS_I4)
DISP_FUNCTION_ID(EventSink, "OnBarsReceived", 4, OnBarsReceived, VT_ERROR, VTS_I4)
4¡Bevent response
SCODE EventSink::OnQuoteChanged(LPTSTR symbol)
{
if(m_pListener) {
m_pListener->ES_OnQuoteChanged(symbol);
}
return S_OK;
}
5¡Bfunction body
void CBartchEsignalDlg::ES_OnQuoteChanged(LPCTSTR pszSymbol)
{
BasicQuote tBasicQuote = (*m_piHooks)->GetGetBasicQuote(pszSymbol);
}
Then the application throw exception and run down;
We use about 640 symbol, the exception always occurs at the time that the market is opening, the trading is very hot
Comment