命令: rundll32.exe shell32.dll,Control_RunDLL main.cpl @2 结果: 显示打印机属性。例子: Dim x x = Shell("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder")
用 API 打开打印对话框 声明: Declare Function PRINTDLG Lib "comdlg32.dll" Alias _ "PrintDlgA" (pPrintdlg As PRINTDLG) As Long Type PRINTDLG lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long hdc As Long flags As Long nFromPage As Integer nToPage As Integer nMinPage As Integer nMaxPage As Integer nCopies As Integer hInstance As Long lCustData As Long lpfnPrintHook As Long lpfnSetupHook As Long lpPrintTemplateName As String lpSetupTemplateName As String hPrintTemplate As Long hSetupTemplate As Long End Type 使用: Private Sub Command1_Click() Dim p As PRINTDLG p.lStructSize = Len(p) p.hwndOwner = Me.hWnd p.nFromPage = 1 p.nToPage = 1 p.nMinPage = 1 p.nMaxPage = 1 p.nCopies = 1 x = PRINTDLG(p) Printer.Print Text1.Text End Sub
结果: 显示打印机属性。例子:
Dim x
x = Shell("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder")
声明:
Declare Function PRINTDLG Lib "comdlg32.dll" Alias _
"PrintDlgA" (pPrintdlg As PRINTDLG) As Long
Type PRINTDLG
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
hdc As Long
flags As Long
nFromPage As Integer
nToPage As Integer
nMinPage As Integer
nMaxPage As Integer
nCopies As Integer
hInstance As Long
lCustData As Long
lpfnPrintHook As Long
lpfnSetupHook As Long
lpPrintTemplateName As String
lpSetupTemplateName As String
hPrintTemplate As Long
hSetupTemplate As Long
End Type
使用:
Private Sub Command1_Click()
Dim p As PRINTDLG
p.lStructSize = Len(p)
p.hwndOwner = Me.hWnd
p.nFromPage = 1
p.nToPage = 1
p.nMinPage = 1
p.nMaxPage = 1
p.nCopies = 1
x = PRINTDLG(p)
Printer.Print Text1.Text
End Sub