MAKELANGID

  • Thread starter Thread starter Howard Kaikow
  • Start date Start date
H

Howard Kaikow

In C++, one can use the MAKELANGID macro from Winnt.h.

Can that be used in C#?
 
Since there are no macros in C#, and since you can view the winnt.h
file...
why didn't you create methods like this:

/*
A language ID is a 16 bit value which is the combination of a
primary language ID and a secondary language ID. The bits are
allocated as follows:

+-----------------------+-------------------------+
| Sublanguage ID | Primary Language ID |
+-----------------------+-------------------------+
15 10 9 0 bit


Language ID creation/extraction macros:

MAKELANGID - construct language id from a primary language id
and
a sublanguage id.
PRIMARYLANGID - extract primary language id from a language id.
SUBLANGID - extract sublanguage id from a language id.


#define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))
#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
#define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
*/

public ushort MAKELANGID(byte primaryLanguage, byte subLanguage)
{
return (ushort)((((ushort)subLanguage) << 10) |
(ushort)primaryLanguage);
}

public byte PRIMARYLANGID(ushort languageId)
{
return (byte)(languageId & 0x3ff);
}

public byte SUBLANGID(ushort languageId)
{
return (byte)(languageId >> 10);
}

Eyal.
 
Howard said:
In C++, one can use the MAKELANGID macro from Winnt.h.

Can that be used in C#?

You cannot use the macro per se, but you easily reuse the macro's C++
expression in C#.

Cheers,
 
Eyal said:
How do you reuse C++ macros in C#?

Eyal.

Eyal,

quoting helps keeping a post in context. Also, read what I actually
wrote:

"[...] you easily reuse the macro's C++ *expression* in C#."

Which is exactly what you did in your reply.

Cheers,
 
Eyal Safran said:
How do you reuse C++ macros in C#?

Not the macro - the macro *expression*. Basically translating it into
C#, as you did in your other post on this thread.
 
Back
Top