Skip Menu |

This queue is for tickets about the Win32-API CPAN distribution.

Report information
The Basics
Id: 6754
Status: resolved
Priority: 0/
Queue: Win32-API

People
Owner: Nobody in particular
Requestors: steve.hay [...] uk.radan.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 0.20
  • 0.40
  • 0.41
  • 0.46
  • 0.47
  • 0.48
  • 0.49
  • 0.50
  • 0.53
  • 0.54
  • 0.55
  • 0.56
  • 0.57
  • 0.58
  • 0.59
  • 0.60
  • 0.61
  • 0.62
  • 0.63
  • 0.64
  • 0.65
  • 0.66
  • 0.67
  • 0.68
Fixed in: 0.70_01



Subject: Problem with "SHORT" return types?
Hi, I have a problem using Win32::API to call a Win32 API function that returns a LANGID (which I believe, from the MS header files, is a WORD, i.e. a USHORT). It seems that if I specify LANGID (or WORD) in the prototype then the function returns the undefined value: ##### use Win32::API; Win32::API->Import('kernel32.dll', 'WORD 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"; } ##### The above program prints "Returned <undef>", rather than giving the expected output. In order to make the program work, I have to pretend that the return type is a DWORD and then mask off the high WORD which is otherwise full of garbage and spoils the result: ##### Win32::API->Import('kernel32.dll', 'DWORD GetSystemDefaultLangID()') or die "Can't import GetSystemDefaultLangID: $^E\n"; my $langid = GetSystemDefaultLangID() & 0xffff; ##### Also, I think that the entry in Win32::API::Types' __DATA__ section for LANGID is wrong -- it says 's', meaning a signed short, but I believe it should say 'S', meaning an unsigned short. This is using Win32-API-0.41 on WinXP/VC++ 6 with perl-5.8.4.
On Fri Jun 25 03:55:07 2004, SHAY wrote: Show quoted text
> > Also, I think that the entry in Win32::API::Types' __DATA__ section > for LANGID is wrong -- it says 's', meaning a signed short, but I > believe it should say 'S', meaning an unsigned short. > > This is using Win32-API-0.41 on WinXP/VC++ 6 with perl-5.8.4.
The problem turned out to be that S means Win32::API::Struct for a Win32::API object, not unsigned short. There was no letter code for short (the bug). The meaning of the letters couldn't be changed since that would break API. If you create a Win32::API::More object, S means unsigned short. Looking in the MS SDK headers, LANGID is a USHORT. I'm not sure whether LANGID should or shouldn't (API breakage for someone who wrote a script that works around the bug by using -ed constants) at this time.
This was fixed in 0.69, as described in my last post. 30 days no response, closing as resolved.