⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.frm

📁 很好的教程原代码!
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Main 
   Caption         =   "Form1"
   ClientHeight    =   4035
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5460
   LinkTopic       =   "Form1"
   ScaleHeight     =   4035
   ScaleWidth      =   5460
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "设定成预设的打印机"
      Height          =   495
      Left            =   120
      TabIndex        =   1
      Top             =   2880
      Width           =   3015
   End
   Begin VB.ListBox List1 
      Height          =   1860
      Left            =   120
      TabIndex        =   0
      Top             =   600
      Width           =   4455
   End
End
Attribute VB_Name = "Main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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
    Else
        
        WriteProfileString "windows", "device", Device
        SendMessage HWND_BROADCAST, WM_WININICHANGE, 32767&, ByVal "windows"
    End If
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


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -