Thursday, January 11, 2007

Delphi/C++Builder 2006 Import ActiveX Control Update

A bug was recently found when importing the Microsoft Message Queue 3.0 Object Library type library contained in the DLL mqoa.dll. When calling ITypeInfo.GetDocumentation we would fail with the error TYPE_E_ELEMENTNOTFOUND. It turns out that even though the documentation states that ITypeInfo.GetDocumentation can be called with NULL as the last four parameters that in some cases methods that don't contain a help string such as the case with the method IMSMQManagement.TransactionalStatus, NULL is required. Here is the IDL of the interface as seen from OLE View:

interface IMSMQManagement : IDispatch
[id(00000000), helpstring("Method to initialize the MSMQManagement
[in, optional] VARIANT* Machine,
[in, optional] VARIANT* PathName,
[in, optional] VARIANT* FormatName);
[id(0x00000001), propget, helpstring("Property that identifies the queue.
The format name of a queue is generated by MSMQ when the queue is created, or
generated later by the application."
HRESULT FormatName([out, retval] BSTR* pbstrFormatName);
[id(0x00000002), propget, helpstring("Property returning the name of the
relevant machine."
HRESULT Machine([out, retval] BSTR* pbstrMachine);
[id(0x00000003), propget, helpstring("Property returning the number of
messages in a queue."
HRESULT MessageCount([out, retval] long* plMessageCount);
[id(0x00000004), propget, helpstring("Property indicating that the
queue is known to be foreign, that it is known not to be foreign,
or that its status in this regard is unknown."
HRESULT ForeignStatus([out, retval] long* plForeignStatus);
[id(0x00000005), propget, helpstring("Property indicating the type of a
HRESULT QueueType([out, retval] long* plQueueType);
[id(0x00000006), propget, helpstring("Property indicating whether the
queue resides on the local machine."
HRESULT IsLocal([out, retval] VARIANT_BOOL* pfIsLocal);
[id(0x00000007), propget]
HRESULT TransactionalStatus([out, retval] long* plTransactionalStatus);
[id(0x00000008), propget, helpstring("Property indicating the amount of
storage used for the queue."
HRESULT BytesInQueue([out, retval] VARIANT* pvBytesInQueue);

So now the code has been changed from:

OleCheck(FParent.FTypeInfo.GetDocumentation(FuncDesc.memid, @Name, @HelpString,
@FHelpContext, nil));

To the slightly more complicated:

Check := FParent.FTypeInfo.GetDocumentation(FuncDesc.memid, @Name, @HelpString,
@FHelpContext, nil);

OleCheck(FParent.FTypeInfo.GetDocumentation(FuncDesc.memid, @Name, nil,
nil, nil));

If you are getting an "element not found" error when using the Microsoft Message Queue 3.0 Object Library type library then you can download an unofficial update of tlib100.bpl here.


Worry said...

What could be done for Delphi 7

Tzvika said...

What do you do with this bpl file?

Anonymous said...

Do you have a fix for RAD Studio 2007?

Chris Bensen said...

Sorry, I hadn't noticed there were comments. There isn't anything I can do for Delphi 7. The .bpl file needs to be dropped in the bin directory. Be sure to make a backup copy of the one there just in case. This was never a Delphi 2007 bug since it was fixed before that product shipped.

Post a Comment