in reply to Raku: How do I generate a handle for HKEY_LOCAL_MACHINE?

I was able to piece together a solution (I think), based on someone's code I found on SO:

use NativeCall; constant BYTE := uint8; constant WCHAR := uint16; constant DWORD := int32; constant REGSAM := int32; constant WCHARS := CArray[WCHAR]; constant BYTES := CArray[BYTE]; constant HKEY_LOCAL_MACHINE = 0x80000002; constant KEY_QUERY_VALUE = 1; constant ERROR_SUCCESS = 0; # Yeah, I know. The Win-Api uses 0 for + success and other values to indicate errors sub RegOpenKeyExW( DWORD, WCHARS, DWORD, REGSAM, DWORD is rw) is nativ +e("Kernel32.dll") returns DWORD { * }; sub RegQueryValueExW( DWORD, WCHARS, DWORD is rw, DWORD is rw, BYTE is + rw, DWORD is rw) is native("Kernel32.dll") returns DWORD { * }; my $key = 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'; my DWORD $hkey; my $length = 1024; sub wstr( Str $str ) returns WCHARS { my $return = CArray[WCHAR].new( $str.encode.list ); $return[$return.elems] = 0; return $return; } my $h-key = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wstr($key), 0, KEY_QUERY +_VALUE, $hkey); say $hkey;

The $hkey reports back a 3 digit number. However, it changes with each run, so I'm not sure if it's running correctly.

$PM = "Perl Monk's";
$MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
$nysus = $PM . ' ' . $MC;
Click here if you love Perl Monks