使用MQ传输结构体信息

使用MQ传输结构体信息

5

忙了一个星期终于搞掂了,心情顺畅,以此志之。

代码如下:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;

type
MQDataInfo = record
ID : Integer;
Name : PAnsiChar;
Value : PAnsiChar;
Image : TBitmap;
end;
PMQDataInfo = ^MQDataInfo;

type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
LabeledEdit1: TLabeledEdit;
LabeledEdit2: TLabeledEdit;
LabeledEdit3: TLabeledEdit;
Button2: TButton;
Button3: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

uses MQI;

const
QM_NAME : MQCHAR48 = 'MyTest'#0;
QUEUE_NAME : MQCHAR48 = 'Test001'#0;

procedure TForm1.Button1Click(Sender: TObject);
var
Hconn : MQHCONN;
Hobj : MQHOBJ;
ConnectOpts : MQCNO;
QMgrName : MQCHAR48;
ObjDesc : MQOD;
Options, CompCode, Reason : MQLONG;
Buffer : MQDataInfo; //PAnsiChar;//Array[0..1024000] of Byte;
BufferLength : Integer;
MsgDesc : MQMD;
PutMsgOptions : MQPMO;
begin
QMgrName := QM_NAME;
ConnectOpts := MQCNO_DEFAULT;

MQCONNX ( @QMgrName, @ConnectOpts, @HConn, @Compcode, @Reason);

if CompCode <> MQCC_OK then
begin
Self.Memo1.Lines.Add('Connect Failed');
end
else
begin
Self.Memo1.Lines.Add('Connected successed');
end;

Options := MQOO_FAIL_IF_QUIESCING + MQOO_OUTPUT;
ObjDesc := MQOD_DEFAULT;
ObjDesc.ObjectName := QUEUE_NAME;

MQOPEN (HConn, @ObjDesc, Options, @HObj, @Compcode, @Reason );

if CompCode <> MQCC_OK then
begin
Self.Memo1.Lines.Add('Open Failed');
end
else
begin
Self.Memo1.Lines.Add('Open Successed');
end;

MsgDesc := MQMD_DEFAULT;

请问如何设定ip呢

请问如何设定ip呢

Posted by 游侠 (未验证) on 周四, 01/10/2008 - 10:42