Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. function GetAllPrivateQueues( const aMachine : WideString; aStrL : TStrings) : HRESULT;
  2. // Returns a list of all private queues of a given machine
  3. type PPWideChar = ^PWideChar;
  4. var props : MQMGMTPROPS;
  5. keys : array[0..0] of MGMTPROPID;
  6. vals : array[0..0] of MQPROPVARIANT;
  7. ppws : PPWideChar;
  8. i : Integer;
  9. begin
  10. // Init Props
  11. props.cProp := 0;
  12. props.aPropID := @keys;
  13. props.aPropVar := @vals;
  14. props.aStatus := nil;
  15.  
  16. // we want private queues
  17. ASSERT( props.cProp < (SizeOf(keys) / SizeOf(PROPID)));
  18. keys[props.cProp] := PROPID_MGMT_MSMQ_PRIVATEQ;
  19. vals[props.cProp].vt := VT_NULL;
  20. Inc(props.cProp);
  21.  
  22. // MQMgmtGetInfo() has what we want, requires MSMQ 3.0
  23. result := MQMgmtGetInfo( PWideChar(aMachine), MO_MACHINE_TOKEN, props);
  24. if FAILED(result) then Exit;
  25.  
  26. // collect the names
  27. // cast required this way, the data type in ActiveX.pas (D7) is incorrect
  28. ppws := PPWideChar(vals[0].calpwstr.pElems);
  29. for i := 0 to vals[0].calpwstr.cElems-1 do begin
  30. aStrL.Add( ppws^);
  31. MQFreeMemory( ppws^);
  32. Inc(ppws);
  33. end;
  34. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement