#include <GUIConstantsEx.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Date.au3>
$day = @MDAY
$sLogPath=@ScriptDir
$LogFile = FileOpen($sLogPath & "" & @MON & "月" & @MDAY & "日" & ".txt",1+8)
Global $bInfo[1][1]
OnAutoItExitRegister("Onexit" )
MemoWrite("程序启动")
While 1
If $day <> @MDAY Then
FileClose($sLogPath & "" & @MON & "月" & $day & "日" & ".txt")
$LogFile = FileOpen($sLogPath & "" & @MON & "月" & @MDAY & "日" & ".txt",1+8)
$day = @MDAY
EndIf
Example()
Sleep(1000)
WEnd
Func Example()
Local $aInfo
$server=("\\homepc")
$share=("e")
$aInfo=_Net_Share_ConnectionEnum($server,$share)
If @error Then MemoWrite("Error ...................: " & @error)
;MemoWrite("Entries read ............: " & $aInfo[0][0])
For $iI = 1 To $aInfo[0][0]
Local $yes = 0
For $x = 1 To $bInfo[0][0]
If $aInfo[$iI][0] = $bInfo[$x][0] Then
$yes = 1
$bInfo[$x][0] = ""
$bInfo[$x][1] = ""
$bInfo[$x][2] = ""
$bInfo[$x][3] = ""
$bInfo[$x][4] = ""
$bInfo[$x][5] = ""
$bInfo[$x][6] = ""
ExitLoop
EndIf
Next
If Not $yes Then
MemoWrite("登入")
MemoWrite("Connection ID ...........: " & $aInfo[$iI][0])
MemoWrite("Connection type..........: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
MemoWrite("Number of files open ....: " & $aInfo[$iI][2])
MemoWrite("Number of users .........: " & $aInfo[$iI][3])
MemoWrite("Connection time .........: " & $aInfo[$iI][4])
MemoWrite("User name ...............: " & $aInfo[$iI][5])
MemoWrite("Computer name ...........: " & $aInfo[$iI][6])
MemoWrite("************************************************************")
EndIf
Next
For $x = 1 To $bInfo[0][0]
If $bInfo[$x][0] <> "" then
MemoWrite("退出")
MemoWrite("Connection ID ...........: " & $bInfo[$x][0])
MemoWrite("Connection type..........: " & _Net_Share_ResourceStr($bInfo[$x][1]))
MemoWrite("Number of files open ....: " & $bInfo[$x][2])
MemoWrite("Number of users .........: " & $bInfo[$x][3])
MemoWrite("Connection time .........: " & $bInfo[$x][4])
MemoWrite("User name ...............: " & $bInfo[$x][5])
MemoWrite("Computer name ...........: " & $bInfo[$x][6])
MemoWrite("************************************************************")
EndIf
Next
$bInfo = $aInfo
EndFunc
Func MemoWrite($message="")
FileWriteLine($LogFile, _NowCalc() & " " & $message & @CRLF)
EndFunc
Func Onexit()
MemoWrite("程序正常退出")
EndFunc
|