UltimaWeapon
UltimaWeapon

Reputation: 2660

How to localize COM classes?

I'm in trouble with localize my COM classes. I don't known how to localize IErrorInfo and other text in standard way. I have searched but found nothing. My COM classes is IUnknown interface, not dual interfaces.

Thanks for advance.

Upvotes: 0

Views: 73

Answers (1)

Euro Micelli
Euro Micelli

Reputation: 33998

There is no "COM-standard" mechanism to provide a localization locale to a COM object.

COM is arguably too "low-level" for that. Automation conceptually sits a layer above COM and so IDispatch's Invoke does provide an LCID argument; but even with [dual] interfaces, the standard implementation of IDispatch (CreateStdDispatch et al) doesn't pass the LCID down to the called method.

(However, will the standard implementation provide the LCID if a method has an [lcid]-marked parameter? I don't know first hand, but it's implied so here).

You will need to provide your own mechanism. I don't know what would be the most appropriate mechanism for your object. Some ideas:

  • You could have all your methods take an explicit LCID parameter that the client has to fill-in. I would go ahead and mark the parameter with [lcid] and follow the rules in the MSDN documentation.
  • You could have a SetLanguage() method that sets an object-wide language stored in the instance and which controls the language used by your messages.
  • You could rely on the default system locale.

Upvotes: 1

Related Questions