[已解决]dllcall操作Everything.dll获取文件完整路径名
本帖最后由 king8462 于 2022-4-1 12:38 编辑想要获取指定搜索匹配的完整文件路径名,看了之前的帖子(https://www.autoitx.com/thread-38310-1-1.html),不会写Everything_GetResultFullPathName语法,请高手帮忙,谢谢!
修改了zzwwdd的帖子代码,虽然可以实现目的,但没有直接用这个Everything_GetResultFullPathName函数方便.
;先把 everthing.dll 放在相同目录下
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiMenu.au3>
#include <WinAPI.au3>
Local $wjm = ClipGet()
$dll = DllOpen("Everything64.dll")
$result = DllCall($dll, "none", "Everything_SetSearchW", "wstr", $wjm)
$result = DllCall($dll, "none", "Everything_QueryW", "BOOL", true)
;Local $jg = DllCall($dll, "DWORD", "Everything_GetNumFileResults")
Local $jg = DllCall($dll, "DWORD", "Everything_GetNumResults")
Local $mz = DllCall($dll, "wstr", "Everything_GetResultFileNameW","int","0") ;DWORD Everything_GetNumResults(void);
;MsgBox(0, 'test', $mz)
If $jg>=1 Then
;MsgBox(0, 'test', $jg)
$test = DllCall($dll, "wstr", "Everything_GetResultPath","int",0) ;DWORD Everything_GetNumResults(void);
;MsgBox(0,"",$test)
DllClose($dll)
ShellExecute ($test&'\'& $mz,@SW_SHOWMAXIMIZED)
EndIf
这是百度的AHK的代码:
[*]; 两种方式获取文件的完整路径,推荐后面那种
[*]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)
下面是官方帮助文档内容:
Everything_GetResultFullPathName函数检索可见结果的完整路径和文件名。
句法
DWORD Everything_GetResultFullPathName(
DWORD index,
LPTSTR lpString,
DWORD nMaxCount
);
参数
指数
可见结果的从零开始的索引。
lpString [出]
指向将接收文本的缓冲区的指针。如果字符串与缓冲区一样长或更长,则字符串将被截断并以 NULL 字符终止。
nMaxCount
指定要复制到缓冲区的最大字符数,包括 NULL 字符。如果文本超出此限制,则将其截断。
// 获取第一个可见结果的完整路径和文件名。
Everything_GetResultFullPathName(0,buf,sizeof(buf) / sizeof(TCHAR));
Local $wjm = '1.txt';ClipGet()
$dll = DllOpen("Everything64.dll")
$result = DllCall($dll, "none", "Everything_SetSearchW", "wstr", $wjm)
$result = DllCall($dll, "none", "Everything_QueryW", "BOOL", True)
;Local $jg = DllCall($dll, "DWORD", "Everything_GetNumFileResults")
Local $jg = DllCall($dll, "DWORD", "Everything_GetNumResults")
Local $mz = DllCall($dll, "wstr", "Everything_GetResultFileNameW", "int", "0") ;DWORD Everything_GetNumResults(void);
;MsgBox(0, 'test', $mz)
If $jg > 0 Then
;MsgBox(0, 'test', $jg)
;$test = DllCall($dll, "wstr", "Everything_GetResultPath", "int", 0) ;DWORD Everything_GetNumResults(void);
;MsgBox(0,"",$test)
;ShellExecute($test & '\' & $mz, @SW_SHOWMAXIMIZED)
For $iIndex = 1 To $jg
Local $aFile = DllCall($dll, 'dword', 'Everything_GetResultFullPathNameW', 'dword', $iIndex, 'wstr', '', 'DWORD', 0)
ConsoleWrite('+ FilePath: ' & $aFile & @CRLF)
Next
EndIf
DllClose($dll)
... 'dword', $iIndex - 1, ... afan 发表于 2022-4-1 11:50
... 'dword', $iIndex - 1, ...
谢谢楼上两位大佬的帮助!
页:
[1]