Once upon a time, I talked about a Win32 API which was entirely broken. Well, I'm here to report that I found another one which is broken, but in a much more subtle way. No crashes. No machine melting. Just not useful.
The GetGeoInfo API is meant to get you information about a geographical location. You can enumerate over these locations using another API, which gives you a unique 32-bit ID for the location, which you can then pass into this API.
You can call this API, asking for different pieces of data (much like other Win32 APIs, such as GetSystemMetrics or SystemParametersInfo), including everything you see here. At this point, I should make a note that up until very recently (within the last few months), the documentation for timezones and official languages did not say "unsupported." So that's strike one and strike two against the API -- it would have been awesome to be able to put in the GeoID for something like the US and get back all of the timezones which the US spans. Or put in Canada, and get the official languages for the entire country. But alas, those don't work.
But wait, there are other cool things you can get from this! For instance, you can get locale information via the LCID enumeration. Once given this, you can use the GetLocaleInfo API to get information such as the currency symbol, names of days and months, etc. That's some very useful information -- this way the user can input what country they're in and you can find the country in the list of GeoIDs and grab information for your calendar control.
Except for the fact that the LCID that comes back is based off the language ID passed into the GetGeoInfo API. This essentially makes it worthless since you'd have to know the LANGID already going into the call -- but how do you know what the language is for a country with multiple official languages? If you fail to provide the LANGID, then it defaults to the user's default locale ID. So every GeoID returns to you information that's the default for your system. So for me, Botswana gleefully tells me everything I want to know about the United States' locale information. Rawr.
The LCID isn't the only thing affected by the LANGID stupidity. The RFC1766 ID is also affected. This is the ID which creates a language-locale identifier, which you are probably used to seeing. For instance, the US would be en-US. However, if you don't pass in the proper LANGID, then the user's default language is assumed. So I could be getting en-FR using the GeoID for France. This sort of makes sense, but is still a pitfall since it requires up-front knowledge about the language you're wondering about.
So while this API isn't a total loss (You can use it to get the official name of a geographical location -- wahoo!), it certainly is a downer. I'd claim it's essentially broken, and certainly one that you don't want to rely on for any of your applications.
Do you ever feel really let down when some little MS thing blows up in your face?
I've never felt the need to defend Microsoft before starting to use RB.
I was always the outsider - the unix guy.
Then you could just say, "Oh well - bl**dy M$oft again."
Then you find you're part of a minority that has a history of making great stuff on Win32 and you realize that a lot of the criticism really isn't fair and that people around you believe it's much more true than it really is.
And then something bites you.
And *that's* when you find you don't have the cynicism to fall back on any more. Bl**dy Microsoft. Friend or foe they bite just as hard.
Not really -- I mean, sure, it's always annoying when you stumble across bugs in any product. But I don't get let down or angry. I'm in a rather unique position that in my professional career I design a tool for programmers. So I understand just how crazy and complex it can be to get things perfect for everyone.
I've found bugs in the MS, GTK and Apple APIs, as well as compiler bugs with VS 6, VS.NET, gcc and Code Warrior. They happen with a relative frequency and I guess I've just gotten used to running into them. Like any software developer, I find a way around the issue and move on (after reporting the bug, of course).
Whether you love Microsoft or hate Microsoft, I think we can all agree that they can write software about 30,000 times better than IBM. Take one look at Lotus Notes, and pray to God that OS/2 didn't win the 32-bit OS wars.
Still on your Lotus Note tirade James? I thought that software died in the 90s... :-P
This discussion wasn't meant to be about software reliability but dev tools.
IBM today isn't the same as it used to be -- at least not in their developer tools division. A lot of tools in their alphaWorks and developerWorks programs have been quite innovative and high quality. Their Smalltalk tools weren't bad.