shay has asked for the wisdom of the Perl Monks concerning the following question:
Here's the program that I thought would give me the answer:
use strict; use warnings; use Win32::API; Win32::API->Import('kernel32.dll', 'LANGID GetSystemDefaultLangID()') +or die "Can't import GetSystemDefaultLangID: $^E\n"; my $langid = GetSystemDefaultLangID(); if (defined $langid) { print "Returned '$langid'\n"; printf "Lang ID: 0x%04X\n", $langid; } else { print "Returned <undef>\n"; }
However, when I run this it just outputs:
Returned <undef>
The function itself works fine from a simple C program:
#include <stdio.h> #include <windows.h> #include <winnls.h> void main(void) { printf("Lang ID = 0x%04X\n", GetSystemDefaultLangID()); }
and similar Perl Win32::API programs involving other Win32 API functions also work fine, e.g.
use strict; use warnings; use Win32::API; Win32::API->Import('kernel32.dll', 'DWORD GetCurrentProcessId()') or die "Can't import GetCurrentProcessId: $^E\n"; my $procid = GetCurrentProcessId(); if (defined $procid) { print "Returned '$procid'\n"; } else { print "Returned <undef>\n"; }
Where can I have gone wrong with something so simple, or is this a bug in Win32::API?
- Steve
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to call GetSystemDefaultLangID() with Win32::API
by NetWallah (Canon) on Jun 23, 2004 at 15:29 UTC | |
by shay (Beadle) on Jun 23, 2004 at 16:11 UTC | |
by NetWallah (Canon) on Jun 23, 2004 at 18:39 UTC | |
by shay (Beadle) on Jun 24, 2004 at 12:34 UTC | |
by BrowserUk (Patriarch) on Jun 23, 2004 at 20:58 UTC | |
|
Re: How to call GetSystemDefaultLangID() with Win32::API
by BrowserUk (Patriarch) on Jun 23, 2004 at 15:38 UTC | |
|
Re: How to call GetSystemDefaultLangID() with Win32::API
by slloyd (Hermit) on Jun 23, 2004 at 20:44 UTC | |
by NetWallah (Canon) on Jun 24, 2004 at 17:34 UTC |