#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\图标\13.ico
#AutoIt3Wrapper_outfile=af.exe
#AutoIt3Wrapper_Compression=3
#AutoIt3Wrapper_Res_Comment=智能网关绑定器
#AutoIt3Wrapper_Res_Description=智能网关绑定器
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=叁恨居士
#AutoIt3Wrapper_Res_Field=说明|网吧专用
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt('MustDeclareVars', 1)
_Singleton("Gateway")
Global $IniFile
$IniFile = StringReplace(@ScriptFullPath & "?", StringTrimLeft(@ScriptName, StringInStr(@ScriptName, '.', 0, -1)) & "?", "ini")
If Not FileExists($IniFile) Then
_WriteMac()
Exit
EndIf
_Gatewaybundled()
Func _Gatewaybundled()
Local $Gateway,$GatewayMac,$AutoRun
$Gateway=IniRead($IniFile,"Bundled","Ip","")
$GatewayMac=IniRead($IniFile,"Bundled","Mac","")
$AutoRun=IniRead($IniFile,"Bundled","AutoRun","")
RunWait(@ComSpec & ' /c arp -d',@SystemDir, @SW_HIDE)
RunWait(@ComSpec & ' /c \flarp.exe Freeland='&$Gateway&' '&$GatewayMac&' 1 freeland false', @SystemDir, @SW_HIDE)
Switch $AutoRun
Case 0
RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Run",@ScriptName)
Case 1
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Run",@ScriptName,"REG_SZ",@ScriptFullPath)
EndSwitch
EndFunc ;==>_Gatewaybundled()
Func _WriteMac()
Local $IniIp,$IniMac,$foo,$line,$lines,$Tmp_Gateway,$x
$foo = Run(@ComSpec & " /c ipconfig/all", @SystemDir, @SW_HIDE, 2)
$lines = ""
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
$lines &= $line
Wend
$lines = StringSplit($lines,@CRLF,1)
For $x = 1 To $lines[0]
If StringInStr($lines[$x], "Gateway") Then
$Tmp_Gateway=StringSplit(StringStripWS($lines[$x],8),":")
ExitLoop
Exit
EndIf
Next
$IniIp=InputBox("获取远程计算机MAC",@CRLF&@CRLF&"请输入远程计算机的IP地址",$Tmp_Gateway[2],"",-1,-1,-1,-1)
If @error Then Exit
$IniMac=_GetMAC($IniIp)
If @error Then MsgBox(16,"错误","获取指定"&$IniIp&"的MAC地址失败")
IniWrite($IniFile,"Bundled","Ip",$IniIp)
IniWrite($IniFile,"Bundled","Mac",$IniMac)
IniWrite($IniFile,"Bundled","AutoRun","1")
EndFunc ;==>_WriteMac()
Func _GetMAC($sIP)
Local $MAC,$MACSize
Local $i,$s,$r,$iIP
$MAC = DllStructCreate("byte[6]")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize,1,6)
$r = DllCall ("Ws2_32.dll", "int", "inet_addr", "str", $sIP)
$iIP = $r[0]
$r = DllCall ("iphlpapi.dll", "int", "SendARP","int", $iIP,"int", 0,"ptr", DllStructGetPtr($MAC),"ptr", DllStructGetPtr($MACSize))
$s = ""
For $i = 0 To 5
If $i Then $s = $s & "-"
$s = $s & Hex(DllStructGetData($MAC,1,$i+1),2)
Next
If $s = "00-00-00-00-00-00" Then SetError(1)
Return $s
EndFunc ;==>_GetMAC()
Func _Singleton($sOccurenceName, $iFlag = 0)
Local Const $ERROR_ALREADY_EXISTS = 183
Local Const $SECURITY_DESCRIPTOR_REVISION = 1
Local $handle, $lastError, $pSecurityAttributes = 0
If BitAND($iFlag, 2) Then
Local $structSecurityDescriptor = DllStructCreate("dword[5]")
Local $pSecurityDescriptor = DllStructGetPtr($structSecurityDescriptor)
Local $aRet = DllCall("advapi32.dll", "int", "InitializeSecurityDescriptor", _
"ptr", $pSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION)
If Not @error And $aRet[0] Then
$aRet = DllCall("advapi32.dll", "int", "SetSecurityDescriptorDacl", _
"ptr", $pSecurityDescriptor, "int", 1, "ptr", 0, "int", 0)
If Not @error And $aRet[0] Then
Local $structSecurityAttributes = DllStructCreate("dword;ptr;int")
DllStructSetData($structSecurityAttributes, 1, DllStructGetSize($structSecurityAttributes))
DllStructSetData($structSecurityAttributes, 2, $pSecurityDescriptor)
DllStructSetData($structSecurityAttributes, 3, 0)
$pSecurityAttributes = DllStructGetPtr($structSecurityAttributes)
EndIf
EndIf
EndIf
$handle = DllCall("kernel32.dll", "int", "CreateMutex", "ptr", $pSecurityAttributes, "long", 1, "str", $sOccurenceName)
$lastError = DllCall("kernel32.dll", "int", "GetLastError")
If $lastError[0] = $ERROR_ALREADY_EXISTS Then
If BitAND($iFlag, 1) Then
Return SetError($lastError[0], $lastError[0], 0)
Else
Exit -1
EndIf
EndIf
Return $handle[0]
EndFunc ;==>_Singleton
为什么我这一句都没有执行起来呀RunWait(@ComSpec & ' /c \flarp.exe Freeland='&$Gateway&' '&$GatewayMac&' 1 freeland false', @SystemDir, @SW_HIDE),如位高手帮忙呀!
附flarp.exe 执行参数批处理实例:flarp.exe Freeland=192.168.1.1 00-74-05-7C-70-24 1 freeland false
[ 本帖最后由 fjvip 于 2008-12-23 10:23 编辑 ] |