感谢您使用微软产品。您可以使用WMI的Win32_Printer对象获得所有打印机支持的纸张大小的信息,如下例:Private Sub Command1_Click() WQL = "Select * From Win32_Printer" Set objinst = GetObject("winmgmts:").ExecQuery(WQL) For Each obj In objinst Debug.Print obj.Name Dim type1 As String For i = 1 To UBound(obj.PaperSizesSupported) Debug.Print obj.PaperSizesSupported(i) Next NextEnd Sub详细信息请参考:Win32_Printerhttp://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_printer.asp - 微软全球技术中心 VB技术支持本帖子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。======================
谢谢acptvb,我正在try,如有问题,我再向您请教。
To acptvb:It should use the object PrinterPaperNames not the object PaperSizesSupported to get the PaperNames array.When you run the following code, the Papernames list can be printed out.Option ExplicitPrivate Sub Command1_Click() Dim WQL As String Dim objinst As Object Dim obj As Object Dim i As Long
WQL = "Select * From Win32_Printer" Set objinst = GetObject("winmgmts:").ExecQuery(WQL) For Each obj In objinst Debug.Print obj.Name Dim type1 As String For i = 1 To UBound(obj.PrinterPaperNames) Debug.Print obj.PrinterPaperNames(i) Next NextEnd Sub
Set comp = GetObject("winmgmts:{impersonationLevel=impersonate}!//yourRemoteMachine").InstancesOf("Win32_ComputerSystem") For Each obj In comp Debug.Print obj.Name Debug.Print obj.DoMain Debug.Print obj.SystemType Debug.Print obj.Manufacturer Next
相关文章参考:Microsoft Windows Management Instrumentation: Background and Overview http://msdn.microsoft.com/library/en-us/dnwmi/html/msdn_wmiwp.asp?frame=trueManaging Windows with WMI http://msdn.microsoft.com/library/en-us/dnwmi/html/mngwmi.asp?frame=trueWindows Management Instrumentation: Administering Windows and Applications across Your Enterprise http://msdn.microsoft.com/msdnmag/issues/0500/wmiover/toc.asp?frame=trueWindows Management Instrumentation (Platform SDK for WMI) http://msdn.microsoft.com/library/en-us/wmisdk/wmi/wmi_start_page.asp?frame=true
- 微软全球技术中心 VB技术支持本帖子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。======================
Dim objinst As Object
Dim obj As Object
Dim i As Long
WQL = "Select * From Win32_Printer" Set objinst = GetObject("winmgmts:").ExecQuery(WQL) For Each obj In objinst Debug.Print obj.Name Dim type1 As String For i = 1 To UBound(obj.PrinterPaperNames) Debug.Print obj.PrinterPaperNames(i) Next NextEnd Sub
For Each obj In comp
Debug.Print obj.Name
Debug.Print obj.DoMain
Debug.Print obj.SystemType
Debug.Print obj.Manufacturer
Next
http://msdn.microsoft.com/library/en-us/dnwmi/html/msdn_wmiwp.asp?frame=trueManaging Windows with WMI
http://msdn.microsoft.com/library/en-us/dnwmi/html/mngwmi.asp?frame=trueWindows Management Instrumentation: Administering Windows and Applications across Your Enterprise
http://msdn.microsoft.com/msdnmag/issues/0500/wmiover/toc.asp?frame=trueWindows Management Instrumentation (Platform SDK for WMI)
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/wmi_start_page.asp?frame=true