in reply to Re^2: Win32API::Registry -- RegOpenKeyEx fails when called 2 times. (our 2^H3 main weapons)
in thread Win32API::Registry -- RegOpenKeyEx fails when called 2 times.

Heh. That's funny. You are quoting Win32::Registry documentation to somebody who is using Win32API::Registry.

<homer>D'oh!</homer> And I was wondering why the version numbers were so different ...

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re^3: Win32API::Registry -- RegOpenKeyEx fails when called 2 times. (our 2^H3 main weapons)

Replies are listed 'Best First'.
Re^4: Win32API::Registry -- RegOpenKeyEx fails when called 2 times. (our 2^H3 main weapons)
by ashah21 (Initiate) on Mar 14, 2010 at 18:03 UTC

    Thanks All for your valuable responses.

    As tye said, my presentation is bit confusing.. So let me try to explain the problem again.

    I have to get the value of one subkey which might be present under wow6432node (e.g. SOFTWARE/Wow6432Node/Microsoft/Internet Explorer) location or under the original 32/64 bit (e.g. SOFTWARE/Microsoft/Internet Explorer) registry. So I had put them in if-else.

    The problem I was facing was, if the first key does not exist then my code (posted on the original thread) is not able to find the second key as well even though it exists at that location.

    The reason behind the problem was, I was relying on the regLastError to decide if 'RegOpenKeyEx' function has returned success or not.

    RegOpenKeyEx( $hKey, $sKey, 0, KEY_READ, $key) or warn "Can't ope +n $hKey\\$sKey: ", regLastError(),"\n"; $error = regLastError(); return "error" if ($error ne "");
    Following code works fine for me now:
    RegOpenKeyEx( $hKey, $sKey, 0, KEY_READ, $key) or warn "Can't ope +n $hKey\\$sKey: ", regLastError(),"\n"; RegQueryValueEx( $key, $sValue, [], $type, $data, [] ) or warn "C +an't read $hKey\\$sKey: ", regLastError(),"\n"; RegCloseKey( $key ) or warn "Can't close $hKey\\$sKey: ", regLastE +rror(),"\n"; chomp($data); return $data;


    Thanks again..