Win32API::Registry, RegOpenKeyEx fails [The parameter is incorrect]

R

Rene Nyffenegger

Hello

When I run the code appended further down, the call
to RegOpenKeyEx fails and regLastError() returns
"The parameter is incorrect".

As far as I can see, all is correct, but obviously, it isn't.
If someone gave me a helpful tip, I'd be very grateful.

Rene Nyffenegger

---------------->8----------->8---------->8------------

use warnings;
use strict;

use Win32API::Registry qw:)ALL);

my $handleSubKey=0;
my $handleSw =0;

my $company = "FooBar";

my $disp=0;

if ( ! RegOpenKeyEx(
HKEY_CURRENT_USER,
"Software",
0, # should be zero
KEY_ALL_ACCESS,
$handleSw) ) {

print regLastError();
}

print "handleSw: $handleSw\n";


if ( RegCreateKeyExW (
$handleSw,
$company,
0,
"",
REG_OPTION_NON_VOLATILE ,
KEY_ALL_ACCESS,
0,
$handleSubKey,
$disp)) {

print "$company existed already\n"
if $disp == REG_OPENED_EXISTING_KEY;
print "$company didn't exist, now created\n"
if $disp == REG_CREATED_NEW_KEY;
}
else {
print regLastError();
}
 
B

Brian McCauley

Rene said:
When I run the code appended further down, the call
to RegOpenKeyEx fails and regLastError() returns
"The parameter is incorrect".

As far as I can see, all is correct, but obviously, it isn't.
If someone gave me a helpful tip, I'd be very grateful.

I suggest you avoid the low level module and use the higher level
Tie::Registry. Not only because it's a lot simpler and this is what the
documentation of Win32API::Registry suggests but also because the
Win32API::* documentation is so full of errors and contradictions that
it's nigh on imposible to tell if you are using them correctly.
 
T

Thomas Kratz

Brian said:
I suggest you avoid the low level module and use the higher level
Tie::Registry. Not only because it's a lot simpler and this is what the
documentation of Win32API::Registry suggests but also because the
Win32API::* documentation is so full of errors and contradictions that
it's nigh on imposible to tell if you are using them correctly.

I fully agree, but like to mention the module is called

Win32::TieRegistry

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
 
T

Thomas Kratz

Thomas said:
I fully agree, but like to mention the module is called

Win32::TieRegistry

I just had a look at CPAN and there is indeed a module called
Tie::Registry that seems to be an early predecessor of Win32::TieRegistry.
Perhaps the author (Tye McQueen) should withdraw it from the Tie hierarchy.

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top