'\\ --[SpoolerApi]------------------------------------------------
'\\ Printer Spooler API calls from winspool.drv
'\\ --------------------------------------------------------------
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.ComponentModel
Module SpoolerApi
#Region "GetPrintProcessorDirectory"
'BOOL GetPrintProcessorDirectory(
' [in] LPTSTR pName, // server name
' [in] LPTSTR pEnvironment, // environment name
' [in] DWORD Level, // information level
' [out] LPBYTE pPrintProcessorInfo, // path buffer
' [in] DWORD cbBuf, // size of path buffer
' [out] LPDWORD pcbNeeded // bytes received or required
<DllImport("winspool.drv", EntryPoint:="GetPrintProcessorDirectory", _
SetLastError:=True, _
ExactSpelling:=False, _
CallingConvention:=CallingConvention.StdCall)> _
Private Function GetPrintProcessorDirectoryApi( _
<InAttribute()> ByVal pName As String, _
<InAttribute()> ByVal pEnvironment As String, _
<InAttribute()> ByVal Level As Int32, _
<OutAttribute()> ByVal pPrintProcessorInfo As StringBuilder, _
<InAttribute()> ByVal cbBuf As Int32, _
<OutAttribute()> ByRef pcbNeeded As Int32) As Boolean
End Function
Public Function GetPrintProcessorDirectory() As String
Dim sProcessorInfo As New StringBuilder(260)
Dim pcbNeeded As Int32
If GetPrintProcessorDirectoryApi("", "", 1, sProcessorInfo, sProcessorInfo.Capacity, pcbNeeded) Then
Return sProcessorInfo.ToString
Else
Throw New Win32Exception()
End If
End Function
#End Region
#Region "GetPrinterDriverDirectory"
'BOOL GetPrinterDriverDirectory(
' [in] LPTSTR pName, // server name
' [in] LPTSTR pEnvironment, // environment name
' [in] DWORD Level, // information level
' [out] LPBYTE pDriverDirectory, // path buffer
' [in] DWORD cbBuf, // size of path buffer
' [out] LPDWORD pcbNeeded // bytes received or required
<DllImport("winspool.drv", EntryPoint:="GetPrinterDriverDirectory", _
SetLastError:=True, _
ExactSpelling:=False, _
CallingConvention:=CallingConvention.StdCall)> _
Private Function GetPrinterDriverDirectoryApi( _
<InAttribute()> ByVal pName As String, _
<InAttribute()> ByVal pEnvironment As String, _
<InAttribute()> ByVal Level As Int32, _
<OutAttribute()> ByVal pDriverDirectory As StringBuilder, _
<InAttribute()> ByVal cbBuf As Int32, _
<OutAttribute()> ByRef pcbNeeded As Int32) As Boolean
End Function
Public Function GetPrinterDriverDirectory() As String
Dim sDirectory As New StringBuilder(260)
Dim pcbNeeded As Int32
If GetPrinterDriverDirectoryApi("", "", 1, sDirectory, sDirectory.Capacity, pcbNeeded) Then
Return sDirectory.ToString
Else
Throw New Win32Exception()
End If
End Function
#End Region
End Module