Re: Win32::Printer::Enum::Printer($server)



On Thu, 23 Jun 2005 13:18:43 +0100, Brian McCauley wrote:
> Has anyone ever managed to get Win32::Printer::Enum::Printer($server) to
> enumerate printers on a server?

If you can connect to a remote registry from perl, then this code may
work (it works fine with local printers).

sub list_printers {
# list available printers
my %printers;

# look at registry to get printer names for local machine
my $Register = 'SYSTEM\CurrentControlSet\Control\Print\Printers';
my ($hkey, @key_list, @names, @ports);
my $HKEY_LOCAL_MACHINE = $main::HKEY_LOCAL_MACHINE;
$HKEY_LOCAL_MACHINE->Open($Register, $hkey) or
Carp::croak "Can't open registry key HKEY_LOCAL_MACHINE\\$Register: $!";
$hkey->GetKeys(\@key_list);
foreach my $key (@key_list) {
my $path = $Register . '\\' . $key;
my ($pkey, %values, $printers);
$HKEY_LOCAL_MACHINE->Open($path, $pkey) or
Carp::croak "Can't open registry key HKEY_LOCAL_MACHINE\\$path: $!";
$pkey->GetValues(\%values);
push @ports, $values{Port}[2];
push @names, $values{Name}[2];
}
$printers{name} = [ @names ];
$printers{port} = [ @ports ];
return %printers;
}


--
Stephen Patterson steve@xxxxxxxxxxxxxx http://patter.mine.nu/
Linux Counter No: 142831 GPG Public key: E3E8E974
"Whoever said nothing is impossible never tried slamming a revolving door."
-- Melissa O'Brien
.



Relevant Pages

  • Re: Apps for rollout in 2005: .net or win32
    ... >> applications that need to print WYSIWYG forms on local printers. ... > I find it easier to create a report in HTML using Cold Fusion than ...
    (borland.public.delphi.non-technical)
  • Re: Win 2003 TS: Local Printers Not Showing Up
    ... to enable local printing while logged into a TS session. ... any printers on the Terminal Server. ... >> All remote clients are Win XPP using RDC. ... >> the local printers do not show up in TS session. ...
    (microsoft.public.win2000.termserv.clients)
  • Re: Sharing Remote Printer via VPN on RAS (TermServer)
    ... Each user has to have local printers set ... up on the remote terminal server so that they can print out reports ... These printers are all shared on the local network, ... "appear" to be local printers at the remote site, ...
    (microsoft.public.isa.vpn)
  • Re: printing to a local printer
    ... Personally, I wouldn't spend more time in troubleshooting, but simply reinstall the client from scratch. ... MCSE, CCEA, Microsoft MVP - Terminal Server ... So what is happening is that none of the local printers on the ...
    (microsoft.public.win2000.termserv.clients)
  • Re: Inherited Permissions for Printers
    ... > What I see this works, at least for Add/Remove Printers right. ... Are you saying that having permissions on the Computer ... Local printers are by default> published in the directory. ... >>> computer object in the Active Directory, since all printers published in>>> active directory is child objects to it's host/computer/server. ...
    (microsoft.public.win2000.active_directory)