Applecore Pages on Microsoft Access

Get the Name of the Default Windows Printer

The easiest way that I have found to return the name of the default Windows Printer is to read the information from the WIN.INI file, which automatically references the Registry for 32-bit versions of Windows.

Option Compare Database
Option Explicit
 
Public Declare Function apiGetProfileString Lib "kernel32" Alias "GetProfileStringA" _
    (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, _
    ByVal lpReturnedString As String, ByVal nSize As Long) As Long
 
Function fDefaultPrinter() As String
    Dim strBuffer As String * 254
    Dim lngReturn As Long
    Dim strDefaultPrinter As String
    lngReturn = apiGetProfileString("WINDOWS", "DEVICE", ",,,", strBuffer, Len(strBuffer))
    fDefaultPrinter = Left(strBuffer, InStr(strBuffer, vbNullChar) - 1)
End Function

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:53:14