python 调用everything

ddatsh 发布于 2012/02/20 13:21
阅读 2K+
收藏 9
#coding=utf-8 
from ctypes import * 
import sys,os 
 
if __name__ == '__main__': 
    if len(sys.argv)>1: 
        superSearch=windll.LoadLibrary("everything.dll") 
        strBuff=create_unicode_buffer(255) 
        superSearch.Everything_SetSearchW(c_wchar_p(sys.argv[1])) 
        try: 
            superSearch.Everything_QueryW() 
        except Exception,e:
            print e 
            superSearch.Everything_QueryW(0) 
 
        rsNum=superSearch.Everything_GetNumResults() 
        if rsNum==0: 
            print "Everthing not started or files not found!" 
         
        for index in xrange(rsNum): 
            superSearch.Everything_GetResultFullPathNameW(index,byref(strBuff),len(strBuff)) 
            print strBuff.value.encode("gbk") 
 
        del superSearch 
        del strBuff 
    else: 
        print "parameters error!" 

 

 
在命令行调用时

test.py notepad.exe

会报出

Procedure probably called with not enough arguments (4 bytes missing)

何解?

加载中
0
ddatsh
ddatsh

呃,搞定了,还以为是STDCALL之类的问题

原来是EVERYTHING SDK 现在的Everything_QueryW,参数由原来的无参,变成现在需要一个参数

superSearch.Everything_QueryW(1l)

ddatsh
ddatsh
所以网上很多的文章都不靠谱
douglarek
douglarek
你很犀利啊,@dd ,又是自问自答啊!
0
Yisen
Yisen
c_wchar_p(sys.argv[1]),导致的问题吧
返回顶部
顶部