- 博客(0)
- 资源 (1)
空空如也
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
2009-12-19
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人