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




"Brian McCauley" <nobull@xxxxxxxx> wrote in message
news:d9e9bm$bbs$1@xxxxxxxxxxxxxxxxxxxxx
> Has anyone ever managed to get Win32::Printer::Enum::Printer($server) to
> enumerate printers on a server?
>
> I've tried $server with a plain server name e.g. "MYBOX" and "\\\\MYBOX"
> nither give any response. (Note I'm using an accound with Administrator
> priv at MYBOX).
>
> Looking at MSDN it implies that the parameter to EnumPrinters() should
> be "Print Provider!!\\Machine" so I tried
>
> "win32spl.dll!!\\\\MYBOX"
>
> and
>
> "win32spl!!\\\\MYBOX"
>
> and
>
> "LanMan Print Services!!\\\\MYBOX"
>
> Still Win32::Printer::Enum::Printer() stubbonly returns nothing.
>

Can't help a lot, if at all - I don't have a printer. (If you get stuck you
might find some help on ActiveState's perl-win32-users list.)

In the Printers() function I see the following code:

my $return = Win32::Printer::_EnumPrinters($flag, $server);
unless (defined($return))
{croak "ERROR: Cannot enumerate printers!
${\Win32::Printer::_GetLastError()}";
}

That code seems a bit suss to me. If I call it as 'Printers("rubbish");', I
too find that it runs without output, though, of course, the domain named
"rubbish" doesn't even exist. I suspect that '(defined($return))' should be
replaced simply with '($return)'.
If EnumPrinters() fails, I think that _EnumPrinters() still returns a
defined (but untrue) value.

Anyway, you might find it useful to replace the above code with:

my $return = Win32::Printer::_EnumPrinters($flag, $server);
unless ($return)
{croak "$flag : $server: ERROR: Cannot enumerate printers!
${\Win32::Printer::_GetLastError()}";
}

With that change I get:

8 : \\rubbish : ERROR: Cannot enumerate printers! The RPC server is
unavailable.
at try.pl line 5

which looks sane to me.

Hth.

Cheers,
Rob



.



Relevant Pages

  • Re: InstalledPrinters and Windows Server 2003 R2
    ... the EnumPrinters line it just stops and does not return an error. ... I found that InstalledPrinters had problems when one or more printers had ... I had to fall back on the EnumPrinters API. ... run the same code on a Win XP box all installed printers are listed. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Windows CE + EnumPrinters
    ... EnumPrinters() is not supported on CE. ... I am newbie in Windows CE Developement, I am writing a very simple ... printers installed on machine, For that I am using EnumPrinters API, I ... What I need to do to enumerate printers ...
    (microsoft.public.windowsce.embedded.vc)
  • EnumPrinters PRINTER_ATTRIBUTE_LOCAL
    ... I'm calling the EnumPrinters() api with various info levels 1,2,4,5. ... I am testing on a Workgroup configuration -- not a domain. ... And it identifies the location of the printers correctly. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Is there something better than EnumPrinters?
    ... Checkout msdn and there are samples out there which you can take and use. ... Vipin Aravind ... > information on all the printers currently installed than EnumPrinters. ...
    (microsoft.public.vc.mfc)