Mega Code Archive

 
Categories / Delphi / API
 

Defining primarylangid[], sublangid[], and makelangid[] macros

Question: How can I define the PRIMARYLANGID(), SUBLANGID() and MAKELANGID() macros that are used with the Windows API functions that accept language identifiers? Answer: The follow example demonstrates functional equivalents for the PRIMARYLANGID(), SUBLANGID(), and MAKELANGID() macros. function PRIMARYLANGID(lgid : Word) : LongInt; begin result := lgid and $3FF; end; function SUBLANGID(lgid : Word) : LongInt; begin result := lgid shr 10; end; function MAKELANGID(sPrimaryLanguage : Word; sSubLanguage : Word) : Word; begin result := (sSubLanguage shl 10) or sPrimaryLanguage; end;