tags:

views:

106

answers:

1

I thought I dug most of what I need out of the header files, but I keep crashing out.
Here is the declare I tried using, but I don't think it's just an issue of the declare. I think I'm actually using it wrong.

Private Declare Function GetLocaleInfoEx Lib "kernel32" ( _
ByVal lpLocaleName As Long, _
ByVal LCType As Long, _
ByRef lpLCData As Long, _
ByVal cchData As Long _
) As Long

Here is the corresponding documentation.
EDIT by MarkJ: Oorang wants to use GetLocaleInfoEx because the MSDN docs say it is preferred on Vista.

+1  A: 

EDIT: I couldn't test this because I don't have Vista here at home, but Oorang says it works (in the comments).

Private Declare Function GetLocaleInfoEx _
Lib "kernel32" ( _ 
  ByVal lpLocaleName As Long, _ 
  ByVal LCType As Long, _ 
  ByVal lpLCData As Long, _ 
  ByVal cchData As Long _ 
  ) As Long 

Const LOCALE_SMONTHNAME1 = 56&
Dim sLocaleName As String 
Dim sRetBuffer As String 
Dim nCharsRet As Long 
sLocaleName = "en-US" & Chr$(0) 
sRetBuffer = Space(256) 
nCharsRet = GetLocaleInfoEx(StrPtr(sLocaleName), _ 
  LOCALE_SMONTHNAME1, StrPtr(sRetBuffer), Len(sRetBuffer)-1)
MsgBox Left$(sRetBuffer, nCharsRet)

Your original Declare looked wrong to me. You are required to provide a buffer for the return string (wide characters, otherwise known as a UTF-16 Unicode string). You need to pass a pointer to the buffer in the lpLCData argument. So you need to declare that argument as ByVal Long and use StrPtr(string) where string has been filled with characters to make room for the return data.

MarkJ
Works in Vista. Thanks:)
Oorang