找回密码
 加入
搜索
查看: 1557|回复: 2

请教下VB的API转换

[复制链接]
发表于 2009-3-26 19:20:00 | 显示全部楼层 |阅读模式
Declare Function FindFirstChangeNotification Lib "kernel32" Alias "FindFirstChangeNotificationA" (ByVal lpPathName As String, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long) As Long
以上代码在autoit中如何转换?
新手,不知道代码有没有错,本意是想问下API的FindFirstChangeNotification在autoit的用法.
发表于 2009-3-26 19:52:11 | 显示全部楼层
巧了。。刚才还在钻研这个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处卡壳了~

评分

参与人数 1金钱 +10 收起 理由
ceoguang + 10

查看全部评分

 楼主| 发表于 2009-3-26 20:46:24 | 显示全部楼层
谢谢LS.
又找了相关方面的资料,原来ReadDirectoryChangesW()以及FindFirstChangeNotification()都会存在漏报的情况.此问题的更好解决方法是使用文件驱动过滤,头大啊!
不知道论坛有没有VC高手来帮忙注释下filemon的源码.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 05:24 , Processed in 0.072371 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表