in reply to Re^2: How to call GetSystemDefaultLangID() with Win32::API
in thread How to call GetSystemDefaultLangID() with Win32::API

OK - since this is a SHORT, you need to mask out the high-order bytes for this to make sense.

The following code DOES produce the expected "1033" value for English:

use strict; use warnings; use Win32::API; Win32::API->Import('kernel32.dll', 'long GetSystemDefaultLangID()') or die "Can't import GetSystemDefaultLangID: $^E\n"; my $langid = GetSystemDefaultLangID() & 0xFFFF # Mask out the garbage + in high-order bytes or die "ERROR: LANGID Returned <undef>\n"; print "Returned '$langid'\n"; printf "Lang ID: 0x%04X\n", $langid; # Print output---- # Returned '1033' # Lang ID: 0x0409

Earth first! (We'll rob the other planets later)

Replies are listed 'Best First'.
Re^4: How to call GetSystemDefaultLangID() with Win32::API
by shay (Beadle) on Jun 24, 2004 at 12:34 UTC
    Thanks for that.

    So is this a bug in Win32::API, then? It seems that it doesn't correctly handle functions returning WORD's. Pretending that I want a DWORD and then masking off the high WORD that I didn't actually want seems like a rather awkward way of doing things.