使用_Net_Share_ShareAdd 共享打印机没反应,_Net_Share_ShareCheck 也不能很好地检测到在WINDOWS里设置的共享打印机
_Net_Share_ShareAdd 第三个参数不是很明白: $STYPE_PRINTQ 难道是打印队列不是打印机本身?
共享文件夹倒是没有问题,不知如何才能共享指定的打印机
不明白为什么 _Net_Share_ShareCheck 不能检测到,但用_Net_Share_ShareEnum 却看到
有打印机的兄弟麻烦帮忙一下,谢谢
运行环境:
WIN7 X64
版本 3.3.9.4
#region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_UseX64=n
#PRE_Res_requestedExecutionLevel=None
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <NetShare.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form4 = GUICreate("窗体1", 405, 294, 554, 331)
$Button1 = GUICtrlCreateButton("共享", 276, 184, 75, 25)
$Button2 = GUICtrlCreateButton("删除共享", 280, 232, 75, 25)
$Combo1 = GUICtrlCreateCombo("Combo1", 44, 84, 333, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
_wmi_Win32_ShowaddPrinter()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$sShareName = "AUTOIT-PRINT"
If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
;_Net_Share_ShareAdd(@ComputerName, $sShareName, $STYPE_DEVICE, GUICtrlRead($Combo1))
_Net_Share_ShareAdd(@ComputerName, $sShareName, $STYPE_PRINTQ, GUICtrlRead($Combo1), "AutoIt Share Comment")
If @error Then MsgBox(4096, "信息", "Share add error : " & @error)
MsgBox(4096, "信息", "OK : " )
Else
MsgBox(4096, "信息", $sShareName& " 已在 " )
EndIf
Case $Button2
_Net_Share_ShareDel(@ComputerName, $sShareName)
If @error Then MsgBox(4096, "信息", "Share delete error : " & @error)
MsgBox(4096, "信息", "OK : ")
EndSwitch
WEnd
Func _wmi_Win32_ShowaddPrinter()
Local $strComputer = "localhost"
Local $Output = ""
Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
If IsObj($objWMIService) Then
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL", 48)
For $objItem In $colItems
$Output &= $objItem.Caption & "|"
Next
EndIf
GUICtrlSetData($Combo1, $Output)
;MsgBox(1,$strComputer&"连接的打印机和传真为:",$Output)
EndFunc ;==>_wmi_Win32_ShowaddPrinter
|