Code Listing 4: 16-Bit Code (Access 2 and VB 3) for Getting/Setting the Short Date Format
Declarations SectionDeclare Function GetProfileString Lib "KERNEL" _
(ByVal strSection As String, ByVal strKeyName As String, _
ByVal strDefault As String, ByVal strReturned As String, _
ByVal intSize As Integer) As Integer
Declare Function WriteProfileString Lib "KERNEL" _
(ByVal strSection As String, ByVal strKeyName As String, _
ByVal strValue As String) As Integer
Function SetCurrentShortDate (strIn As String) As String
' Comments : Sets the control panel short date setting
' Parameters: strIn - format to use, e.g. mm/dd/yyyy
' Returns : new value or <error>
Dim fOK As Integer
fOK = WinINIWriteSetting_Y2K("intl", "sshortdate", strIn)
If fOK Then
SetCurrentShortDate = strIn
Else
SetCurrentShortDate = "<error>"
End If
End Function
Function ShowCurrentShortDate_Y2K () As String
' Comments : Returns the current control panel short date setting
' Parameters: none
' Returns : string
ShowCurrentShortDate_Y2K = WinINIGetSetting_Y2K("intl", "sshortdate")
End Function
Function WinINIGetSetting_Y2K (strSection As String, strKeyName As String) _
As String
' Comments : Returns a string value from the WIN.INI file
' Parameters: strSection - name of the section to look in
' strKeyName - name of the key to look for
' Returns : string value
'
Dim strBuffer As String * 256
Dim intSize As Integer
intSize = GetProfileString(strSection, strKeyName, "", strBuffer, 256)
WinINIGetSetting_Y2K = Left$(strBuffer, intSize)
End Function
Function WinINIWriteSetting_Y2K (strSection As String, _
strKeyName As String, strValue As String) As Integer
' Comments : writes the specified value to WIN.INI
' Parameters: strSection - section to write into
' strKeyName - key to write into
' strValue - value to write
' Returns : True if successful, False otherwise
'
Dim intStatus As Integer
intStatus = WriteProfileString(strSection, strKeyName, strValue)
WinINIWriteSetting_Y2K = (intStatus <> 0)
End Function
|