Option Explicit
Const KeyName = "Software\Microsoft\Windows NT\CurrentVersion\Windows"
Private Sub Command1_Click()
Dim Ver As OSVERSIONINFO, S As String, hKey As Long'提示OSVERSIONINFO用户定义类型未定义,请问如何解决,还是需要引用什么啊?
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
Dim Ver As OSVERSIONINFO, S As String, hKey As Long'提示OSVERSIONINFO用户定义类型未定义,请问如何解决,还是需要引用什么啊?
Const KeyName = "Software\Microsoft\Windows NT\CurrentVersion\Windows"
Private Sub Command1_Click()
Dim Ver As OSVERSIONINFO, S As String, hKey As Long'提示OSVERSIONINFO用户定义类型未定义,请问如何解决,还是需要引用什么啊?
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
Dim Ver As OSVERSIONINFO, S As String, hKey As Long'提示OSVERSIONINFO用户定义类型未定义,请问如何解决,还是需要引用什么啊?