#include "StdAfx.h" #include "dataserver.h" #include "CHooks.h" CDataServer::CDataServer(void) : ESignal(NULL) { } CDataServer::~CDataServer(void) { End(); if(ESignal!=NULL) { delete ESignal; ESignal=NULL; } } //"c5916b45-a7eb-4919-a742-ad47ae3ae996" static const CLSID IHooksID = {0xC5916B45,0xA7EB,0x4919, { 0xA7,0x42,0xAD,0x47,0xAE,0x3A,0xe9,0x96 } }; void CDataServer::Run(void) { COleException *e=new COleException; ESignal=new CHooks(); if(ESignal==NULL) { TRACE("CDataServer: Failed to create ESignal Object\n"); goto DONE; } try { if(!ESignal->CreateDispatch(IHooksID,e)) { //if(!ESignal->CreateDispatch("IESignal.Hooks.1",e)) { // AfxMessageBox("Failed to create dispatch object"); throw e; } } catch(COleDispatchException * e) { CString cStr; if (!e->m_strSource.IsEmpty()) cStr = e->m_strSource + " - "; if (!e->m_strDescription.IsEmpty()) cStr += e->m_strDescription; else cStr += "unknown error"; AfxMessageBox(cStr, MB_OK, (e->m_strHelpFile.IsEmpty())? 0:e->m_dwHelpContext); e->Delete(); goto DONE; } catch(CException *e) { TRACE("%s(%d): OLE Exception caught: SCODE = %x\n", __FILE__, __LINE__, COleException::Process(e)); e->Delete(); goto DONE; } TRACE("CDataServer: Created Dispatch Successfully\n"); DONE: if(ESignal!=NULL) { delete ESignal; ESignal=NULL; } }