本帖最后由 bcrun 于 2011-01-29 08:53:04 编辑

解决方案 »

  1.   

    sContent = sContent & TextLine & vbCrLf
    就你示例的代码而言,这行是效率低下的根本原因....
      

  2.   


     
    iFileName   =   App.path   &   "\test.ini " 
    '先在初始路径
     Public   Declare   Function   MWGetConfigInt   Lib   "kernel32 "   Alias   "GetPrivateProfileIntA "   (ByVal   lpApplicationName   As   String,   ByVal   lpKeyName   As   String,   ByVal   nDefault   As   Long,   ByVal   lpFileName   As   String)   As   Integer 
    Public   Declare   Function   GetPrivateProfileString%   Lib   "kernel32 "   Alias   "GetPrivateProfileStringA "   (ByVal   AppName$,   ByVal   KeyName$,   ByVal   keydefault$,   ByVal   ReturnString$,   ByVal   NumBytes   As   Integer,   ByVal   FileName$) 
    Public   Declare   Function   WritePrivateProfileString%   Lib   "kernel32 "   Alias   "WritePrivateProfileStringA "   (ByVal   AppName$,   ByVal   KeyName$,   ByVal   keydefault$,   ByVal   FileName$) Dim   iFileName   As   String '读入整数 
    Public   Function   ReadInteger(Section$,   Entry$,   Default%)   As   Integer 
            ReadInteger   =   MWGetConfigInt(Section$,   Entry$,   0,   iFileName) 
            If   ReadInteger   =   0   And   ReadInteger   <>   Default%   Then 
                WriteInteger   Section$,   Entry$,   Format$(Default%) 
                ReadInteger   =   Default% 
            End   If 
    End   Function '读入长整数 
    Public   Function   ReadLong(Section$,   Entry$,   ByVal   Default&)   As   Long 
            ReadLong   =   Val(ReadString(Section$,   Entry$,   Format(Default&))) 
            If   ReadLong   =   0   And   ReadLong   <>   Default&   Then 
                WriteLong   Section$,   Entry$,   Default& 
                ReadLong   =   Default& 
            End   If 
    End   Function '读入字符串 
    Public   Function   ReadString(Section$,   Entry$,   ByVal   Default$)   As   String 
    Dim   mzBuff   As   String   *   255,   nChars 
    Dim   Tmp   As   String 
    Dim   X,   Y   As   Integer         nChars   =   GetPrivateProfileString(Section$,   Entry$,   " ",   mzBuff,   255,   iFileName) 
            Tmp   =   IIf(nChars   >   0,   Left$(mzBuff,   nChars),   " ") 
            
            Y   =   InStr(Tmp,   Chr(0))   -   1 
            Y   =   IIf(Y   > =   0,   Y,   0) 
            
            ReadString   =   IIf(Y   > =   1,   Left(Tmp,   Y),   Tmp) 
            
            If   ReadString   =   " "   Then 
                  WriteString   Section$,   Entry$,   Default$ 
                  ReadString   =   Default$ 
            End   If 
    End   Function '写入整数 
    Public   Sub   WriteInteger(Section$,   Entry$,   ByVal   Default&) 
            WriteString   Section$,   Entry$,   Format$(Default&) 
    End   Sub '写入整数 
    Public   Sub   WriteLong(Section$,   Entry$,   ByVal   Default&) 
            WriteString   Section$,   Entry$,   Format$(Default&) 
    End   Sub '写入字符串 
    Public   Sub   WriteString(Section$,   Entry$,   ByVal   Default$) 
            iAPI   =   WritePrivateProfileString(Section$,   Entry$,   Default$,   iFileName) 
    End   Sub 没试过,一直压箱底来的~~~
    来我们一起研究研究~~
      

  3.   

    哎!惭愧
    这个是读写INI文件的~~
      

  4.   

    这个是没错滴~~记得有个APISetFilePointer 在一个文件中设置当前的读位置,然后把文件后半段的内容读到内存
    然后,再由APISetFilePointer在一个文件中设置当前的写位置~~~~
    反正就是一个字:麻烦