呼叫Everything SDK進行快速搜尋檔案
阿新 • • 發佈:2018-12-28
from ctypes import windll from ctypes import create_unicode_buffer from ctypes import byref from win32api import ShellExecute def search_files(file): ans = [] append = ans.append Search = windll.LoadLibrary("everything64.dll") strBuff = create_unicode_buffer(255) Search.Everything_SetSearchW(file) Search.Everything_QueryW(True) Results = Search.Everything_GetNumResults() for index in range(Results): Search.Everything_GetResultFullPathNameW(index,byref(strBuff),len(strBuff)) append(strBuff.value) del Search del strBuff return ans if __name__=='__main__': file = input("請輸入需要搜尋的檔案,如*.cpp\n") ans = search_files(file) if ans: with open("result.txt",'w') as fp: for file in ans: if '$' in file: continue fp.write(file+'\n') try: ShellExecute(0, 'open', "Uedit32.exe", 'result.txt','',1) except: ShellExecute(0, 'open', "notepad.exe", 'result.txt','',1)