本帖最后由 hao1032 于 2013-3-10 18:53 编辑
everything是一个快速搜索的工具,官网提供了sdk,可以通过dll和everything进程通信。
需要安装everything软件并开启,才能使用dll
sdk地址:http://support.voidtools.com/everything/SDK
以下是python代码,及运行结果(有4480个txt文档):#coding=utf-8
from ctypes import *
import sys,os
superSearch=windll.LoadLibrary("Everything.dll")
superSearch.Everything_SetSearchW(c_wchar_p("*.txt"))
superSearch.Everything_QueryW(1)
rsNum=superSearch.Everything_GetNumResults()
print "txt num:", rsNum
del superSearch
>>>
txt num: 4480
>>>
下面是我写的autoit脚本,及结果(0个txt文档):$dll = DllOpen("Everything.dll")
$result = DllCall($dll, "none", "Everything_SetSearchW", "wstr", "*.txt")
$result = DllCall($dll, "none", "Everything_QueryW", "BOOL", 1)
$result = DllCall($dll, "DWORD", "Everything_GetNumResults", "none")
DllClose($dll)
MsgBox(0, 'test', $result)
求高手指教,是哪里出错了??(个人认为是Everything_SetSearchW函数的参数类型问题,但是不知道怎么改)
发玩帖子后,在论坛看到了这个文章:http://www.autoitx.com/forum.php?mod=viewthread&tid=26755
看到了这句话:至於 $Result[0] 本身代表我們調用的 win32 API 它的返回值。
然后将将代码改成了下面的样子,发现能结果就正确了$dll = DllOpen("Everything.dll")
$result = DllCall($dll, "none", "Everything_SetSearchW", "wstr", "*.txt")
$result = DllCall($dll, "none", "Everything_QueryW", "BOOL", 1)
$result = DllCall($dll, "DWORD", "Everything_GetNumResults")
DllClose($dll)
MsgBox(0, 'test', $result[0])
|