Module NativeMethods Public Const STANDARD_RIGHTS_REQUIRED As Integer = &HF0000 Public Const PRINTER_ACCESS_ADMINISTER As Integer = &H4 Public Const PRINTER_ACCESS_USE As Integer = &H8 Public Const PRINTER_ALL_ACCESS As Integer = STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE Public Structure PRINTER_DEFAULTS Public pDatatype As IntPtr Public pDevMode As IntPtr Public DesiredAccess As Integer End Structure <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> Public Structure PRINTER_INFO_2 Public pServerName As String Public pPrinterName As String Public pShareName As String Public pPortName As String Public pDriverName As String Public pComment As String Public pLocation As String Public pDevMode As IntPtr Public pSepFile As String Public pPrintProcessor As String Public pDatatype As String Public pParameters As String Public pSecurityDescriptor As IntPtr Public Attributes As Integer Public Priority As Integer Public DefaultPriority As Integer Public StartTime As Integer Public UntilTime As Integer Public Status As Integer Public cJobs As Integer Public AveragePPM As Integer End Structure <DllImport("winspool.drv", CharSet:=CharSet.Auto)> Public Function OpenPrinter(pPrinterName As String, ByRef phPrinter As IntPtr, ByRef pDefault As PRINTER_DEFAULTS) As Boolean End Function <DllImport("winspool.drv", CharSet:=CharSet.Auto)> Public Function SetPrinter(hPrinter As IntPtr, Level As Integer, ByRef pi2 As PRINTER_INFO_2, command As Integer) As Boolean End Function <DllImport("winspool.drv", SetLastError:=True, CharSet:=CharSet.Auto)> Public Function GetPrinter(hPrinter As IntPtr, dwLevel As Integer, pPrinter As IntPtr, cbBuf As Integer, ByRef pcbNeeded As Integer) As Boolean End Function <DllImport("winspool.drv", SetLastError:=True)> Public Function ClosePrinter(hPrinter As IntPtr) As Boolean End Function <DllImport("kernel32.dll")> Public Function GlobalFree(hMem As IntPtr) As IntPtr End Function <DllImport("kernel32.dll")> Public Function GlobalLock(hMem As IntPtr) As IntPtr End Function <DllImport("kernel32.dll")> Public Function GlobalUnlock(hMem As IntPtr) As Boolean End Function End Module