【Windows|Python】Python封装调用Everything SDK

简介

Everything SDK帮助和压缩包:https://www.voidtools.com/zh-cn/support/everything/sdk
帮助信息也可以从网站上下载Everything.chm查看,Everything.chm中提供了一个Python示例,网站上没有。

版本信息

Windows:Win11
Python:3.10
Everything版本: V1.4.1.1022 (x64)
需要注意:Everything软件开启的状态下,代码才能正常使用。

Everything类实现

使用示例

先看一个简单的使用示例

# -*- coding: utf-8 -*-

import os
import sys

try:
    from . import everything
except:
    import everything

if __name__ == "__main__":
    keyword = sys.argv[1]

    et = everything.Everything(libpath)
    et.SetSearchW(keyword )
    et.QueryW(True)

    result_size = et.GetNumResults()
    print("find %d files"%(result_size))

    for idx in range(result_size) :
        file_name = et.GetResultFileNameW(idx)
        ret_path = et.GetResultPathW(idx)
        full_file_path = os.path.join(ret_path, file_name)

        print(full_file_path, os.path.getsize(full_file_path))

特殊函数说明

GetResultSize(self, dwIndex:ctypes.c_ulong, lpSize:ctypes.POINTER(ctypes.c_ulonglong))等入参带指针的函数,参考Python文档和Everything.chm提供的示例程序,调用方法如下:

et = everything.Everything()
index = 0
file_size = ctypes.c_ulonglong(1)
et.GetResultSize(index, file_size)
print(file_size.value)

Everything类源码

类中各个成员函数的声明、入参和返回值参考SDK中src目录下的.c.def文件实现。
目前未支持Windows的HWND类型。

# -*- coding: utf-8 -*-

import os
import ctypes
import platform

if 'Windows' != platform.system():
    raise OSError(platform.system())

sysbit = platform.architecture()[0].replace('bit', '')
fpath = os.path.dirname(os.path.abspath(__file__))
libname = 'Everything{}.dll'.format(sysbit)
libpath = os.path.realpath(os.path.join(fpath, libname))

