Jump to content

How to use "setLocaleInfo" to change date format in XP


Recommended Posts

Hi There,

I have tried using the registry method but it does not refresh the system immediately.

I need to change the date format for about 2000 computers.

Found this "setLocaleInfo" on Microsoft website but do not know how to use it in Autoit. Please advise.

http://msdn.microsoft.com/en-us/library/aa913806.aspx

Thanks in advanced.

Link to comment
Share on other sites

Your link is to the wrong version (WinCE). The correct one is on MSDN: SetLocaleInfo Function.

Yashied's WinAPIEx UDF has a _WinAPI_GetLocaleInfo(), but not the coresponding _WinAPI_SetLocaleInfo(). :)

You'll have to roll your own.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

#Include <WinAPIEx.au3>

Global Const $LOCALE_INVARIANT = 0x007F
Global Const $LOCALE_SYSTEM_DEFAULT = 0x0800
Global Const $LOCALE_USER_DEFAULT = 0x0400

Global Const $LOCALE_CUSTOM_DEFAULT = 0x0C00
Global Const $LOCALE_CUSTOM_UI_DEFAULT = 0x1400
Global Const $LOCALE_CUSTOM_UNSPECIFIED = 0x1000

_WinAPI_SetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE, 'dd-MMM-yy')

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_SetLocaleInfo
; Description....: Sets an item of information in the user override portion of the current locale.
; Syntax.........: _WinAPI_SetLocaleInfo ( $LCID, $iType, $sData )
; Parameters.....: $LCID   - Locale identifier for which to set information.
;                  $iType  - Type of locale information to set. This parameter can be one of the $LOCALE_... constants.
;                  $sData  - The string containing the locale information to set. The information must be in the format specific to
;                            the specified constant.
; Return values..: Success - 1.
;                  Failure - 0 and sets the @error flag to non-zero.
; Author.........: Yashied
; Modified.......:
; Remarks........: None
; Related........:
; Link...........: @@MsdnLink@@ SetLocaleInfo
; Example........: Yes
; ===============================================================================================================================

Func _WinAPI_SetLocaleInfo($LCID, $iType, $sData)

    Local $Ret = DllCall('kernel32.dll', 'int', 'SetLocaleInfoW', 'long', $LCID, 'int', $iType, 'wstr', $sData)

    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_SetLocaleInfo

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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