spythread.cpp
来自「一个手机通信的源代码 一个手机通信的源代码一个手机通信的源代码」· C++ 代码 · 共 97 行
CPP
97 行
// SpyThread.cpp: implementation of the CSpyThread class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Province.h"
#include "SpyThread.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSpyThread::CSpyThread(CString SpyQueuePath)
{
::CoInitializeEx(
NULL, //always NULL
COINIT_APARTMENTTHREADED //see book about threading models
);
m_QueuePtr=NULL;
m_QueueInfoPtr=NULL;
m_MessagePtr=NULL;
m_SpyQueuePath=SpyQueuePath;
}
CSpyThread::~CSpyThread()
{
}
void CSpyThread::InitChildClass()
{
InitQueue();
}
void CSpyThread::ExitThread()
{
}
void CSpyThread::OnTimer(UINT EventID)
{
}
void CSpyThread::SingleStep()
{
try
{
VARIANT TimeOut;
TimeOut.vt=VT_I4;
TimeOut.lVal=1;
m_MessagePtr=m_QueuePtr->Receive(&vtMissing,&vtMissing,&vtMissing,&TimeOut);
if (m_MessagePtr==NULL)
return;
}
catch(_com_error& e)
{
CMsmqerr errtemp;
CString ErrorInfo;
ErrorInfo.Format("Read queue error:%s",errtemp.GetErrText(e));
ReportError(ErrorInfo);
}
}
void CSpyThread::ReportError(CString &csErrorInfo)
{
}
BOOL CSpyThread::InitQueue()
{
::CoInitializeEx(
NULL, //always NULL
COINIT_APARTMENTTHREADED //see book about threading models
);
try{
m_QueueInfoPtr.CreateInstance(__uuidof(MSMQQueueInfo));
m_QueueInfoPtr->PutFormatName(_bstr_t(m_SpyQueuePath));
m_QueuePtr=m_QueueInfoPtr->Open(MQ_RECEIVE_ACCESS,MQ_DENY_NONE);
}
catch(_com_error& e)
{
CMsmqerr errtemp;
CString ErrorInfo;
ErrorInfo.Format("Init spy queue error:%s",errtemp.GetErrText(e));
ReportError(ErrorInfo);
return FALSE;
}
return TRUE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?