GOAL:
Using Win32::TieRegistry, I am opening a registry key in Windows NT4, deleting a subkey, and then closing the registry key using undef. Then I am opening a second key, deleting a subkey, and then closing the second registry key using undef. The second key should not be deleted until the first key is already deleted. My assumption was that closing the first key using undef would enable me to delete the second key, but it's not working in Perl as I had expected. Both keys are being deleted, but the result is similar to what would happen if I deleted the second key first and the first key second.
POSSIBLE SOLUTION:
I found Flush( $bFlush ) in the TieRegistry documenation:
"Flushes all cached information about the Registry key so that future uses will get fresh data from the Registry.
If the optional $bFlush is specified and a true value, then RegFlushKey() will be called, which is almost never necessary."
QUESTIONS:
Maybe I need to use Flush after deleting the first key, but I can't figure out how it works. I have no idea what $bFlush is, what it means by "specified", what it means by "and a true value", or what RegFlushKey() is and why it would be necessary. Even if I don't need to "specify" $bFlush, I don't know the correct syntax for using Flush. It says that Flush( $bFlush ) is a member function defined for use on Win32::TieRegistry objects.
SOME FAILED ATTEMPTS:
Assuming that it's not a method, I was thinking along these lines:
$OpenKey = Flush( $bFlush );
or
Flush();
and I get this error:
Undefined subroutine &main::Flush called...
So I try this:
$OpenKey = Win32::TieRegistry->Flush( $bFlush );
and I get this error:
Can't use string ("Win32::TieRegistry") as a HASH ref while "strict refs" in use at C:\...TieRegistry.pm line 527
This doesn't give me an error, but it doesn't work:
$Registry->Flush();
Debugging, I've noticed that it doesn't step through the entire Flush subroutine.
So, I tried this:
$Registry->Flush( $bFlush );
and I get this error:
Usage: $Key->Flush( $bFlush );
So, I tried this and got the same usage error:
my $key = $Registry->{"LMachine"};
$key->Flush( $bFlush );
ADDITIONAL NOTE:
Someone else has
asked a similar question as well. The original question was missing some details, and the follow up question about Flush didn't get a response.