Board index » delphi » Anyone having luck with using MSMQ typelib?

Anyone having luck with using MSMQ typelib?

Can you post what your LookupQueue method call looks like? I don't work with
MSMQ but know of a few quirks when calling other COM API functions that
perhaps I can help.

Jim

 

Re:Anyone having luck with using MSMQ typelib?


I think for the omitted parameters, that "unassigned" will not work. When
you omit a parameter in VB, VB behind the scenes puts in a special value to
indicate that the parameter is missing. I would assign your omitted t and
t1. parameters EmptyOleVar, defined like this:

function EmptyOleVar:OleVariant;
type
    TVarArg = array[0..3] of Integer;
    PVarArg = ^TVarArg;
var
    ArgPtr: PVarArg;
    AVariant:OleVariant;
begin
    ArgPtr         := @( AVariant );
    ArgPtr^[0]     := varError;
    ArgPtr^[2]     := DISP_E_PARAMNOTFOUND;
    result         := AVariant;
end;

Regards,
Jim
www.kamiak.com   Universal Data Access for Delphi

Re:Anyone having luck with using MSMQ typelib?


Hiall

I am trying to use Microsoft Message Queue Server's typelib to program it
with Delphi. However, I have rather quickly run into a problem: I can't get
the LookupQueue function to work. The error message I get in return is
"incorrect parameter". And the code should be rather simple since all I want
to supply it with is the Label param, and the rest should be null values. If
anyone has an idea about what I might be doing wrong or some working example
code .. I'd be sooo happy :) (and of course the code works in VB ... major
disappointment :(

Regards
 Mikael K.
 http://delphi.it.dtu.dk/delphi

Re:Anyone having luck with using MSMQ typelib?


This is my poor (and non-working) try (i've tried multiple other combinations
and values .. like supplying null instead and so on). Guess you have to lookup
the function for getting the knowledge to improve the code here :) .. ohwell any
attempt will be highly appreciated!

Regards
 Mikael K
http://delphi.it.dtu.dk/delphi

declaration:
    function LookupQueue(var QueueGuid: OleVariant; var ServiceTypeGuid:
OleVariant;
                         var Label_: OleVariant; var CreateTime: OleVariant;
                         var ModifyTime: OleVariant; var RelServiceType:
OleVariant;
                         var RelLabel: OleVariant; var RelCreateTime:
OleVariant;
                         var RelModifyTime: OleVariant): IMSMQQueueInfos;
safecall;

tryout code:

    query       :   MSMQQuery;
    qinfos      :   MSMQQueueInfos;
    qInfoDest   :   MSMQQueueInfo;
    qDest       :   MSMQQueue;
    msgSent     :   MSMQMessage;

    t,t1,t2,t3,t4,t5,t6,t7,t8,t9  :   OleVariant;
    s1,s2       :   OleVariant;
begin
 query:=COMSMQQuery.Create;
 t:=unassigned;
 t1:=unassigned;
 t2:='Destination';
 t3:=Now;
 t4:=Now;
 t5:=REL_NOP;
 t6:=REL_EQ;
 t7:=REL_NOP;
 t8:=REL_NOP;
 try
    qinfos:= query.LookupQueue(t,t1,t2,t3,t4,t5,t6,t7,t8);
 except
    on E : EOleException do
        begin
            ShowMessage(E.Message+','+IntToHex(E.ErrorCode,8));
        end;

ja...@kamiak.com skrev:

Quote
> Can you post what your LookupQueue method call looks like? I don't work with
> MSMQ but know of a few quirks when calling other COM API functions that
> perhaps I can help.

> Jim

Re:Anyone having luck with using MSMQ typelib?


In article <6otjqp$f6...@forums.borland.com>,

Quote
  <ja...@kamiak.com> wrote:
> I think for the omitted parameters, that "unassigned" will not work. When
> you omit a parameter in VB, VB behind the scenes puts in a special value to
> indicate that the parameter is missing. I would assign your omitted t and
> t1. parameters EmptyOleVar, defined like this:

> function EmptyOleVar:OleVariant;
> type
>     TVarArg = array[0..3] of Integer;
>     PVarArg = ^TVarArg;
> var
>     ArgPtr: PVarArg;
>     AVariant:OleVariant;
> begin
>     ArgPtr         := @( AVariant );
>     ArgPtr^[0]     := varError;
>     ArgPtr^[2]     := DISP_E_PARAMNOTFOUND;
>     result         := AVariant;
> end;

> Regards,
> Jim
> www.kamiak.com   Universal Data Access for Delphi

Alternately, using Variants allows you to use the VB style of arguments.
You lose typechecking though.

procedure TfrmSubscriberTester.Button1Click(Sender: TObject);
var
  rMSMQQuery: OleVariant;
  rMSMQQueueInfo: OleVariant;
  rMSMQQueueInfos: OleVariant;
  rMSMQQueue: OleVariant;
  rMSMQMessage: OleVariant;
begin
  rMSMQQuery := CoMSMQQuery.Create;

  rMSMQQueueInfos := rMSMQQuery.LookupQueue(Label:='MyOwnQueue');
  rMSMQQueueInfos.Reset;
  rMSMQQueueInfo := rMSMQQueueInfos.next;

  if varisEmpty(rMSMQQueueInfo) then
  begin
    rMSMQQueueInfo := CoMSMQQueueInfo.create;
    rMSMQQueueInfo.Pathname := 'QServer\MyOwnQueue';
    rMSMQQueueInfo.Label    := 'MyOwnQueue';
    rMSMQQueueInfo.create(true,true);
  end;

  rMSMQQueue := rMSMQQueueInfo.Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE);

  rMSMQMessage := rMSMQQueue.Receive;
  if not varisEmpty(rMSMQMessage) then
  begin
//  process message
  end;
end;

enjoy,
  Norman Lange
  nla...@atkin.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Other Threads