How to use Getprinter in vb.net ?

Z

Zok

hello all,


I am trying for a long time now to get the information of a printer.
i have such cide in vb6 but having troubles moving it into vb.net.


can anyone please provide me with the correct vb.net declaration (there

are so many different versions online) and example of how to use these
apis :


openprinter
getprinter
setprinter


and example of how to use


this is the code im working on now, but getprinter just doesnt work.


Private Declare Function OpenPrinter Lib "winspool.drv" Alias
"OpenPrinterA" (ByVal pPrinterName As String, ByRef phPrn As Integer,
ByRef pDefault As Integer) As Integer


Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA"
(ByVal hPrinter As Integer, ByVal Level As Integer, ByRef pPrinter As
Object, ByVal cbBuf As Integer, ByRef pcbNeeded As Integer) As Integer


Dim hPrn As Integer
Dim Buffer() As Byte
Dim BytesNeeded As Integer
Dim BytesUsed As Integer


Call OpenPrinter(m_DevName, hPrn, 0)
If hPrn Then


Call GetPrinter(hPrn, 2, 0, 0, BytesNeeded)
If Err.LastDllError = ERROR_INSUFFICIENT_BUFFER Then
ReDim Buffer(BytesNeeded - 1)


nRet = GetPrinter(hPrn, 2, Buffer(0), BytesNeeded,
BytesUsed)


end if
 
C

Cesar Ronchese

Download the ApiGuide from www.allapi.net. That program have samples of most
WinAPIs, and some samples for .Net. If no .Net sample is available, it shows
the class that replaced the API function.

[]s
Cesar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top