香港新浪網 MySinaBlog
« 上一篇 | 下一篇 »
Emily | 23rd Apr 2006, 10:44 AM | API / Add-in | (1018 Reads)

 API Get Default Printer Name

'---------------------------------------------------------------------------------------
' Module    : Module1
' DateTime  : 23/4/2006 10:43
' Author    :
' Purpose   : API Get Default Printer Name
'---------------------------------------------------------------------------------------
Private Declare Function GetProfileString Lib "kernel32.dll" 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 Get_DefaultPrinterName() As String
Const BUFFSIZE As Long = 254

Dim strBuffer As String * BUFFSIZE
Dim lngRetVal As Long

    lngRetVal = GetProfileString("windows", "device", ",,,", strBuffer, BUFFSIZE)
    Get_DefaultPrinterName = Left(strBuffer, InStr(strBuffer, ":"))
    
End Function

 ' 

参考:Get Printer Port , Printer Status