|
@@ -48,7 +48,7 @@ Var
|
|
begin
|
|
begin
|
|
SecurityAttributes := Nil;
|
|
SecurityAttributes := Nil;
|
|
P:=PrepKey(Key);
|
|
P:=PrepKey(Key);
|
|
- Result:=RegCreateKeyExA(GetBaseKey(RelativeKey(Key)),
|
|
|
|
|
|
+ FLastError:=RegCreateKeyExA(GetBaseKey(RelativeKey(Key)),
|
|
P,
|
|
P,
|
|
0,
|
|
0,
|
|
'',
|
|
'',
|
|
@@ -56,7 +56,8 @@ begin
|
|
KEY_ALL_ACCESS,
|
|
KEY_ALL_ACCESS,
|
|
SecurityAttributes,
|
|
SecurityAttributes,
|
|
Handle,
|
|
Handle,
|
|
- @Disposition) = ERROR_SUCCESS;
|
|
|
|
|
|
+ @Disposition);
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
RegCloseKey(Handle);
|
|
RegCloseKey(Handle);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -66,12 +67,14 @@ Var
|
|
P: PChar;
|
|
P: PChar;
|
|
begin
|
|
begin
|
|
P:=PRepKey(Key);
|
|
P:=PRepKey(Key);
|
|
- Result:=RegDeleteKeyA(GetBaseKey(RelativeKey(Key)),P)=ERROR_SUCCESS;
|
|
|
|
|
|
+ FLastError:=RegDeleteKeyA(GetBaseKey(RelativeKey(Key)),P);
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TRegistry.DeleteValue(const Name: String): Boolean;
|
|
function TRegistry.DeleteValue(const Name: String): Boolean;
|
|
begin
|
|
begin
|
|
- Result := RegDeleteValueA(fCurrentKey, @Name[1]) = ERROR_SUCCESS;
|
|
|
|
|
|
+ FLastError:= RegDeleteValueA(fCurrentKey, @Name[1]);
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TRegistry.SysGetData(const Name: String; Buffer: Pointer;
|
|
function TRegistry.SysGetData(const Name: String; Buffer: Pointer;
|
|
@@ -82,8 +85,9 @@ Var
|
|
|
|
|
|
begin
|
|
begin
|
|
P := PChar(Name);
|
|
P := PChar(Name);
|
|
- If RegQueryValueExA(fCurrentKey,P,Nil,
|
|
|
|
- @RD,Buffer,lpdword(@BufSize))<>ERROR_SUCCESS Then
|
|
|
|
|
|
+ FLastError:=RegQueryValueExA(fCurrentKey,P,Nil,
|
|
|
|
+ @RD,Buffer,lpdword(@BufSize));
|
|
|
|
+ if (FLastError<>ERROR_SUCCESS) Then
|
|
Result:=-1
|
|
Result:=-1
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
@@ -109,7 +113,10 @@ Var
|
|
begin
|
|
begin
|
|
P:=PChar(ValueName);
|
|
P:=PChar(ValueName);
|
|
With Value do
|
|
With Value do
|
|
- Result:=RegQueryValueExA(fCurrentKey,P,Nil,lpdword(@RegData),Nil,lpdword(@DataSize))=ERROR_SUCCESS;
|
|
|
|
|
|
+ begin
|
|
|
|
+ FLastError:=RegQueryValueExA(fCurrentKey,P,Nil,lpdword(@RegData),Nil,lpdword(@DataSize));
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
|
|
+ end;
|
|
If Not Result Then
|
|
If Not Result Then
|
|
begin
|
|
begin
|
|
Value.RegData := rdUnknown;
|
|
Value.RegData := rdUnknown;
|
|
@@ -129,9 +136,9 @@ begin
|
|
if not(Rel) then
|
|
if not(Rel) then
|
|
Delete(S,1,1);
|
|
Delete(S,1,1);
|
|
{$ifdef WinCE}
|
|
{$ifdef WinCE}
|
|
- RegOpenKeyEx(GetBaseKey(Rel),PWideChar(WideString(S)),0,FAccess,Result);
|
|
|
|
|
|
+ FLastError:=RegOpenKeyEx(GetBaseKey(Rel),PWideChar(WideString(S)),0,FAccess,Result);
|
|
{$else WinCE}
|
|
{$else WinCE}
|
|
- RegOpenKeyEx(GetBaseKey(Rel),PChar(S),0,FAccess,Result);
|
|
|
|
|
|
+ FLastError:=RegOpenKeyEx(GetBaseKey(Rel),PChar(S),0,FAccess,Result);
|
|
{$endif WinCE}
|
|
{$endif WinCE}
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -143,9 +150,12 @@ var
|
|
begin
|
|
begin
|
|
FillChar(Value, SizeOf(Value), 0);
|
|
FillChar(Value, SizeOf(Value), 0);
|
|
With Value do
|
|
With Value do
|
|
- Result:=RegQueryInfoKeyA(CurrentKey,nil,nil,nil,lpdword(@NumSubKeys),
|
|
|
|
|
|
+ begin
|
|
|
|
+ FLastError:=RegQueryInfoKeyA(CurrentKey,nil,nil,nil,lpdword(@NumSubKeys),
|
|
lpdword(@MaxSubKeyLen),nil,lpdword(@NumValues),lpdword(@MaxValueLen),
|
|
lpdword(@MaxSubKeyLen),nil,lpdword(@NumValues),lpdword(@MaxValueLen),
|
|
- lpdword(@MaxDataLen),nil,@winFileTime)=ERROR_SUCCESS;
|
|
|
|
|
|
+ lpdword(@MaxDataLen),nil,@winFileTime);
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
|
|
+ end;
|
|
if Result then
|
|
if Result then
|
|
begin
|
|
begin
|
|
FileTimeToSystemTime(@winFileTime, @sysTime);
|
|
FileTimeToSystemTime(@winFileTime, @sysTime);
|
|
@@ -196,16 +206,19 @@ begin
|
|
If CanCreate then
|
|
If CanCreate then
|
|
begin
|
|
begin
|
|
Handle:=0;
|
|
Handle:=0;
|
|
- Result:=RegCreateKeyExA(GetBaseKey(RelativeKey(Key)),P,0,'',
|
|
|
|
|
|
+ FLastError:=RegCreateKeyExA(GetBaseKey(RelativeKey(Key)),P,0,'',
|
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
REG_OPTION_NON_VOLATILE,
|
|
fAccess,SecurityAttributes,Handle,
|
|
fAccess,SecurityAttributes,Handle,
|
|
- pdword(@Disposition))=ERROR_SUCCESS
|
|
|
|
-
|
|
|
|
|
|
+ pdword(@Disposition));
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- Result:=RegOpenKeyExA(GetBaseKey(RelativeKey(Key)),
|
|
|
|
- P,0,fAccess,Handle)=ERROR_SUCCESS;
|
|
|
|
|
|
+ begin
|
|
|
|
+ FLastError:=RegOpenKeyExA(GetBaseKey(RelativeKey(Key)),
|
|
|
|
+ P,0,fAccess,Handle);
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
|
|
+ end;
|
|
If Result then begin
|
|
If Result then begin
|
|
if RelativeKey(Key) then
|
|
if RelativeKey(Key) then
|
|
S:=CurrentPath + Key
|
|
S:=CurrentPath + Key
|
|
@@ -238,7 +251,8 @@ begin
|
|
{$ifdef WinCE}
|
|
{$ifdef WinCE}
|
|
Result:=False;
|
|
Result:=False;
|
|
{$else}
|
|
{$else}
|
|
- Result:=RegConnectRegistryA(PChar(UNCName),RootKey,newroot)=ERROR_SUCCESS;
|
|
|
|
|
|
+ FLastError:=RegConnectRegistryA(PChar(UNCName),RootKey,newroot);
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
if Result then begin
|
|
if Result then begin
|
|
RootKey:=newroot;
|
|
RootKey:=newroot;
|
|
PWinRegData(FSysData)^.RootKeyOwned:=True;
|
|
PWinRegData(FSysData)^.RootKeyOwned:=True;
|
|
@@ -371,7 +385,8 @@ begin
|
|
rdBinary : RegDataType:=REG_BINARY;
|
|
rdBinary : RegDataType:=REG_BINARY;
|
|
end;
|
|
end;
|
|
P:=PChar(Name);
|
|
P:=PChar(Name);
|
|
- Result:=RegSetValueExA(fCurrentKey,P,0,RegDataType,Buffer,BufSize)=ERROR_SUCCESS;
|
|
|
|
|
|
+ FLastError:=RegSetValueExA(fCurrentKey,P,0,RegDataType,Buffer,BufSize);
|
|
|
|
+ Result:=FLastError=ERROR_SUCCESS;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegistry.RenameValue(const OldName, NewName: string);
|
|
procedure TRegistry.RenameValue(const OldName, NewName: string);
|
|
@@ -417,3 +432,11 @@ begin
|
|
fRootKey := Value;
|
|
fRootKey := Value;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TRegistry.GetLastErrorMsg: string;
|
|
|
|
+begin
|
|
|
|
+ if FLastError <> ERROR_SUCCESS then
|
|
|
|
+ Result:=SysErrorMessage(FLastError)
|
|
|
|
+ else
|
|
|
|
+ Result:='';
|
|
|
|
+end;
|
|
|
|
+
|