刚才看到你原来的帖子了,我想你可能把问题复杂化了,你看能不能这样,把同一文档发给不同打印机这件事,转换成:打印文档,然后切换默认打印机,然后再打印文档。
至于切换打印机,以及查询现有打印机,请参考Afan大大的代码,如下:#include <WinAPI.au3>
GUICreate('切换默认打印机', 380, 70)
GUICtrlCreateLabel('默认打印机:', 10, 15, 90, 17)
$combo = GUICtrlCreateCombo('', 85, 10, 210, 20, 0x0003) ; $CBS_DROPDOWNLIST=0x0003
GUICtrlSetData(-1, EnumPrinter())
GUICtrlSetData(-1, GetDefaultPrinterName())
$Button = GUICtrlCreateButton('应用(&Y)', 295, 9, 70, 22)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $Button
$sPrinter = GUICtrlRead($combo)
_WinAPI_SetDefaultPrinter($sPrinter)
If GetDefaultPrinterName() = $sPrinter Then MsgBox(64, '完成', '设置成功~ ')
EndSwitch
WEnd
Func EnumPrinter()
Local $data = '', $i = 1, $Val
While 1
$Val = RegEnumVal('HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices', $i)
If @error <> 0 Then ExitLoop
$data &= $Val & '|'
$i += 1
WEnd
Return $data
EndFunc ;==>EnumPrinter
Func GetDefaultPrinterName()
Return StringRegExpReplace(RegRead('HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows', 'Device'), '(.+?),.+', '$1')
EndFunc ;==>GetDefaultPrinterName
|