文件名称:VB设置默认打印机设置默认打印机
文件大小:3KB
文件格式:RAR
更新时间:2013-01-08 15:22:07
VB设置默认打印机
Option Explicit Const KeyName = "Software\Microsoft\Windows NT\CurrentVersion\Windows" Private Sub Command1_Click() Dim Ver As OSVERSIONINFO, S As String, hKey As Long Dim Device As String, length As Long Ver.dwOSVersionInfoSize = Len(Ver) GetVersionEx Ver Device = List1.Text length = LenB(StrConv(Device, vbFromUnicode)) + 1 If Ver.dwPlatformId = VER_PLATFORM_WIN32_NT Then RegOpenKey HKEY_CURRENT_USER, KeyName, hKey RegSetValueEx hKey, "Device", 0, REG_SZ, ByVal Device, length RegCloseKey hKey MsgBox "设置默认打印机: " & List1.Text & " 成功!", vbInformation, "温馨提示" Else WriteProfileString "windows", "device", Device SendMessage HWND_BROADCAST, WM_WININICHANGE, 32767&, ByVal "windows" End If End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Form_Load() Dim i As Integer For i = 0 To Printers.Count - 1 List1.AddItem Printers(i).DeviceName & "," & _ Printers(i).DriverName & "," & _ Printers(i).Port Next End Sub
【文件预览】:
GetPrinter_Module.bas
MSSCCPRJ.SCC
GetPrinter.vbw
GetPrinter.vbp
Printer.vbw
GetPrinter.frm