2017-12-11 2 views
1

D10 시애틀에서 folowing 코드를 잘 컴파일하지만 D10이 설치된 PC는 고장났습니다. 그렇다면 DXE5을 사용하여 프로젝트에서 작은 업데이트를 만들 필요가 있지만 명령이 TJSONBool.Create(False)JSONObj.ToJSON이기 때문에 컴파일되지 않습니다.D10 to DXE5 : TJSONBool.Create (False)와 JSONObj.ToJSON은 무엇입니까?

무엇이 DXE5에 대해서 각각 TJSONBool.Create(False)JSONObj.ToJSON에 해당합니까?

uses 
Data.DBXJSON, SHFolder; 

function GetSpecialFolderPath(folder : integer) : string; 
const 
    SHGFP_TYPE_CURRENT = 0; 
var 
    path: array [0..MAX_PATH] of char; 
begin 
    if SUCCEEDED(SHGetFolderPath(0,folder,0,SHGFP_TYPE_CURRENT,@path[0])) then 
    Result := path 
    else 
    Result := ''; 
end; 

procedure ChangeChromeSetting(const ATarget, Avalue: string); 
var 
    specialfolder: integer; 
    pathchrome: String; 
    JSONObj, ObjIpp: TJSONObject; 
    JSONPair: TJSONPair; 
    OldValue: string; 
begin 
    specialFolder := CSIDL_LOCAL_APPDATA; 
    pathchrome := GetSpecialFolderPath(specialFolder); 
    pathchrome := pathchrome + '\Google\Chrome\User Data\Local State'; 

if fileexists(pathchrome) then 
    begin 
    JSONObj := TJSONObject.ParseJSONValue(TFile.ReadAllText(pathchrome)) as TJSONObject; 
    if not Assigned(JSONObj) then Exit; {raise Exception.Create('Cannot read file: ' + pathchrome);} 
    try 
     OldValue := JSONObj.GetValue<string>(ATarget); 
     if OldValue = '' then 
       Exit; 
     if not SameText(OldValue, Avalue) then 
     begin 
     JSONPair := JSONObj.Get(ATarget); 
     JSONPair.JsonValue.Free; 
     JSONPair.JsonValue := TJSONString.Create(Avalue); 

     ObjIpp := TJSONObject.Create; 
     ObjIpp.AddPair('enabled', TJSONBool.Create(False)); 
     JSONObj.AddPair('hardware_acceleration_mode', ObjIpp); 

     TFile.WriteAllText(pathchrome, JSONObj.ToJSON); 
     end; 
    finally 
     JSONObj.Free; 
    end; 
    end; 
end; 

////////////////////// USAGE ///////////////////////// 

ChangeChromeSetting('hardware_acceleration_mode_previous', 'false'); 

답변

4

TJSONBoolTJSONAncestor.AsJSON은 XE5에 아직 존재하지 않습니다. ToJSON을 XE7에 첨가하고, TJSONBool을 10.0 시애틀에 첨가 하였다.

ObjIpp.AddPair('enabled', TJSONFalse.Create); 
... 
TFile.WriteAllText(pathchrome, JSONObj.ToString); 
:

이전 버전에서

대신 TJSONTrue/TJSONFalseTJSONObject.ToString 사용

관련 문제