//function GetJsonType(joI: ISuperObject): string;
//  begin
//    case joI.DataType of
//      stNull:    Result := 'stNull';
//      stBoolean: Result := 'stBoolean';
//      stDouble:  Result := 'stDouble';
//      stInt:     Result := 'stInt';
//      stObject:  Result := 'stObject';
//      stArray:   Result := 'stArray';
//      stString:  Result := 'stString';
//      stMethod:  Result := 'stMethod';
//    end;
//  end;

 

function ReadBigString(const FileName, Section, Ident, DefaultStr: string): string;
var
  PtrBuff : PChar;
  BuffSize, IniStrLen: integer;
const
  BuffMax = 2048000;  // some sensible value 2000K
begin
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms724353(v=vs.85).aspx
  Result := '';
  PtrBuff := nil;
  BuffSize := 204800; //200K
  repeat
    inc(BuffSize, 1024);//1K
    ReAllocMem(PtrBuff, BuffSize);
    IniStrLen := GetPrivateProfileString(PChar(Section), PChar(Ident),
                                         PChar(DefaultStr), PtrBuff,
                                         BuffSize, PChar(FileName));
//The return value is the number of characters copied to the buffer, not including the terminating null character.
  until (BuffSize > BuffMax) or (IniStrLen < BuffSize - 1);
  SetString(Result, PtrBuff, IniStrLen);
  FreeMem(PtrBuff);
end;

 

 posted on 2017-06-06 15:08  宝兰  阅读(70)  评论(0)    收藏  举报