On 23.08.2013 19:51, waldo kitty wrote:
On 8/23/2013 13:25, Sven Barth wrote:
On 23.08.2013 15:46, waldo kitty wrote:
On 8/22/2013 23:08, Flávio Etrusco wrote:
I guess he means this:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724840%28v=vs.85%29.aspx


interesting... you'd think that people would mention these things and
give links as above if it is what they are actually after... thanks for
the pointer and to michael for the additional information... and
definitely thanks to sven for the implementation...

now we wait to see if the OP can update to the latest FPC SVN, as
indicated by sven, to gain access to it...

He can also use the functionality in 2.6.x, 2.7.1 "just" wraps the
necessary
house keeping.

right but it has to be specifically added, correct? it has not (yet)
been added other than in FPC trunk? i did see it come in here when i svn
upped my FPC and lazarus a few hours ago ;)

Code in trunk:

=== code begin ===

sl := Nil;
reg := TRegistry.Create(KEY_READ);
try
  reg.RootKey := HKEY_USERS;
  if not reg.ConnectRegistry('\\SomeMachine') then
    raise Exception.Create('Could not connect');
  reg.OpenKeyReadOnly('\');

  sl := TStringList.Create;
  reg.GetKeyNames(sl);
  for s in sl do
    Writeln(s);
finally
  reg.Free;
  sl.Free;
end;

=== code end ===

Equivalent code in 2.6.2 and earlier:

=== code begin ===

sl := Nil;
reg := TRegistry.Create(KEY_READ);
try
if RegConnectRegistry('\\SomeMachine', HKEY_USERS, key) <> ERROR_SUCCESS then
    raise Exception.Create('Could not connect');
  reg.RootKey := key;
  reg.OpenKeyReadOnly('\Software');

  sl := TStringList.Create;
  reg.GetKeyNames(sl);
  for s in sl do
    Writeln(s);
finally
  reg.Free;
  sl.Free;
end;

=== code end ===

For this he can open the remote registry with RegConnectRegistry
and pass resulting HKEY handle to the Rootkey property of a TRegistry
instance.
Afterwards he can work normally with TRegistry. At the end he needs to
close the
Rootkey using RegCloseKey. This is basically what TRegistry now does
in 2.7.1 as
well.

can i assume that RegCloseKey sends the possibly modified key back to
the remote? i'm just asking to learn O:)


You are only opening either HKEY_USERS, HKEY_LOCAL_MACHINE or HKEY_PERFORMANCE_DATA using RegConnectRegistry/TRegistry.ConnectRegistry. All other subkeys are opened using the normal registry API (be it directly or through TRegistry) and Windows handles the rest. When exactly it sends the modifications to the remote machine is up to Windows.

Regards,
Sven

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to