ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
16.6 Setting Registry ValuesIn addition to creating keys, we can also set Registry values. To do so, we once again need an open key and the $eriko->SetValue("blah", REG_SZ, "some_string"); $eriko->SetValueEx("foo", 0, REG_SZ, "bar"); Even though these two functions look similar, they do quite different things. The first line ( 16.6.1 More Registry OperationsYou can do more with the Registry than just read and modify key values. You can also delete keys and export/import hives from the Registry. As we mentioned above, be extremely prudent when deleting or importing things into your registry. Here's an example of deleting a key: use Win32::Registry; $main::HKEY_CURRENT_USER->Open("SOFTWARE", $Software) || die "Open: $!"; $Software->Create("ERIKO", $eriko) || die "Create: $!"; # open parent key $eriko->DeleteKey("blah"); # delete blah
use Win32::Registry; $main::HKEY_CURRENT_USER->Open("SOFTWARE", $Software) || die "Open: $!"; $Software->Create("ERIKO", $eriko) || die "Create: $!"; $eriko->Open("blah", $blah); # open blah $blah->GetKeys(\@kids); # get all child keys foreach $k (@kids) { # kill all of them $blah->DeleteKey($k); } $eriko->DeleteKey("blah"); # now, remove blah This code assumes that none of the child keys of The following example saves a Registry hive to an external file using the use Win32::Registry; $main::HKEY_LOCAL_MACHINE->Open("SOFTWARE", $Software) || die "Open: $!"; $Software->Open("ActiveState", $ActiveState) || die "Open: $!"; # write ActiveState hive to perlkeys.reg $ActiveState->Save("perlkeys.reg") || die "Save: $!"; You can connect to the Registry of a remote machine (but only to the HKEY_LOCAL_MACHINE or HKEY_USERS hives) using the use Win32::Registry; Win32::Registry::RegConnectRegistry("\\\\somemachine", HKEY_LOCAL_MACHINE, $key) || die "connect: $!"; |