Using the NT registry extensions in NT Perl port 
Author Message
 Using the NT registry extensions in NT Perl port

I have the following implementation of Perl:

This is perl, version 5.001
        Unofficial patchlevel 1l.
Copyright 1987-1994, Larry Wall
Windows NT port Copyright (c) 1995 Microsoft Corporation. All rights reserved.
        Developed by hip communications inc., http://www.*-*-*.com/

This perl has extra built-in functions to cover the registry API, such as
NTRegOpenKey.  But the on-line man pages aren't much help.   For instance:

        NTRegOpenKey HKEY, SUBKEYNAME, PHKRESULT

How do I call this function?  Like this?:

NTRegOpenKey "HKEY_LOCAL_MACHINE", "SOFTWARE/Company/Product/1.0/MyKey", $key;

Or use doubled backslashes instead of slashes in the key name?  Or pass a
reference like "\$key" instead of "$key"?  Or use some magic symbol instead
of the string "HKEY_LOCAL_MACHINE"?

Nothing I've tried works, and the on-line documentation doesn't give a
hint, so I'd appreciate any help.

Thanks!
--
Laurence J. Golding

(408)456-6004                     -- God's final message to creation



Mon, 31 May 1999 03:00:00 GMT  
 Using the NT registry extensions in NT Perl port

Quote:
>This perl has extra built-in functions to cover the registry API, such as
>NTRegOpenKey.  But the on-line man pages aren't much help.

The on-line docs are even wrong, giving incorrect parameter ordering.
Below I've included som perl code for extracting the keys and values for
the registry entry used by the NT Web server to hold virtual roots.
The trick is using $HKEY_LOCAL_MACHINE->Open($key, $keyObj)
for opening a key and $keyObj->GetValues(\%values) for
accessing the keys and values. The object oriented interface is rather
nice, IMHO.

Hallvard

use lib 'D:\Perl\perl5\Lib';

use English;
use Win32::Registry;

sub main {
    my($file) = $ARGV[0] || '&STDOUT';
    my($key)  = $ARGV[1] ||
'SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Virtual Roots';
    print STDERR "Writing roots in \nkey: $key, to \nfile: $file\n";
    $key =~ s/__/ /g;
    my($keyObj, %values);
    $HKEY_LOCAL_MACHINE->Open($key, $keyObj) || die $!;
    $keyObj->GetValues(\%values) || die $!;

    open(ROOTS, ">$file") || die;
    print ROOTS '%main::virtual_roots = (', "\n";
    foreach (keys %values) {
   $_ =~ /^(.*),$/;
   my($root) = $1;
   $values{$_}->[2] =~ /^(.*),(\w*),(\d)$/;
   my($dir, $user, $access) = ($1, $2, $3);
   $dir =~ s/\\$/\\\\/;
   print ROOTS "\t'$root'\t=>\t'$dir',\n"
       if ($access == 1); # root is to a readable directory
   # print "#\t$root\t$access\t$user\t$dir\n";
    }
    print ROOTS ");\n\n1;";
    close(ROOTS);

Quote:
}

main();

--
Hallvard Traetteberg, Research Scientist      Tel: +47 2206 7983
SINTEF Telecom and Informatics, Oslo          Tel: +47 2206 7300
NORWAY                                        Fax: +47 2206 7350



Mon, 31 May 1999 03:00:00 GMT  
 Using the NT registry extensions in NT Perl port


(snip)

Quote:
>Nothing I've tried works, and the on-line documentation doesn't give a
>hint, so I'd appreciate any help.

The online docs for release 110 are much better.  They document the
Win32::Registry stuff pretty well.  But, anything that you try to do
that requires priviledges (like RegSaveKey / RegRestoreKey) will not
work on NT.  Win32::Registry doesn't have the implementation for
things like AdjustTokenPriviledges.

Hope this helps.

--Duane



Sun, 20 Jun 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Perl for NT, ? using Registry extensions

2. ? on Perl 5.001 and NT registry extensions

3. Porting a Perl extension to NT 4.0

4. Porting extension to NT for an embedded P5 program

5. Is anyone using perl/tk and opengl extension on 95/NT

6. mod_perl on NT .. problems using Apache::Registry

7. Port old GL/C/SGI app to NT app using Perl

8. How can I connect to NT machine's registry remotely when using Win32::TieRegistry

9. Trouble using Win32::Registry to edit NT environment

10. PERL(NT) for Win32 and SYSTEM Calls in NT 4.0 (worked in NT 3.51)

11. Perl and Windows NT registry problem.

12. NT Registry Access with Perl 5.004_02

 

 
Powered by phpBB® Forum Software