The .NET framework makes it easy to get information about various locales; the Win32 C++ APIs are a bit harder to figure out.
Is there an equivalent function in Win32 to get the two-letter ISO language name given an integer locale ID?
In C# I'd do:
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(1034);
string iso = ci.TwoLetterISOLanguageName;
// iso == "es" now.
The code needs to run on XP and newer.