巧了。。刚才还在钻研这个api,成果分享下~
$dwNotifyFilter = bitOr(1, 2, 4, 8)
$hNotification = DllCall("kernel32.dll", "hWnd", "FindFirstChangeNotification", _
"str", @ScriptDir, "int", True, "dword", $dwNotifyFilter)
While True
$dwResult = DllCall("kernel32.dll", "dword", "WaitForSingleObject", _
"hWnd", $hNotification[0], "dword", 100000)
If not $dwResult[0] Then msgbox(0, $dwResult[0], '')
DllCall("kernel32.dll", "int", "FindNextChangeNotification", "hWnd", $hNotification[0])
WEnd
Func OnAutoItExit()
DllCall("kernel32.dll", "int", "FindCloseChangeNotifycation", "hWnd", $hNotification[0])
Exit(0)
EndFunc ;==>OnAutoItExit()
测试方法,在当前脚本(子)目录新建/删除/重命名文件,会弹出个提示。但还不能截取到是哪个文件发生了改变。在ReadDirectoryChangesW处卡壳了~ |