aux649350702 发表于 2011-2-22 21:37:55

根据下面的代码,谁能作个删除选中打印机的应用?

#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
上面代码转转自论坛,再次对作者表示感谢。
这个代码是切换默认打印机的,能作成删除选中打印机的效果么?
页: [1]
查看完整版本: 根据下面的代码,谁能作个删除选中打印机的应用?