简体   繁体   中英

How do I use IMultiLanguage2 in Delphi XE2?

I am in need of an idiot's guide for how to use the IMultiLanguage2 interface from Delphi XE2, with 32-bit VCL applications.

So far I have found MLANG.IDL in the RAD Studio include\\windows\\sdk\\idl folder, and verified that my OS has the mlang.dll file in SysWOW64.

I have also managed to create a MLANG.TLB file using MIDL.exe on MLANG.IDL (do I need this step?) but I cannot import the TLB into XE2 because it does not appear in the 'registered' list. Nor do I want to try to register it because I do not want to create a dependency on other than mlang.dll. TLibImp will not open mlang.dll.

I have looked at GenTLB (which does not open MLANG.IDL) and read a lot of the EMB Docwiki on using type libraries, including the statement "Type libraries on RAD Studio use RIDL instead of IDL". What is the purpose of the huge folder of IDL files installed with XE2, then? Since they are in an include folder, are they only for use with C++ and not for Delphi?

If you already have the type library in binary .tlb format then you can import it by clicking the "Add" button in the "Import Component" dialog - this will let you browse for the .tlb file and should generate a Delphi unit with the declarations.

Alternatively, you can use the tlibimp command line tool, eg:

tlibimp -P mlang.tlb

A quick usage example:

uses
  MultiLanguage_TLB;

var
  M: IMultiLanguage2;
  C: Cardinal;
begin
  M := CreateComObject(CLASS_CMultiLanguage) as IMultiLanguage2;
  OleCheck(M.GetNumberOfCodePageInfo(C));
  ShowMessage(Format('GetNumberOfCodePageInfo: %d', [C]));
end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM