zoukankan      html  css  js  c++  java
  • vb 获取打印机名称

    Const HKLM = &H80000002 '定义根键常数
    '其他常用根键 Const HKCR = &H80000000 , Const HKCU = &H80000001
    Set oReg = GetObject("winmgmts:\. ootdefault:StdRegProv")
    strKeyPath = "SOFTWAREMicrosoftWindowsCurrentVersionApp Paths"
    oReg.EnumKey HKLM, strKeyPath, arrSubKeys '枚举子项,赋值给数组arrSubKeys
    For Each subkey In arrSubKeys
    Print subkey
    Next

    For Each x In Printers
     FindPrinter strPrint, x.DeviceName
    next

    Function FindPrinter(ByRef PrinterName As String, Optional ByVal PrinterDescription As String = "") As Boolean
    ' 查指定打印机
    Dim objRegistry As Object
    Dim arrSubKeys As Variant
    Dim subkey As Variant
    Dim KeyValue As Variant

    If Len(PrinterDescription) > 0 Then
    Set objRegistry = GetObject("winmgmts:\. ootdefault:StdRegProv")
    objRegistry.EnumValues &H80000001, "SoftwareMicrosoftWindows NTCurrentVersionPrinterPorts", arrSubKeys
    For Each subkey In arrSubKeys
    If InStr(1, subkey, PrinterDescription) Then
    objRegistry.GetStringValue &H80000001, "SoftwareMicrosoftWindows NTCurrentVersionPrinterPorts", subkey, KeyValue
    PrinterName = subkey & " 在 " & Mid(KeyValue, InStr(KeyValue, ",") + 1, InStr(KeyValue, ":,") - InStr(KeyValue, ","))
    FindPrinter = True
    Exit For
    End If
    Next
    Set objRegistry = Nothing
    End If
    End Function

  • 相关阅读:
    scrapy 断点续爬
    Tornado
    python 列表去重的几种方法
    安装Mysql-python报错EnvironmentError: mysql_config not found
    安装setuptools 报错缺少zlib
    微信小程序-if条件渲染
    微信小程序-遍历列表
    微信小程序-数据绑定
    超强过滤器
    如何在tomcat安装部署php项目
  • 原文地址:https://www.cnblogs.com/rosesmall/p/3140438.html
Copyright © 2011-2022 走看看