Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locale Aware Question (App check time format?)

Status
Not open for further replies.

cyberbiker

Programmer
Joined
Mar 16, 2001
Messages
431
Location
US
I am not locating any information in my searching so please bear with me.

I am looking for a way to determine the system time format from my app at run time

I want to set a maskededit control format property and mask property when my app starts depending on the sytem settings.

Simply, if the system time uses the 24 hour clock I want set the masked edit box properties one way and if they use the usual American practice of AM/PM then I will set the masked edit properties another way.

Any advice to aimme the right direction would be appreciated.

Terry (cyberbiker)
 
You can use GetLocaleInfo API, by using the appropriate LCTYPE you can get all sorts of stuff.

Here is some sample code encapsulating the API

Public Declare Function GetLocaleInfo Lib "kernel32" _
Alias "GetLocaleInfoA" _
(ByVal Locale As Long, _
ByVal LCType As Long, _
ByVal lpLCData As String, _
ByVal cchData As Long) As Long

Public Declare Function GetUserDefaultLCID Lib "kernel32" () As Long

Public Function f_GetUserLOCALEinfo(ll_Type As Long) As String

Dim ll_LocaleID As Long
Dim ll_Return As Long

ll_LocaleID = GetUserDefaultLCID()

ll_Return = GetLocaleInfo(ll_LocaleID, ll_Type, f_GetUserLOCALEinfo, Len(f_GetUserLOCALEinfo))

If ll_Return Then
f_GetUserLOCALEinfo = Space(ll_Return)
ll_Return = GetLocaleInfo(ll_LocaleID, ll_Type, f_GetUserLOCALEinfo, Len(f_GetUserLOCALEinfo))
If ll_Return Then
f_GetUserLOCALEinfo = Left$(f_GetUserLOCALEinfo, ll_Return - 1)
Else
MsgBox "Error ???"
End If
Else
MsgBox "Error ???"
End If

End Function


Dim ls_DateString As String
Dim ls_TimeString As String

Const LOCALE_SHORTDATE = &H1F
Const LOCALE_STIMEFORMAT = &H1003

ls_DateString = f_GetUserLOCALEinfo(LOCALE_SHORTDATE)
ls_TimeString = f_GetUserLOCALEinfo(LOCALE_STIMEFORMAT)





 
Thank you very much.
I was thinking I would need to usa an API Call, but had no idea which one.


Terry (cyberbiker)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top