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
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