正好,前段时间做过一个小程序,是关于这方面的
首先引入MSMQ的类型库,就会产生一些控件在Active里
发:
procedure TForm1.Button1Click(Sender: TObject);
var
MSMQQInfo: Variant;
begin
MSMQQInfo := CreateOleObject('MSMQ.MSMQQueueInfo');
MSMQQInfo.PathName := './private$/Test';
try
MSMQQInfo.Create; //出错误提示信息
except
end;
MSMQQueueInfo1.PathName := './private$/Test';
MSMQQueueInfo1.Label_ :='ss';
MSMQMessage1.Label_ := 'bb';
MSMQMessage1.Body := 'kk';
msmqqueue1.ConnectTo(MSMQQueueInfo1.Open(MQ_SEND_ACCESS, 0));
MSMQMessage1.Send(MSMQQueueInfo1.Open(MQ_SEND_ACCESS, MQ_DENY_NONE));
end;
收:
procedure TForm1.Button4Click(Sender: TObject);
begin
msmqqueueinfo1.PathName := './private$/Test'';
msmqqueue1.Disconnect;
msmqqueue1.ConnectTo(msmqqueueinfo1.Open(1, 0));
msmqqueue1.EnableNotification(MSMQEvent1.DefaultInterface);
end;
处理:
procedure TForm1.MSMQEvent1Arrived(Sender: TObject; var Queue: OleVariant;
Cursor: Integer);
var
Msg: Variant;
ss: string;
begin
Msg := Queue.Receive;
ss:= Msg.body;
// 处理程序
end;
你看够不够用?
:)