www.pudn.com > 200311301927570.rar > queue.h


/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
// Queue.h: interface for the CQueue class.																	    //	 
// Authour :		Airlink 																					//		 
// E-Mail:			Airlink@sohu.com																			//			 
// CreateTime:		2002-12-08																					//	 
// Decalaration:	This class is based on MSMG 2.0, The writing message mode is MQMSG_DELIVERY_EXPRESS.		// 
//					so, the message stays in memory until it  be Readed out.									// 
//					You must Initialize Com Libarary before use this class.										// 
// Example:			 																							// 
//																												// 
//	TestApp::InitInstance()																						// 
//	{																											//				 
//		::CoInitialize(NULL);																					// 
//	}																											// 
//	TestApp::ExitInstance()																						// 
//	{																											//				 
//		CoUninitialize();																						// 
//	}																											// 
//	void ReadWrite()																							//			 
//	{																											//	 
//		CQueue  queue;																							//	 
//		if(!queue.InitInstance("DIRECT=os:Airlink\\Private$\\TestWrite",										// 
//							   "DIRECT=OS:Airlink\\Private$\\TestRead"))	{									// 
//			return;																								// 
//		}																										//	 
//																												// 
//		_bstr_t lable;																							// 
//		_variant_t body;																						// 
//		queue.ReadQueue(lable, body, priority, 100));															//	 
//		queue.WriteQueue(lable, body, priority);																// 
//	}																											// 
//																												//	 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ 
 
#if !defined(AFX_COMQUEUE_H__E3F9FE80_E269_4EFA_B3F0_B92272B36CD6__INCLUDED_) 
#define AFX_COMQUEUE_H__E3F9FE80_E269_4EFA_B3F0_B92272B36CD6__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
#import "C:\WINNT\system32\mqoa.dll" no_namespace 
 
class AFX_EXT_CLASS CQueue 
{ 
public: 
	CQueue(); 
	virtual ~CQueue(); 
 
	//用途:初始化队列 
	//in:	strWrtieQueuePath  -- 写操作队列的路径 
	//in:	strReadQueuePath   -- 读操作队列的路径 
	//in:	nWRMode -- 读写模式。1 -- 只读队列, 2 -- 只写队列, 3 -- 读写队列(Default) 
	BOOL InitInstance(CString strWrtieQueuePath/*Write-in*/, CString strReadQueuePath/*Read-out*/, int nWRMode = 3); 
 
	//用途:读队列 
	//in :	lTimeout   -- 读操作延时。0 - 阻塞方式, x - 超时(ms) 
	//out:	bstrLable  -- 读出标签 
	//out:	varBody    -- 读出正文 
	//out:	lPriority  -- 读出优先级 
	BOOL ReadQueue(CString &strLable, _variant_t &varBody, long &lPriority, long lTimeout); 
 
	//用途:写队列 
	//in:	bstrLable  -- 写入标签 
	//in:	varBody    -- 写入正文 
	//in:	lPriority  -- 写入优先级	 
	BOOL WriteQueue(const CString  &strLable, const _variant_t &varBody, const long &lPriority); 
 
	//用途:读队列 
	//in :	lTimeout   -- 读操作延时。0 - 阻塞方式, x - 超时(ms) 
	//out:	strLable  -- 读出标签 
	//out:	strBody    -- 读出正文 
	//out:	lPriority  -- 读出优先级 
	BOOL ReadQueue(CString &strLable, CString &strBody, long &lPriority, long lTimeOut); 
 
	//用途:写队列 
	//in:	strLable  -- 写入标签 
	//in:	strBody    -- 写入正文 
	//in:	lPriority  -- 写入优先级	 
	BOOL WriteQueue(const CString &strLable, const CString &strBody, const long &lPriority); 
 
	//用途:读队列 
	//in :	lTimeout   -- 读操作延时。0 - 阻塞方式, x - 超时(ms) 
	//out:	strLable   -- 读出标签 
	//out:	strBody    -- 读出正文 
	//out:	lPriority  -- 读出优先级 
	//out:	otmSenTime -- 读出发送时间 
	BOOL ReadQueue(CString &strLable, CString &strBody, long &lPriority, COleDateTime &otmSenTime, long lTimeOut); 
 
	//用途:读队列 
	//in :	lTimeout   -- 读操作延时。0 - 阻塞方式, x - 超时(ms) 
	//out:	strLable   -- 读出标签 
	//out:	strBody    -- 读出正文 
	//out:	lPriority  -- 读出优先级 
	//out:	otmSenTime -- 读出发送时间 
	BOOL ReadQueue(CString &strLable, _variant_t &varBody, long &lPriority, COleDateTime &otmSenTime, long lTimeOut); 
 
	//用途:创建队列 
	//in :	strFormatName   -- 队列格式名字。eg: "Direct=OS:Airlink\\Private$\\Test" 
	//BOOL CreateQueue(CString strFormatName); 
 
	//用途:删除队列 
	//in :	strFormatName   -- 队列格式名字。eg: "Direct=OS:Airlink\\Private$\\Test" 
	//BOOL DeleteQueue(CString strFormatName); 
private: 
	IMSMQQueuePtr m_QueueRead;//读队列对象指针 
	IMSMQQueuePtr m_QueueWrite;//写队列对象指针 
	IMSMQQueueInfoPtr m_QueueReadInfo; 
	IMSMQQueueInfoPtr m_QueueWriteInfo; 
}; 
#endif // !defined(AFX_COMQUEUE_H__E3F9FE80_E269_4EFA_B3F0_B92272B36CD6__INCLUDED_)