Changing Windows Default Printer

Supposedly this does the job:
Private Sub SetDefaultPrinter(ByVal PrinterName As String, _
ByVal DriverName As String, ByVal PrinterPort As String)
Dim DeviceLine As String

'rebuild a valid device line string
DeviceLine = PrinterName & "," & DriverName & "," & PrinterPort

'Store the new printer information in the
'[WINDOWS] section of the WIN.INI file for
'the DEVICE= item
Call WriteProfileString("windows", "Device", DeviceLine)

'Cause all applications to reload the INI file
Call SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, "windows")

End Sub
Private Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" _
(ByVal lpszSection As String, ByVal lpszKeyName As String, _
ByVal lpszString As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lparam As String) As Long
Private Const HWND_BROADCAST As Long = &HFFFF&
Private Const WM_WININICHANGE As Long = &H1A

'in a sub:
SetDefaultPrinter(strPrinterName, "", "")
'where strPrinterName contains the name of the printer you want
Source: vbCity/DevCity.NET Forums :: .NET :: VB.NET :: Change default printer in vb.net

Also, something along the lines of this CodeGuru Forums - Change Default printer might work too
 
Back
Top