Everything SDK

在實驗Everything ETP的時候竟然發現,ETP Server當了= =|||。
好吧,我只是同時送了4個query過去,就當了>"<。找替代方案。

替代方案就是Everything SDK。
稍微測試一下,速度快很多。SDK是用IPC的方式跟Everything主程式溝通。所以Everything一定要開著,這點ETP也是一樣。

程式碼是參考(原创)在gvim中实现基于Everything SDK的极速搜索,稍作修改變成傳回list
from ctypes import *

def query(term):
    SE = windll.LoadLibrary("./SDK/everything.dll")

    strBuff=create_unicode_buffer(1024)
    SE.Everything_SetSearchW(c_wchar_p(term))

    try:
        SE.Everything_QueryW()
    except:
        SE.Everything_QueryW(0)

    results = []
    rcount = SE.Everything_GetNumResults()

    if rcount == 0:
        return results

    for x in range(0, rcount):
        SE.Everything_GetResultFullPathNameW(x, byref(strBuff), len(strBuff))
        results.append(strBuff.value)
    del strBuff, SE
    return results

Reference:

沒有留言:

張貼留言