For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > November 2004 > Win32API::Registry, RegOpenKeyEx fails [The parameter is incorrect]









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2004-11-29, 4:05 pm

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();
}


--
Rene Nyffenegger
http://www.adp-gmbh.ch
Brian McCauley

2004-11-29, 4:05 pm



Rene Nyffenegger wrote:

> 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.

Thomas Kratz

2004-11-29, 4:05 pm

Brian McCauley wrote:

> 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^.-
Thomas Kratz

2004-11-29, 4:05 pm

Thomas Kratz wrote:
> Brian McCauley wrote:
>
>
>
> 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^.-
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com