* Patch from Serge Anvarov (bug ID 35102) to reduce code duplication

git-svn-id: trunk@41952 -
This commit is contained in:
michael 2019-04-28 09:26:52 +00:00
parent a254a49e84
commit 587397253d

View File

@ -42,6 +42,17 @@ begin
Result:=(S='') or (S[1]<>'\')
end;
function RegDataWordToRegDataType(RD: DWORD): TRegDataType;
begin
// Test in ascending because rdString is most commonly used
Result := Succ(Low(RegDataWords));
repeat
if RegDataWords[Result] = RD then
Exit;
Inc(Result);
until Result > High(Result);
Result := Low(RegDataWords);
end;
function TRegistry.sysCreateKey(Key: UnicodeString): Boolean;
Var
@ -95,9 +106,7 @@ begin
Result:=-1
else
begin
RegData:=High(TRegDataType);
While (RegData>rdUnknown) and (RD<>RegDataWords[RegData]) do
RegData:=Pred(RegData);
RegData:=RegDataWordToRegDataType(RD);
Result:=BufSize;
end;
end;
@ -110,15 +119,10 @@ Var
begin
With Value do
begin
FLastError:=RegQueryValueExW(fCurrentKey,PWideChar(ValueName),Nil,lpdword(@RegData),Nil,lpdword(@DataSize));
FLastError:=RegQueryValueExW(fCurrentKey,PWideChar(ValueName),Nil,@RD,Nil,lpdword(@DataSize));
Result:=FLastError=ERROR_SUCCESS;
if Result then
begin
RD:=DWord(RegData);
RegData:=High(TRegDataType);
While (RegData>rdUnknown) and (RD<>RegDataWords[RegData]) do
RegData:=Pred(RegData);
end;
RegData:=RegDataWordToRegDataType(RD);
end;
If Not Result Then
begin