zoukankan      html  css  js  c++  java
  • VB6 获取和设置默认打印机

    Private Declare Function GetProfileString 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 GetDeviceName() As String
    Dim di As String
    def$ = String(128, 0)
    di = GetProfileString("WINDOWS", "DEVICE", "", def$, 127)
    GetDeviceName = Trim(def$)
    GetDeviceName = Left(GetDeviceName, InStr(GetDeviceName, ",") - 1)
    End Function
    Private Sub Command1_Click()
    Dim a As String
    MsgBox GetDeviceName
    a = GetDeviceName()
    Call setDefaultPrinter_To_System("PDF995")
    End Sub


    Public Sub setDefaultPrinter_To_System(devcName As String)
        Dim X As Printer
        Dim WshNetwork As Object
        Dim k As Long


        k = 0
        For Each X In Printers
           If X.DeviceName = devcName Then
              ' Set printer as system default.
              Set Printer = X
              Set WshNetwork = CreateObject("WScript.Network")
              WshNetwork.setDefaultPrinter (Printers(k).DeviceName)
              ' Stop looking for a printer.
              Exit For
           End If
           k = k + 1
        Next
        
    End Sub

  • 相关阅读:
    columns布局应用场景
    flex速记
    css属性选择器模糊匹配
    ydui的rem适配方案
    vscode搜索失效问题
    ESP8266 超声波测距模块HC-SR04
    树莓派PICO Wifi 无线网卡 esp82666接线图
    查看数据库容量大小
    面试官问我JVM内存结构,我真的是
    深入浅出Java内存模型
  • 原文地址:https://www.cnblogs.com/rosesmall/p/4938813.html
Copyright © 2011-2022 走看看