AHK调用Everything接口的例子

准备工作:
1、先去 www.voidtools.com 下载安装Everything,并下载SDK压缩包

2、将SDK压缩包中的Dll文件解压到 AutoHotkey.exe 程序所在的目录

3、运行 Everything.exe 不要退出,让它建立全盘的数据库

;-------------------------------------------
; 【AHK调用Everything接口的例子】  By FeiYue
;-------------------------------------------

FindStr:="file: AutoHotkey"

dll:=A_PtrSize=8 ? "Everything64.dll" : "Everything32.dll"
dll:=RegExReplace(A_AhkPath, "[^\\]+$", dll)
hModule:=DllCall("LoadLibrary", "Str",dll, "Ptr"), dll.="\"
DllCall(dll "Everything_SetSearch", "Str",FindStr)

; 设置搜索需要返回哪些结果的选项
DllCall(dll "Everything_SetRequestFlags", "int"
  , (EVERYTHING_REQUEST_FILE_NAME:=0x00000001)
  | (EVERYTHING_REQUEST_PATH:=0x00000002)
  | (EVERYTHING_REQUEST_SIZE:=0x00000010)
  | (EVERYTHING_REQUEST_DATE_CREATED:=0x00000020)
  | (EVERYTHING_REQUEST_DATE_MODIFIED:=0x00000040) )

; 文件路径升序排序:EVERYTHING_SORT_PATH_ASCENDING:=3
; 创建时间升序排序:EVERYTHING_SORT_DATE_CREATED_ASCENDING:=11
; 修改时间降序排序:EVERYTHING_SORT_DATE_MODIFIED_DESCENDING:=14
DllCall(dll "Everything_SetSort", "int",3)

DllCall(dll "Everything_Query", "int",1)
num:=DllCall(dll "Everything_GetNumResults"), s:=""

; msgbox, % "错误值:" DllCall(dll "Everything_GetLastError")

VarsetCapacity(fullname, 255*2, 0)
VarsetCapacity(date1, 8, 0)
VarsetCapacity(date2, 8, 0)
Loop, % (num>5 ? 5:num)
{
  i:=A_Index-1

  ; 两种方式获取文件的完整路径,推荐后面那种
  path:=DllCall(dll "Everything_GetResultPath", "int",i, "Str")
  name:=DllCall(dll "Everything_GetResultFileName", "int",i, "Str")
  DllCall(dll "Everything_GetResultFullPathName", "int",i, "Str",fullname, "int",255)

  ; 获取文件大小和创建、修改时间
  DllCall(dll "Everything_GetResultSize", "int",i, "int64*",size)
  DllCall(dll "Everything_GetResultDateCreated", "int",i, "Ptr",&date1)
  DllCall(dll "Everything_GetResultDateModified", "int",i, "Ptr",&date2)

  s.=path "\" name "`n" fullname
    . "`n文件大小: " Round(size/1024) "Kb"
    . "`n创建时间: " GetTime(date1)
    . "`n修改时间: " GetTime(date2) "`n`n"
}
DllCall("FreeLibrary", "Ptr",hModule)
MsgBox, 4096,, %s%
return

GetTime(ByRef date) {
  static add_hours
  if !add_hours
  {
    add_hours:=A_Now
    add_hours-=A_NowUTC, Hours
  }
  sec:=(NumGet(date,4,"uint")<<32|NumGet(date,0,"uint"))//10000000
  t:="16010101"
  t+=sec, Seconds
  t+=add_hours, Hours
  return, t
}

;

给TA捐赠
共{{data.count}}人
人已捐赠
其他案例

ahk抓抓工具

2020-3-26 13:40:25

其他教程

ahk连接数据库

2020-3-26 14:17:03

个人中心
购物车
优惠劵
有新私信 私信列表
搜索