Jump to content

Recommended Posts

Posted

I had a need to play a little "Locale" game today, and saw in MS documentation the GetLocaleInfoEx function. but no luck finding it, not even mentioned a single time here on the forums.

is there a good reason why it's not already in WinApiLocale.au3 ?

This is not bashing on anyone for their oversight, just curious really.

Also does not seem to be in WinAPIEx.au3.

There are others similar functions missing.

Oh, and I would contribute if I only had the ability... :(

Thanks to contributors to WinAPI and related for what you have already done.!

I am just a hobby programmer, and nothing great to publish right now.

Posted

John, understood. So anything that is "Non-XP" functions are not put into an official UDF.

I like the policy, especially because having a lot of functions that are "non-XP" would be a support nightmare.

Thanks for the tip, I ended up using just that one - and the pre-made LCID table from Microsoft.

I am just a hobby programmer, and nothing great to publish right now.

Posted

It's normally the case that UDFs created a few years ago aren't maintained 100%, so you'll find that more recent functionality is missing. I find this happening quite often with additional constants to controls etc.

Implementing GetLocaleInfoEx isn't easy though, it gets a little tricky when the return value isn't actually a string. If you want something to work off then this is my very quickly typed out basic implementation based on the MSDN signature. As normal absolutely no guarantee this code will even run. 

Func _WinAPI_GetLocaleInfoEx($sLocaleName, $LCType)
    Local $aResult = DllCall("kernel32.dll", "int", "GetLocaleInfoEx", "wstr", $sLocaleName, "DWORD", $LCType, "wstr", "", "int", 32768)
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[3]
EndFunc   ;==>_WinAPI_GetLocaleInfoEx

If you do get it working then make sure to submit a trac request so it gets tested and included in the next round of betas.

Posted

Func _WinAPI_GetLocaleInfoEx($sLocaleName, $LCType)
    Local $aResult = DllCall("kernel32.dll", "int", "GetLocaleInfoEx", "wstr", $sLocaleName, "DWORD", $LCType, "wstr", "", "int", 32768)
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[3]
EndFunc   ;==>_WinAPI_GetLocaleInfoEx

If you do get it working then make sure to submit a trac request so it gets tested and included in the next round of betas.

 

It works.

_winapi_getlocaleinfoex("en-US", 4)  
Returns "English"

as it's supposed to.

I prefer not to make a trac request right now, as I can use your template to create more. Starting to get the idea of how.

MSDN is not easy to ready though, as it never gives values of constants or any examples. :(

I am just a hobby programmer, and nothing great to publish right now.

Posted

I think this might cover all cases. I don't know much about locale stuff so it'll need a bit more testing.

#include <WinAPILocale.au3>


Global Const $LOCALE_RETURN_NUMBER = 0x20000000

$ret = _WinAPI_GetLocaleInfoEx("en-US", BitOR($LOCALE_ICALENDARTYPE, $LOCALE_RETURN_NUMBER))
MsgBox(0, $ret, @error & @CRLF & @extended)


Func _WinAPI_GetLocaleInfoEx($sLocaleName, $LCType)
    Local $aResult

    If BitAND($LCType, $LOCALE_RETURN_NUMBER) Then
        $aResult = DllCall("kernel32.dll", "int", "GetLocaleInfoEx", "wstr", $sLocaleName, "DWORD", $LCType, "DWORD*", "", "int", 2)
    Else
        $aResult = DllCall("kernel32.dll", "int", "GetLocaleInfoEx", "wstr", $sLocaleName, "DWORD", $LCType, "wstr", "", "int", 32768)
    EndIf
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[3]
EndFunc   ;==>_WinAPI_GetLocaleInfoEx

The best place for finding constants, unless you have the windows headers installed, is http://pinvoke.net/ it's pretty good and if you search for the function instead of the constant (so like GetLocaleInfoEx) you'll get the full list of required constants (hopefully).

Hope that helps!

Matt

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...