- 下载SDK
https://www.voidtools.com/support/everything/sdk/
- 加载dll
ctypes.WinDLL(self.path)
- 调用接口
具体接口使用方法官网都有,示例
https://www.voidtools.com/support/everything/sdk/python/
完整代码:
import ctypesclass EverythingSearch:path = r"D:\path\to\everything\dll\Everything32.dll"def __init__(self):self.dll = ctypes.WinDLL(self.path)def set_search(self, query):self.dll.Everything_SetSearchW(query)def execute_query(self):self.dll.Everything_QueryW(1)def get_results(self):query_results = []res = self.dll.Everything_GetNumResults()for i in range(res):filename = ctypes.create_unicode_buffer(260)self.dll.Everything_GetResultFullPathNameW(i, filename, 260)result = {'filename': ctypes.wstring_at(filename)}print(result)query_results.append(result)return query_resultsif __name__ == '__main__':es = EverythingSearch()es.set_search(r"*.suffix D:\my\path\to\dir") # 查找后缀为suffix的文件; 查找范围为D:\my\path\to\dires.execute_query()results = es.get_results()