本帖最后由 iamwonvy 于 2012-9-5 22:23 编辑
http://finder.sdo.com/upload/for ... thread&tid=1232
一共四个函数,三个函数已经写好了,FindA / FindW这个函数的回调函数返回不了数组,
风行者说要创建结构,我不是很懂……
#include <Array.au3>
;;-----------------------------------------------------------------------------------------------------------------
;启动Finder
Func LaunchFinder()
local $hDll = DllOpen("finderlib64.dll")
$result = DllCall($hDll, "bool", "LaunchFinder")
If @error Then ConsoleWrite(@error)
If IsArray($result) Then
If $result[0]=1 Then
MsgBox(0,"","Finder启动成功")
Else
MsgBox(0,"","Finder启动失败")
EndIf
EndIf
DllClose($hDll)
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;~ ;监测调用环境,比如Finder是否存在
;~ local $hDll = DllOpen("finderlib64.dll")
;~ $result = DllCall($hDll, "Int", "CheckRequirement")
;~ If @error Then ConsoleWrite(@error)
;~ If IsArray($result) Then
;~ Switch $result[0]
;~ Case 0
;~ MsgBox(0,0,"无错")
;~ Case 1
;~ MsgBox(0,1,"超时")
;~ Case 2
;~ MsgBox(0,2,"Finder没有运行")
;~ Case 3
;~ MsgBox(0,3,"通信出错")
;~ Case 4
;~ MsgBox(0,4,"Finder版本不支持")
;~ Case 9
;~ MsgBox(0,9,"Finder没有安装")
;~ Case 10
;~ MsgBox(0,10,"Finder正在初始化当中")
;~ Case 99
;~ MsgBox(0,99,"未知错误")
;~ Case Else
;~ _ArrayDisplay($result, "其它")
;~ EndSwitch
;~ EndIf
;~ DllClose($hDll)
;-----------------------------------------------------------------------------------------------------------------
;~ ;Finder是否已经在运行
;~ local $hDll = DllOpen("finderlib64.dll")
;~ $result = DllCall($hDll, "bool", "IsFinderRunning")
;~ If @error Then ConsoleWrite(@error)
;~ If IsArray($result) Then
;~ If $result[0] = 1 Then
;~ MsgBox(0,"","Finder已经在运行")
;~ Else
;~ MsgBox(0,"","Finder没有运行")
;~ EndIf
;~ EndIf
;~ DllClose($hDll)
;;-----------------------------------------------------------------------------------------------------------------
local $hDll = DllOpen(@ScriptDir&"\finderlib64.dll")
; 创建回调函数
$handle = DLLCallbackRegister("TResultCallBack", "none", "str;int;int;int")
; 调用_Find
$result = DllCall($hDll, _
"int", _ ;返回值类型
"_Find", _ ;函数名称
"str", "*.jpg", _ ;AStr 搜索关键词
"ptr", DllCallbackGetPtr($handle), _ ;ACallback 回调函数
"str", "", _ ;ADir 制定目录(单个)
"str", "", _ ;AExcludeDir 后缀过滤(多个)
"str", "", _ ;AFilter
"str", 1000, _ ;ACount 返回结果数量
"str", 0, _ ;Afrom 开始结果位置
"BOOL", True, _ ;ASpaceOr 是否匹配任一关键词
"BOOL", False, _ ;AWholeWords 匹配全词
"BOOL", False, _ ;ACaseSensitive 区分大小写
"BOOL", True, _ ;AIncludeDir 搜索目录
"BOOL", True, _ ;AIncludeFiles 搜索文件
"WORD", 1000 _ ;ATimeoutMS 超时时间
)
If @error Then ConsoleWrite(@error)
;释放回调函数内存
DllCallbackFree($handle)
DllClose($hDll)
;下面是回调函数根据传递过来的值进行处理
Func TResultCallBack($Buffer, $BufferCount, $TotalCount, $ErrorCode)
;~ MsgBox(0,0,IsString($Buffer))
;~ _ArrayDisplay($Buffer)
MsgBox(0,0,$TotalCount)
EndFunc
|