Is the printer ready ?


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
This sound like it should be easy but it isn't.  I need to find out from with a VFP app if a particular printer is ready to print. i.e it's current status  (Ready, out of paper, off-line whatever)  This code, offered up on  Universal Thread, doesn't work because if the printer is installed the handle will happen successfully (assuming the printer server box is on line) no matter what the status of the printer is.

(code below is a VFP function with syntax adjusted from VB)

LPARAMETERS tcprintername

&&#DEFINE cJobs_OFFSET 77

DECLARE INTEGER OpenPrinter IN winspool.drv;

STRING pPrinterName, INTEGER @phPrinter, INTEGER pDefault

DECLARE INTEGER ClosePrinter IN winspool.drv INTEGER hPrinter

cPrinter=tcprintername

hPrinter=0

IF OpenPrinter(m.cPrinter, @hPrinter, 0) = 0

&&? "Unable to obtain handle for the printer."

RETURN -1

ENDIF

= ClosePrinter(hPrinter)

RETURN 0

I found this http://www.merrioncomputing.com/Programming/PrintStatus.htm and I think my answer for creating a dll in .net may be in here but putting it together is a little beyound my current understanding of how these pieces fit.

Anyone who has solved this, knows of a third party dll that can be obtained or purchased, or who has already invented this wheel - you guidance will be greatly appreciated.

Charles

Replies
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Hey, thanks an lot Edhy and Trent.  i'm really glad I asked!  I had actually forgotten that by using a .NET dll I would have to make sure the boxes that ran it had .NET but since this is a feature that is going into an app we are converting to a SQLExpress backend I believe that will insure that .NET is there, no?

In any case, this is helping a lot in clarifying my understanding of how to do this stuff.  I knew that winmgmts was the old approach but couldn't wrap my brain around how to use the wmi.

It is great to be learning .NET in an environment where people speak Fox.  (I have been talking up Strataframe big-time on the UT for exactly that reason)

Both of your posts are going in the scrapbook and I'm definitely going to be making good use of this.  Thanks again.

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Glad it helped! Smile
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Charles R Hankey - 17 Years Ago
Edhy Rijo - 17 Years Ago
Charles R Hankey - 17 Years Ago
Edhy Rijo - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Edhy Rijo - 17 Years Ago
                         Add SYstem.Management as a reference.
Trent L. Taylor - 17 Years Ago
                             Thanks, that did it!
Edhy Rijo - 17 Years Ago
Charles R Hankey - 17 Years Ago
             Glad it helped! :)
Trent L. Taylor - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search