in reply to Re: WinNT Printer monitoring...
in thread WinNT Printer monitoring...

ASDI seems like a nice option. However, that means upgrading my domain to Active Directory (to be able to access the API), which I don't really trust. I know Microsoft has done a lot to AD since the launch of WinNT 5, but it's not something I want to bet my car and college on. I'd be a little more interested in a Win32::API(EnumPrinters()) call (I just got a chance to look at the MSDN Printer reference that was pointed out). This would be a much nicer thing to do (albeit possibly slower) since it would be backwards compatible (I have a thing for backwards compatibility). Maybe I'm just being harsh on Active Directory, but oh well. Thanks for the lead though. It's definitely worth a shot.

Necos
secon_kun@hotmail.com

Replies are listed 'Best First'.
(rchiav)Re(3): WinNT Printer monitoring...
by rchiav (Deacon) on Sep 05, 2001 at 22:32 UTC
    No, you don't have to upgrade to 2000. There's the "WinNT://" service providor which works just fine for NT machines. That link I gave you includes what objects are available to which service providors. You can even interface the entire Novell NDS structure (OU's, users, printers, etc..)

    Here's a little sample. This will list the names of printers on a praticular NT server..

    !/usr/bin/perl -w use strict; use Win32::OLE qw/in/; #fill in domain and server my $domain = ''; my $server = ''; my $printer; my $objServer = Win32::OLE->GetObject("WinNT://$domain/$server"); $objServer->{FILTER} = ["printqueue"]; foreach $printer (in $objServer) { print "$printer->{NAME}\n"; }
    Hope this helps..
    Rich
      Hmmm... This is really interesting. As much as I praise the Windows 2000 workstation edition, I'm still new to the Win2k (Active Directory, etc.) scheme of things. Personally, I find it very unstable. However, since you're using Win32::OLE to get the server information, there could be some pretty code down the line. I'd still like to use Win32::API (since it's backwards compatible with 95/98, which some of our workstations still run) to write a module (since one hasn't been written, or, at least, none of us know about it). I'm assuming that the code you're writting will be closed source. I've always been a personal fan of OSS and if I do get an opportunity to write a GOOD module for Win32 printer monitoring, I'd definitely be releasing the code under GPL (and if you do make your code closed, I hope it sells well, cause it's awful clever of you to use ASDI, something which is completely foreign to me). One thing that I wanted to ask however, which DLL contains the printer and spooling functions that are described in SDK? Microsoft says its in the SDK, but I'm pretty sure the DLL has to be local since the Spooler service can monitor the ports.

      Necos
      secon_kun@hotmail.com
        As far as the functions idnopheq recomended, if you click on the function link it will tell you at the bottom which lib it's in. I looked at a couple and they were in either winspool or gdi32. You'll have to check each specific function to see where it resides.

        As far as what I'm working on, it's nothing I'm planning on selling. It's going to be basically for me and whoever else wants to use it. I'll probably post it here if and when it's complete.

        And regarding AD itself.. it's a much needed improvement over the flat NT domain structure. A Directory Serivce is something that has been noticably lacking. Though I'll agree that there's a lot I consider to be done poorly. AD it's on that list though. There's a whole lot of uglyness in permissions now. They not only give you enough rope to hang yourself, they have already knotted it for you. If you get a chance to set up some servers.. read up on the horrible situation you have with RRAS and permissions. It's not pretty.

        obPerl: If you're going to write a module to do this I'd be interested in seeing it. I'm sure there's quite a few others who would benifit from it also..

        Rich