[ActiveLock-Development] CVS: alutil INIFile.cls,1.1,1.2
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2003-11-03 06:03:54
|
Update of /cvsroot/activelock/alutil In directory sc8-pr-cvs1:/tmp/cvs-serv25350 Modified Files: INIFile.cls Log Message: Allow INI key values to have max length of 2048 bytes Index: INIFile.cls =================================================================== RCS file: /cvsroot/activelock/alutil/INIFile.cls,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- INIFile.cls 19 Aug 2003 04:45:58 -0000 1.1 +++ INIFile.cls 3 Nov 2003 06:03:51 -0000 1.2 @@ -16,7 +16,7 @@ ' /////////////////////////////////////////////////////////////////////// ' / Filename: INIFile.cls / ' / Version: 1.0.0.1 / -' / Purpose: Stores and retrives product keys / +' / Purpose: INI File Class / ' / Klaus H. Probst [kp...@vb...] / ' / / ' / Date Created: ???? ??, ???? - KHP / @@ -46,6 +46,14 @@ ' advance to obtain my express permission. ' ' +'* /////////////////////////////////////////////////////////////////////// +' / MODULE CHANGE LOG / +' /////////////////////////////////////////////////////////////////////// +' @history +' <pre> +' 11.02.03 - th2tran - Allow key values to have max length of 2048 bytes +' </pre> + ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// @@ -65,6 +73,8 @@ Private m_LastError As String ' Last error message +Private Const VALUE_MAX_LEN As Long = 2048 + ' ' Retrieves a value from the passed key (ValueName) and returns it as a variant ' (String subtype). This proc is useful if your requirements go above that of the @@ -76,10 +86,10 @@ Public Function GetValue(ByVal ValueName As String, Optional ByVal Default As String, Optional ByRef Failed As Boolean) As Variant Dim sBuffer As String Dim lReturn As Long - + m_LastError = "" ' reset error message - - sBuffer = String$(255, vbNullChar) + + sBuffer = String$(VALUE_MAX_LEN, vbNullChar) lReturn = GetPrivateProfileString(m_sSection, ValueName, Default, sBuffer, Len(sBuffer), m_sFileName) If lReturn > 0 Then @@ -137,7 +147,7 @@ On Error GoTo catch iCounter = -1 '// preset this - lBuffSize = 1024 '// start out with 2048 bytes + lBuffSize = VALUE_MAX_LEN '// start out with 2048 bytes Do lBuffSize = (lBuffSize * 2) lBuffSize = lBuffSize - 1 '// otherwise we overflow 32767 @@ -165,7 +175,7 @@ Else ReDim Preserve asEnumKeys(0 To iCounter) End If - + 'pull up to the first Null sValuePair = Mid$(sBuffer, 1, InStr(sBuffer, vbNullChar) - 1) If Len(sValuePair) > 0 Then @@ -173,9 +183,9 @@ If iDelim > 0 Then asEnumKeys(iCounter) = Left$(sValuePair, iDelim - 1) End If - + End If - + 'trim the string to the next null sBuffer = Mid$(sBuffer, InStr(sBuffer, vbNullChar) + 1) iCounter = iCounter + 1 @@ -221,7 +231,7 @@ 'Debug.Assert 0 On Error GoTo catch iCounter = -1 - lBuffSize = 1024 '// start out with 2048 bytes + lBuffSize = VALUE_MAX_LEN '// start out with 2048 bytes Do lBuffSize = (lBuffSize * 2) lBuffSize = lBuffSize - 1 '// otherwise we overflow 32767 @@ -257,7 +267,7 @@ asEnumValues(iCounter) = Right$(sValuePair, (Len(sValuePair) - iDelim)) End If End If - + 'trim the string to the next null sBuffer = Mid$(sBuffer, InStr(sBuffer, vbNullChar) + 1) iCounter = iCounter + 1 @@ -303,7 +313,7 @@ 'Debug.Assert 0 On Error GoTo catch iCounter = -1 - lBuffSize = 1024 '// start out with 2048 bytes + lBuffSize = VALUE_MAX_LEN '// start out with 2048 bytes Do lBuffSize = (lBuffSize * 2) lBuffSize = lBuffSize - 1 '// otherwise we overflow 32767 @@ -329,14 +339,14 @@ Else ReDim Preserve asEnumSections(0 To iCounter) End If - + 'pull up to the first Null sValue = Mid$(sBuffer, 1, InStr(sBuffer, vbNullChar) - 1) If Len(sValue) > 0 Then asEnumSections(iCounter) = sValue - + End If - + 'trim the string to the next null sBuffer = Mid$(sBuffer, InStr(sBuffer, vbNullChar) + 1) iCounter = iCounter + 1 @@ -389,7 +399,7 @@ ' Public Function EnumSectionValuePairs(ByRef ArrayResult As Variant) As Integer On Error GoTo catch - + Dim sBuffer As String Dim lReturn As Long Dim sValuePair As String @@ -403,7 +413,7 @@ 'Debug.Assert 0 On Error GoTo catch iCounter = -1 - lBuffSize = 1024 '// start out with 2048 bytes + lBuffSize = VALUE_MAX_LEN '// start out with 2048 bytes Do lBuffSize = (lBuffSize * 2) lBuffSize = lBuffSize - 1 '// otherwise we overflow 32767 @@ -443,7 +453,7 @@ arrEnumValues(iCounter) = Right$(sValuePair, (Len(sValuePair) - iDelim)) End If End If - + 'trim the string to the next null sBuffer = Mid$(sBuffer, InStr(sBuffer, vbNullChar) + 1) iCounter = iCounter + 1 @@ -488,7 +498,7 @@ Dim lReturn As Long Dim sDefault As String - szBuffer = String$(255, vbNullChar) + szBuffer = String$(VALUE_MAX_LEN, vbNullChar) sDefault = "" lReturn = GetPrivateProfileString(m_sSection, ValueName, sDefault, szBuffer, Len(szBuffer), m_sFileName) |