class Everything:
    REQUEST_FILE_NAME = 0x00000001
    REQUEST_PATH = 0x00000002
    REQUEST_FULL_PATH_AND_FILE_NAME = 0x00000004
    REQUEST_EXTENSION = 0x00000008
    REQUEST_SIZE = 0x00000010
    REQUEST_DATE_CREATED = 0x00000020
    REQUEST_DATE_MODIFIED = 0x00000040
    REQUEST_DATE_ACCESSED = 0x00000080
    REQUEST_ATTRIBUTES = 0x00000100
    REQUEST_FILE_LIST_FILE_NAME = 0x00000200
    REQUEST_RUN_COUNT = 0x00000400
    REQUEST_DATE_RUN = 0x00000800
    REQUEST_DATE_RECENTLY_CHANGED = 0x00001000
    REQUEST_HIGHLIGHTED_FILE_NAME = 0x00002000
    REQUEST_HIGHLIGHTED_PATH = 0x00004000
    REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = 0x00008000

    def __init__(self, lib_path:str=libpath):
        self.dll = ctypes.cdll.LoadLibrary(lib_path)

    # DWORD Everything_GetLastError(void)
    def GetLastError(self):
        GetLastError = self.dll.Everything_GetLastError
        GetLastError.restype = ctypes.c_ulong
        ret = GetLastError()
        return ret

    # void Everything_SetSearchA(LPCSTR lpString)
    def SetSearchA(self, lpString):
        SetSearchA = self.dll.Everything_SetSearchA
        SetSearchA(lpString)

    # void Everything_SetSearchW(LPCWSTR lpString)
    def SetSearchW(self, lpString):
        SetSearchW = self.dll.Everything_SetSearchW
        SetSearchW(lpString)

    # void Everything_SetMatchPath(BOOL bEnable)
    def SetMatchPath(self, bEnable):
        SetMatchPath = self.dll.Everything_SetMatchPath
        SetMatchPath(bEnable)

    # void Everything_SetMatchCase(BOOL bEnable)
    def SetMatchCase(self, bEnable):
        SetMatchCase = self.dll.Everything_SetMatchCase
        SetMatchCase(bEnable)

    # void Everything_SetMatchWholeWord(BOOL bEnable)
    def SetMatchWholeWord(self, bEnable):
        SetMatchWholeWord = self.dll.Everything_SetMatchWholeWord
        SetMatchWholeWord(bEnable)

    # void Everything_SetRegex(BOOL bEnable)
    def SetRegex(self, bEnable):
        SetRegex = self.dll.Everything_SetRegex
        SetRegex(bEnable)

    # void Everything_SetMax(DWORD dwMax)
    def SetMax(self, dwMax):
        SetMax = self.dll.Everything_SetMax
        SetMax(dwMax)

    # void Everything_SetOffset(DWORD dwOffset)
    def SetOffset(self, dwOffset):
        SetOffset = self.dll.Everything_SetOffset
        SetOffset(dwOffset)

    # void Everything_SetReplyID(DWORD dwId)
    def SetReplyID(self, dwId):
        SetReplyID = self.dll.Everything_SetReplyID
        SetReplyID(dwId)

    # void Everything_SetReplyWindow(HWND hWnd)
    def SetReplyWindow(self, hWnd):
        SetReplyWindow = self.dll.Everything_SetReplyWindow
        SetReplyWindow(hWnd)

    # LPCSTR Everything_GetSearchA(void)
    def GetSearchA(self):
        GetSearchA = self.dll.Everything_GetSearchA
        GetSearchA.restype = ctypes.c_char_p
        ret = GetSearchA()
        return ctypes.string_at(ret).decode()

    # LPCWSTR Everything_GetSearchW(void)
    def GetSearchW(self):
        GetSearchW = self.dll.Everything_GetSearchW
        GetSearchW.restype = ctypes.c_wchar_p
        ret = GetSearchW()
        return ctypes.wstring_at(ret)

    # BOOL Everything_GetMatchPath(void)
    def GetMatchPath(self):
        GetMatchPath = self.dll.Everything_GetMatchPath
        GetMatchPath.restype = ctypes.c_bool
        ret = GetMatchPath()
        return ret

    # BOOL Everything_GetMatchCase(void)
    def GetMatchCase(self):
        GetMatchCase = self.dll.Everything_GetMatchCase
        GetMatchCase.restype = ctypes.c_bool
        ret = GetMatchCase()
        return ret

    # BOOL Everything_GetMatchWholeWord(void)
    def GetMatchWholeWord(self):
        GetMatchWholeWord = self.dll.Everything_GetMatchWholeWord
        GetMatchWholeWord.restype = ctypes.c_bool
        ret = GetMatchWholeWord()
        return ret

    # BOOL Everything_GetRegex(void)
    def GetRegex(self):
        GetRegex = self.dll.Everything_GetRegex
        GetRegex.restype = ctypes.c_bool
        ret = GetRegex()
        return ret

    # DWORD Everything_GetMax(void)
    def GetMax(self):
        GetMax = self.dll.Everything_GetMax
        GetMax.restype = ctypes.c_ulong
        ret = GetMax()
        return ret

    # DWORD Everything_GetOffset(void)
    def GetOffset(self):
        GetOffset = self.dll.Everything_GetOffset
        GetOffset.restype = ctypes.c_ulong
        ret = GetOffset()
        return ret

    # DWORD Everything_GetReplyID(void)
    def GetReplyID(self):
        GetReplyID = self.dll.Everything_GetReplyID
        GetReplyID.restype = ctypes.c_ulong
        ret = GetReplyID()
        return ret

    # HWND Everything_GetReplyWindow(void)
    def GetReplyWindow(self):
        GetReplyWindow = self.dll.Everything_GetReplyWindow
        GetReplyWindow()

    # BOOL Everything_QueryA(BOOL bWait)
    def QueryA(self, bWait):
        QueryA = self.dll.Everything_QueryA
        QueryA.restype = ctypes.c_bool
        ret = QueryA(bWait)
        return ret

    # BOOL Everything_QueryW(BOOL bWait)
    def QueryW(self, bWait):
        QueryW = self.dll.Everything_QueryW
        QueryW.restype = ctypes.c_bool
        ret = QueryW(bWait)
        return ret

    # BOOL Everything_IsQueryReply(UINT message,WPARAM wParam,LPARAM lParam,DWORD dwId)
    def IsQueryReply(self, message, wParam, lParam, dwId):
        IsQueryReply = self.dll.Everything_IsQueryReply
        IsQueryReply.restype = ctypes.c_bool
        ret = IsQueryReply(message, wParam, lParam, dwId)
        return ret

    # void Everything_SortResultsByPath(void)
    def SortResultsByPath(self):
        SortResultsByPath = self.dll.Everything_SortResultsByPath
        SortResultsByPath()

    # DWORD Everything_GetNumFileResults(void)
    def GetNumFileResults(self):
        GetNumFileResults = self.dll.Everything_GetNumFileResults
        GetNumFileResults.restype = ctypes.c_ulong
        ret = GetNumFileResults()
        return ret

    # DWORD Everything_GetNumFolderResults(void)
    def GetNumFolderResults(self):
        GetNumFolderResults = self.dll.Everything_GetNumFolderResults
        GetNumFolderResults.restype = ctypes.c_ulong
        ret = GetNumFolderResults()
        return ret

    # DWORD Everything_GetNumResults(void)
    def GetNumResults(self):
        GetNumResults = self.dll.Everything_GetNumResults
        GetNumResults.restype = ctypes.c_ulong
        ret = GetNumResults()
        return ret

    # DWORD Everything_GetTotFileResults(void)
    def GetTotFileResults(self):
        GetTotFileResults = self.dll.Everything_GetTotFileResults
        GetTotFileResults.restype = ctypes.c_ulong
        ret = GetTotFileResults()
        return ret

    # DWORD Everything_GetTotFolderResults(void)
    def GetTotFolderResults(self):
        GetTotFolderResults = self.dll.Everything_GetTotFolderResults
        GetTotFolderResults.restype = ctypes.c_ulong
        ret = GetTotFolderResults()
        return ret

    # DWORD Everything_GetTotResults(void)
    def GetTotResults(self):
        GetTotResults = self.dll.Everything_GetTotResults
        GetTotResults.restype = ctypes.c_ulong
        ret = GetTotResults()
        return ret

    # BOOL Everything_IsVolumeResult(DWORD dwIndex)
    def IsVolumeResult(self, dwIndex):
        IsVolumeResult = self.dll.Everything_IsVolumeResult
        IsVolumeResult.restype = ctypes.c_bool
        ret = IsVolumeResult(dwIndex)
        return ret

    # BOOL Everything_IsFolderResult(DWORD dwIndex)
    def IsFolderResult(self, dwIndex):
        IsFolderResult = self.dll.Everything_IsFolderResult
        IsFolderResult.restype = ctypes.c_bool
        ret = IsFolderResult(dwIndex)
        return ret

    # BOOL Everything_IsFileResult(DWORD dwIndex)
    def IsFileResult(self, dwIndex):
        IsFileResult = self.dll.Everything_IsFileResult
        IsFileResult.restype = ctypes.c_bool
        ret = IsFileResult(dwIndex)
        return ret

    # LPCSTR Everything_GetResultFileNameA(DWORD dwIndex)
    def GetResultFileNameA(self, dwIndex):
        GetResultFileNameA = self.dll.Everything_GetResultFileNameA
        GetResultFileNameA.restype = ctypes.c_char_p
        ret = GetResultFileNameA(dwIndex)
        return ctypes.string_at(ret).decode()

    # LPCWSTR Everything_GetResultFileNameW(DWORD dwIndex)
    def GetResultFileNameW(self, dwIndex):
        GetResultFileNameW = self.dll.Everything_GetResultFileNameW
        GetResultFileNameW.restype = ctypes.c_wchar_p
        ret = GetResultFileNameW(dwIndex)
        return ctypes.wstring_at(ret)

    # LPCSTR Everything_GetResultPathA(DWORD dwIndex)
    def GetResultPathA(self, dwIndex):
        GetResultPathA = self.dll.Everything_GetResultPathA
        GetResultPathA.restype = ctypes.c_char_p
        ret = GetResultPathA(dwIndex)
        return ctypes.string_at(ret).decode()

    # LPCWSTR Everything_GetResultPathW(DWORD dwIndex)
    def GetResultPathW(self, dwIndex):
        GetResultPathW = self.dll.Everything_GetResultPathW
        GetResultPathW.restype = ctypes.c_wchar_p
        ret = GetResultPathW(dwIndex)
        return ctypes.wstring_at(ret)

    # DWORD Everything_GetResultFullPathNameA(DWORD dwIndex,LPSTR buf,DWORD bufsize)
    def GetResultFullPathNameA(self, dwIndex, buf, bufsize):
        GetResultFullPathNameA = self.dll.Everything_GetResultFullPathNameA
        GetResultFullPathNameA.restype = ctypes.c_ulong
        ret = GetResultFullPathNameA(dwIndex, buf, bufsize)
        return ret

    # DWORD Everything_GetResultFullPathNameW(DWORD dwIndex,LPWSTR wbuf,DWORD wbuf_size_in_wchars)
    def GetResultFullPathNameW(self, dwIndex, wbuf, wbuf_size_in_wchars):
        GetResultFullPathNameW = self.dll.Everything_GetResultFullPathNameW
        GetResultFullPathNameW.restype = ctypes.c_ulong
        ret = GetResultFullPathNameW(dwIndex, wbuf, wbuf_size_in_wchars)
        return ret

    # void Everything_Reset(void)
    def Reset(self):
        Reset = self.dll.Everything_Reset
        Reset()

    # void Everything_CleanUp(void)
    def CleanUp(self):
        CleanUp = self.dll.Everything_CleanUp
        CleanUp()

    # void Everything_SetSort(DWORD dwSort)
    def SetSort(self, dwSort):
        SetSort = self.dll.Everything_SetSort
        SetSort(dwSort)

    # void Everything_SetRequestFlags(DWORD dwRequestFlags)
    def SetRequestFlags(self, dwRequestFlags):
        SetRequestFlags = self.dll.Everything_SetRequestFlags
        SetRequestFlags(dwRequestFlags)

    # DWORD Everything_GetSort(void)
    def GetSort(self):
        GetSort = self.dll.Everything_GetSort
        GetSort.restype = ctypes.c_ulong
        ret = GetSort()
        return ret

    # DWORD Everything_GetRequestFlags(void)
    def GetRequestFlags(self):
        GetRequestFlags = self.dll.Everything_GetRequestFlags
        GetRequestFlags.restype = ctypes.c_ulong
        ret = GetRequestFlags()
        return ret

    # DWORD Everything_GetResultListSort(void)
    def GetResultListSort(self):
        GetResultListSort = self.dll.Everything_GetResultListSort
        GetResultListSort.restype = ctypes.c_ulong
        ret = GetResultListSort()
        return ret

    # DWORD Everything_GetResultListRequestFlags(void)
    def GetResultListRequestFlags(self):
        GetResultListRequestFlags = self.dll.Everything_GetResultListRequestFlags
        GetResultListRequestFlags.restype = ctypes.c_ulong
        ret = GetResultListRequestFlags()
        return ret

    # LPCWSTR Everything_GetResultExtensionW(DWORD dwIndex)
    def GetResultExtensionW(self, dwIndex):
        GetResultExtensionW = self.dll.Everything_GetResultExtensionW
        GetResultExtensionW.restype = ctypes.c_wchar_p
        ret = GetResultExtensionW(dwIndex)
        return ctypes.wstring_at(ret)

    # LPCSTR Everything_GetResultExtensionA(DWORD dwIndex)
    def GetResultExtensionA(self, dwIndex):
        GetResultExtensionA = self.dll.Everything_GetResultExtensionA
        GetResultExtensionA.restype = ctypes.c_char_p
        ret = GetResultExtensionA(dwIndex)
        return ctypes.string_at(ret).decode()

    # BOOL Everything_GetResultSize(DWORD dwIndex,LARGE_INTEGER *lpSize)
    def GetResultSize(self, dwIndex:ctypes.c_ulong, lpSize:ctypes.POINTER(ctypes.c_ulonglong)):
        GetResultSize = self.dll.Everything_GetResultSize
        GetResultSize.argtypes = [ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulonglong)]
        GetResultSize.restype = ctypes.c_bool
        ret = GetResultSize(dwIndex, lpSize)
        return ret

    # BOOL Everything_GetResultDateCreated(DWORD dwIndex,FILETIME *lpDateCreated)
    def GetResultDateCreated(self, dwIndex:ctypes.c_ulong, lpDateCreated:ctypes.POINTER(ctypes.c_ulonglong)):
        GetResultDateCreated = self.dll.Everything_GetResultDateCreated
        GetResultDateCreated.argtypes = [ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulonglong)]
        GetResultDateCreated.restype = ctypes.c_bool
        ret = GetResultDateCreated(dwIndex, lpDateCreated)
        return ret

    # BOOL Everything_GetResultDateModified(DWORD dwIndex,FILETIME *lpDateModified)
    def GetResultDateModified(self, dwIndex:ctypes.c_ulong, lpDateModified:ctypes.POINTER(ctypes.c_ulonglong)):
        GetResultDateModified = self.dll.Everything_GetResultDateModified
        GetResultDateModified.argtypes = [ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulonglong)]
        GetResultDateModified.restype = ctypes.c_bool
        ret = GetResultDateModified(dwIndex, lpDateModified)
        return ret

    # BOOL Everything_GetResultDateAccessed(DWORD dwIndex,FILETIME *lpDateAccessed)
    def GetResultDateAccessed(self, dwIndex:ctypes.c_ulong, lpDateAccessed:ctypes.POINTER(ctypes.c_ulonglong)):
        GetResultDateAccessed = self.dll.Everything_GetResultDateAccessed
        GetResultDateAccessed.argtypes = [ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulonglong)]
        GetResultDateAccessed.restype = ctypes.c_bool
        ret = GetResultDateAccessed(dwIndex, lpDateAccessed)
        return ret

    # DWORD Everything_GetResultAttributes(DWORD dwIndex)
    def GetResultAttributes(self, dwIndex):
        GetResultAttributes = self.dll.Everything_GetResultAttributes
        GetResultAttributes.restype = ctypes.c_ulong
        ret = GetResultAttributes(dwIndex)
        return ret

    # LPCWSTR Everything_GetResultFileListFileNameW(DWORD dwIndex)
    def GetResultFileListFileNameW(self, dwIndex):
        GetResultFileListFileNameW = self.dll.Everything_GetResultFileListFileNameW
        GetResultFileListFileNameW.restype = ctypes.c_wchar_p
        ret = GetResultFileListFileNameW(dwIndex)
        return ctypes.wstring_at(ret)

    # LPCSTR Everything_GetResultFileListFileNameA(DWORD dwIndex)
    def GetResultFileListFileNameA(self, dwIndex):
        GetResultFileListFileNameA = self.dll.Everything_GetResultFileListFileNameA
        GetResultFileListFileNameA.restype = ctypes.c_char_p
        ret = GetResultFileListFileNameA(dwIndex)
        return ctypes.string_at(ret).decode()

    # DWORD Everything_GetResultRunCount(DWORD dwIndex)
    def GetResultRunCount(self, dwIndex):
        GetResultRunCount = self.dll.Everything_GetResultRunCount
        GetResultRunCount.restype = ctypes.c_ulong
        ret = GetResultRunCount(dwIndex)
        return ret

    # BOOL Everything_GetResultDateRun(DWORD dwIndex,FILETIME *lpDateRun)
    def GetResultDateRun(self, dwIndex:ctypes.c_ulong, lpDateRun:ctypes.POINTER(ctypes.c_ulonglong)):
        GetResultDateRun = self.dll.Everything_GetResultDateRun
        GetResultDateRun.argtypes = [ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulonglong)]
        GetResultDateRun.restype = ctypes.c_bool
        ret = GetResultDateRun(dwIndex, lpDateRun)
        return ret

    # BOOL Everything_GetResultDateRecentlyChanged(DWORD dwIndex,FILETIME *lpDateRecentlyChanged)
    def GetResultDateRecentlyChanged(self, dwIndex:ctypes.c_ulong, lpDateRecentlyChanged:ctypes.POINTER(ctypes.c_ulonglong)):
        GetResultDateRecentlyChanged = self.dll.Everything_GetResultDateRecentlyChanged
        GetResultDateRecentlyChanged.argtypes = [ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulonglong)]
        GetResultDateRecentlyChanged.restype = ctypes.c_bool
        ret = GetResultDateRecentlyChanged(dwIndex, lpDateRecentlyChanged)
        return ret

    # LPCWSTR Everything_GetResultHighlightedFileNameW(DWORD dwIndex)
    def GetResultHighlightedFileNameW(self, dwIndex):
        GetResultHighlightedFileNameW = self.dll.Everything_GetResultHighlightedFileNameW
        GetResultHighlightedFileNameW.restype = ctypes.c_wchar_p
        ret = GetResultHighlightedFileNameW(dwIndex)
        return ctypes.wstring_at(ret)

    # LPCSTR Everything_GetResultHighlightedFileNameA(DWORD dwIndex)
    def GetResultHighlightedFileNameA(self, dwIndex):
        GetResultHighlightedFileNameA = self.dll.Everything_GetResultHighlightedFileNameA
        GetResultHighlightedFileNameA.restype = ctypes.c_char_p
        ret = GetResultHighlightedFileNameA(dwIndex)
        return ctypes.string_at(ret).decode()

    # LPCWSTR Everything_GetResultHighlightedPathW(DWORD dwIndex)
    def GetResultHighlightedPathW(self, dwIndex):
        GetResultHighlightedPathW = self.dll.Everything_GetResultHighlightedPathW
        GetResultHighlightedPathW.restype = ctypes.c_wchar_p
        ret = GetResultHighlightedPathW(dwIndex)
        return ctypes.wstring_at(ret)

    # LPCSTR Everything_GetResultHighlightedPathA(DWORD dwIndex)
    def GetResultHighlightedPathA(self, dwIndex):
        GetResultHighlightedPathA = self.dll.Everything_GetResultHighlightedPathA
        GetResultHighlightedPathA.restype = ctypes.c_char_p
        ret = GetResultHighlightedPathA(dwIndex)
        return ctypes.string_at(ret).decode()

    # LPCWSTR Everything_GetResultHighlightedFullPathAndFileNameW(DWORD dwIndex)
    def GetResultHighlightedFullPathAndFileNameW(self, dwIndex):
        GetResultHighlightedFullPathAndFileNameW = self.dll.Everything_GetResultHighlightedFullPathAndFileNameW
        GetResultHighlightedFullPathAndFileNameW.restype = ctypes.c_wchar_p
        ret = GetResultHighlightedFullPathAndFileNameW(dwIndex)
        return ctypes.wstring_at(ret)

    # LPCSTR Everything_GetResultHighlightedFullPathAndFileNameA(DWORD dwIndex)
    def GetResultHighlightedFullPathAndFileNameA(self, dwIndex):
        GetResultHighlightedFullPathAndFileNameA = self.dll.Everything_GetResultHighlightedFullPathAndFileNameA
        GetResultHighlightedFullPathAndFileNameA.restype = ctypes.c_char_p
        ret = GetResultHighlightedFullPathAndFileNameA(dwIndex)
        return ctypes.string_at(ret).decode()

    # DWORD Everything_GetMajorVersion(void)
    def GetMajorVersion(self):
        GetMajorVersion = self.dll.Everything_GetMajorVersion
        GetMajorVersion.restype = ctypes.c_ulong
        ret = GetMajorVersion()
        return ret

    # DWORD Everything_GetMinorVersion(void)
    def GetMinorVersion(self):
        GetMinorVersion = self.dll.Everything_GetMinorVersion
        GetMinorVersion.restype = ctypes.c_ulong
        ret = GetMinorVersion()
        return ret

    # DWORD Everything_GetRevision(void)
    def GetRevision(self):
        GetRevision = self.dll.Everything_GetRevision
        GetRevision.restype = ctypes.c_ulong
        ret = GetRevision()
        return ret

    # DWORD Everything_GetBuildNumber(void)
    def GetBuildNumber(self):
        GetBuildNumber = self.dll.Everything_GetBuildNumber
        GetBuildNumber.restype = ctypes.c_ulong
        ret = GetBuildNumber()
        return ret

    # BOOL Everything_Exit(void)
    def Exit(self):
        Exit = self.dll.Everything_Exit
        Exit.restype = ctypes.c_bool
        ret = Exit()
        return ret

    # BOOL Everything_IsDBLoaded(void)
    def IsDBLoaded(self):
        IsDBLoaded = self.dll.Everything_IsDBLoaded
        IsDBLoaded.restype = ctypes.c_bool
        ret = IsDBLoaded()
        return ret

    # BOOL Everything_IsAdmin(void)
    def IsAdmin(self):
        IsAdmin = self.dll.Everything_IsAdmin
        IsAdmin.restype = ctypes.c_bool
        ret = IsAdmin()
        return ret

    # BOOL Everything_IsAppData(void)
    def IsAppData(self):
        IsAppData = self.dll.Everything_IsAppData
        IsAppData.restype = ctypes.c_bool
        ret = IsAppData()
        return ret

    # BOOL Everything_RebuildDB(void)
    def RebuildDB(self):
        RebuildDB = self.dll.Everything_RebuildDB
        RebuildDB.restype = ctypes.c_bool
        ret = RebuildDB()
        return ret

    # BOOL Everything_UpdateAllFolderIndexes(void)
    def UpdateAllFolderIndexes(self):
        UpdateAllFolderIndexes = self.dll.Everything_UpdateAllFolderIndexes
        UpdateAllFolderIndexes.restype = ctypes.c_bool
        ret = UpdateAllFolderIndexes()
        return ret

    # BOOL Everything_SaveDB(void)
    def SaveDB(self):
        SaveDB = self.dll.Everything_SaveDB
        SaveDB.restype = ctypes.c_bool
        ret = SaveDB()
        return ret

    # BOOL Everything_SaveRunHistory(void)
    def SaveRunHistory(self):
        SaveRunHistory = self.dll.Everything_SaveRunHistory
        SaveRunHistory.restype = ctypes.c_bool
        ret = SaveRunHistory()
        return ret

    # BOOL Everything_DeleteRunHistory(void)
    def DeleteRunHistory(self):
        DeleteRunHistory = self.dll.Everything_DeleteRunHistory
        DeleteRunHistory.restype = ctypes.c_bool
        ret = DeleteRunHistory()
        return ret

    # DWORD Everything_GetTargetMachine(void)
    def GetTargetMachine(self):
        GetTargetMachine = self.dll.Everything_GetTargetMachine
        GetTargetMachine.restype = ctypes.c_ulong
        ret = GetTargetMachine()
        return ret

    # BOOL Everything_IsFastSort(DWORD sortType)
    def IsFastSort(self, sortType):
        IsFastSort = self.dll.Everything_IsFastSort
        IsFastSort.restype = ctypes.c_bool
        ret = IsFastSort(sortType)
        return ret

    # BOOL Everything_IsFileInfoIndexed(DWORD fileInfoType)
    def IsFileInfoIndexed(self, fileInfoType):
        IsFileInfoIndexed = self.dll.Everything_IsFileInfoIndexed
        IsFileInfoIndexed.restype = ctypes.c_bool
        ret = IsFileInfoIndexed(fileInfoType)
        return ret

    # DWORD Everything_GetRunCountFromFileNameW(LPCWSTR lpFileName)
    def GetRunCountFromFileNameW(self, lpFileName):
        GetRunCountFromFileNameW = self.dll.Everything_GetRunCountFromFileNameW
        GetRunCountFromFileNameW.restype = ctypes.c_ulong
        ret = GetRunCountFromFileNameW(lpFileName)
        return ret

    # DWORD Everything_GetRunCountFromFileNameA(LPCSTR lpFileName)
    def GetRunCountFromFileNameA(self, lpFileName):
        GetRunCountFromFileNameA = self.dll.Everything_GetRunCountFromFileNameA
        GetRunCountFromFileNameA.restype = ctypes.c_ulong
        ret = GetRunCountFromFileNameA(lpFileName)
        return ret

    # BOOL Everything_SetRunCountFromFileNameW(LPCWSTR lpFileName,DWORD dwRunCount)
    def SetRunCountFromFileNameW(self, lpFileName, dwRunCount):
        SetRunCountFromFileNameW = self.dll.Everything_SetRunCountFromFileNameW
        SetRunCountFromFileNameW.restype = ctypes.c_bool
        ret = SetRunCountFromFileNameW(lpFileName, dwRunCount)
        return ret

    # BOOL Everything_SetRunCountFromFileNameA(LPCSTR lpFileName,DWORD dwRunCount)
    def SetRunCountFromFileNameA(self, lpFileName, dwRunCount):
        SetRunCountFromFileNameA = self.dll.Everything_SetRunCountFromFileNameA
        SetRunCountFromFileNameA.restype = ctypes.c_bool
        ret = SetRunCountFromFileNameA(lpFileName, dwRunCount)
        return ret

    # DWORD Everything_IncRunCountFromFileNameW(LPCWSTR lpFileName)
    def IncRunCountFromFileNameW(self, lpFileName):
        IncRunCountFromFileNameW = self.dll.Everything_IncRunCountFromFileNameW
        IncRunCountFromFileNameW.restype = ctypes.c_ulong
        ret = IncRunCountFromFileNameW(lpFileName)
        return ret

    # DWORD Everything_IncRunCountFromFileNameA(LPCSTR lpFileName)
    def IncRunCountFromFileNameA(self, lpFileName):
        IncRunCountFromFileNameA = self.dll.Everything_IncRunCountFromFileNameA
        IncRunCountFromFileNameA.restype = ctypes.c_ulong
        ret = IncRunCountFromFileNameA(lpFileName)
        return ret
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要在Windows下使用Python调用海康威视网络摄像头SDK,可以按照以下步骤操作: 1. 安装海康威视网络摄像头SDK:首先,从海康威视官方网站下载并安装最新版本的SDK。确保SDK与你的Python版本兼容。 2. 设置环境变量:打开控制面板,进入系统属性,点击“高级系统设置”,选择“环境变量”。在系统变量中,找到“Path”变量,并将SDK的安装路径添加到该变量中。这样Python才能找到SDK的库文件。 3. 安装Python的海康威视SDK库:通过pip安装Python的海康威视SDK库,可以在命令提示符中运行以下命令: ``` pip install hikvisionapi ``` 这样就能将海康威视SDK库安装到Python环境中。 4. 使用Python调用SDK:在Python脚本中导入SDK库并使用其中的函数和类来调用摄像头功能。例如,你可以使用SDK提供的函数初始化摄像头设备、打开视频流、进行图像处理等操作。 需要注意的是,在使用SDK之前,你需要先了解SDK提供的函数和类的使用方法。可以参考SDK的官方文档或样例代码来了解如何正确地调用SDK的各项功能。 总之,通过安装SDK、设置环境变量、安装PythonSDK库,并使用Python脚本来调用SDK的函数和类,你就能在Windows下使用Python调用海康威视网络摄像头SDK了。 ### 回答2: 在Windows操作系统下,可以使用Python调用海康威视网络摄像头SDK来实现摄像头的控制和影像数据的获取。下面是一个简单的示例代码: 首先,确保已经安装了Python和相应的海康威视网络摄像头SDK。 ```python # 导入相关库 from ctypes import * # 加载SDK的动态链接库 hk_sdk = cdll.LoadLibrary('hk_sdk.dll') # 设置登录参数 addr = b'IP地址' # 摄像头的IP地址 port = 8000 # 摄像头的端口号 user = b'用户名' # 登录用户名 password = b'密码' # 登录密码 # 登录摄像头 login_info = hk_sdk.NET_DVR_USER_LOGIN_INFO() # 定义登录信息结构体 login_info.sDeviceAddress = addr # 摄像头的IP地址 login_info.wPort = port # 摄像头的端口号 login_info.sUserName = user # 登录用户名 login_info.sPassword = password # 登录密码 login_info.cbLoginResult = None # 登录结果回调函数 login_info.pUser = None # 用户参数 lUserID = hk_sdk.NET_DVR_Login_V40(byref(login_info), None) # 调用登录函数,获取登录ID # 检查登录是否成功 if lUserID < 0: print('设备登录失败') hk_sdk.NET_DVR_Cleanup() # 释放资源 else: print('设备登录成功') # 进行相关操作,如实时预览或录像等 # 登出摄像头 hk_sdk.NET_DVR_Logout_V30(lUserID) hk_sdk.NET_DVR_Cleanup() # 释放资源 ``` 以上代码首先通过`cdll.LoadLibrary()`函数加载SDK的动态链接库。然后创建一个`NET_DVR_USER_LOGIN_INFO`结构体,并设置登录参数,包括IP地址、端口号、用户名和密码。接着调用`NET_DVR_Login_V40()`函数进行登录,并获取登录ID。如果登录成功,则可以进行相关操作,如实时预览或录像等。最后,调用`NET_DVR_Logout_V30()`函数登出摄像头,并使用`NET_DVR_Cleanup()`函数释放资源。 需要注意的是,具体的操作和功能需根据海康威视网络摄像头SDK的文档进行相关配置和调用
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值