has anyone every tried to make the Everything API available to PB?
https://www.voidtools.com/support/everything/sdk/
"Everything" is a bad word for the search function in the forum

Code: Select all
EnableExplicit
; https://www.voidtools.com/support/everything/sdk/
Define Everything64Dll
Everything64Dll = OpenLibrary(#PB_Any, "[PathToYour]\Everything-SDK\dll\Everything64.dll") ; <- adjust the path to your needs
If Everything64Dll
If ExamineLibraryFunctions(Everything64Dll)
While NextLibraryFunction()
Debug LibraryFunctionName()
Wend
EndIf
Define MajorVersion = CallFunction(Everything64Dll, "Everything_GetMajorVersion")
Define MinorVersion = CallFunction(Everything64Dll, "Everything_GetMinorVersion")
Define Revision = CallFunction(Everything64Dll, "Everything_GetRevision")
Define BuildNumber = CallFunction(Everything64Dll, "Everything_GetBuildNumber")
Debug Str(MajorVersion) + "." + Str(MinorVersion) + "." + Str(Revision) + "." + Str(BuildNumber)
CloseLibrary(Everything64Dll)
Else
Debug "!OpenLibrary()"
EndIf
Code: Select all
;https://www.voidtools.com/support/everything/sdk/
;https://www.voidtools.com/Everything-SDK.zip
;https://www.voidtools.com/faq/
; What is "Everything"?
; "Everything" is search engine that locates files and folders by filename instantly for Windows.
;
; Unlike Windows search "Everything" initially displays every file and folder on your computer (hence the name "Everything").
;
; You type in a search filter to limit what files and folders are displayed.
EnableExplicit
Prototype Everything_SetSearchW (search.p-unicode)
Prototype Everything_SetRequestFlags (dwRequestFlags)
Prototype Everything_QueryW (bwait)
Prototype Everything_GetNumResults ()
Prototype Everything_GetResultFileNameW ( index)
Prototype Everything_GetResultPathW(index)
Prototype Everything_GetLastError ()
Prototype Everything_GetResultFullPathNameW ( index, *buffer , size)
Prototype Everything_GetResultSize ( index, *ByRef_size_As_UInt64)
Prototype Everything_GetResultDateModified ( index_As_UInt32, *ByRef_ft_As_UInt64)
Prototype Everything_SetReplyWindow(hwnd)
Prototype Everything_SetReplyId(Id)
Prototype Everything_IsQueryReply(uMsg,wParam,lParam,Id)
Macro __dquotes__
"
EndMacro
Macro __GetFunction__(_Function_)
Global _function_._function_ = GetFunction(lib, __dquotes__#_function_#__dquotes__)
EndMacro
Global lib = OpenLibrary(#PB_Any, ".\dll\Everything32.dll")
__GetFunction__(Everything_SetSearchW)
__GetFunction__(Everything_SetRequestFlags)
__GetFunction__(Everything_QueryW)
__GetFunction__(Everything_GetNumResults)
__GetFunction__(Everything_GetResultFileNameW)
__GetFunction__(Everything_GetResultPathW)
__GetFunction__(Everything_GetLastError)
__GetFunction__(Everything_GetResultFullPathNameW)
__GetFunction__(Everything_GetResultSize)
__GetFunction__(Everything_GetResultDateModified)
__GetFunction__(Everything_SetReplyWindow)
__GetFunction__(Everything_SetReplyID)
__GetFunction__(Everything_IsQueryReply)
#EVERYTHING_REQUEST_FILE_NAME = $1
#EVERYTHING_REQUEST_PATH = $00000002
#EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME = $00000004
#EVERYTHING_REQUEST_EXTENSION = $00000008
#EVERYTHING_REQUEST_SIZE = $00000010
#EVERYTHING_REQUEST_DATE_CREATED = $00000020
#EVERYTHING_REQUEST_DATE_MODIFIED = $00000040
#EVERYTHING_REQUEST_DATE_ACCESSED = $00000080
#EVERYTHING_REQUEST_ATTRIBUTES = $00000100
#EVERYTHING_REQUEST_FILE_LIST_FILE_NAME = $00000200
#EVERYTHING_REQUEST_RUN_COUNT = $00000400
#EVERYTHING_REQUEST_DATE_RUN = $00000800
#EVERYTHING_REQUEST_DATE_RECENTLY_CHANGED = $00001000
#EVERYTHING_REQUEST_HIGHLIGHTED_FILE_NAME = $00002000
#EVERYTHING_REQUEST_HIGHLIGHTED_PATH = $00004000
#EVERYTHING_REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = $00008000
Procedure.s GetResultFullPathName(index)
Protected Buf$ = Space(Everything_GetResultFullPathNameW(index, 0, 0)+1)
Everything_GetResultFullPathNameW(index, @Buf$, Len(Buf$))
ProcedureReturn Buf$
EndProcedure
Procedure.s FormatDateTime(*SystemTime.SYSTEMTIME)
Protected sDate$ = Space(GetDateFormat_(#LOCALE_SYSTEM_DEFAULT, #DATE_SHORTDATE,0 , 0, 0, 0))
GetDateFormat_(#LOCALE_SYSTEM_DEFAULT, #DATE_SHORTDATE, *SystemTime, 0, sDate$, Len(sDate$))
Protected sTime$ = Space(GetTimeFormat_(#LOCALE_SYSTEM_DEFAULT, #TIME_FORCE24HOURFORMAT,0 , 0, 0, 0))
GetTimeFormat_(#LOCALE_SYSTEM_DEFAULT, #TIME_FORCE24HOURFORMAT, *SystemTime, 0, sTime$, Len(sTime$))
ProcedureReturn sDate$ + " " + sTime$
EndProcedure
Procedure GetResults()
Protected NumResults
Protected i
Protected.s filename
Protected.q size
Protected.q FileTime
Protected DateModified.SYSTEMTIME
NumResults = Everything_GetNumResults()
If NumResults > 0
For i = 0 To NumResults - 1
Everything_GetResultSize(i, @size)
Everything_GetResultDateModified(i, @FileTime)
Debug GetResultFullPathName(i)
If FileTime = $FFFFFFFFFFFFFFFF
RtlZeroMemory_(@DateModified, SizeOf(SYSTEMTIME))
Else
FileTimeToSystemTime_(@FileTime, @DateModified)
Debug FormatDateTime(DateModified)
EndIf
Next
EndIf
EndProcedure
Procedure Test(Search$, window, bWait = #False)
If Not IsWindow(window)
bWait = #True
EndIf
If Not bWait
Everything_SetReplyWindow(WindowID(window))
EndIf
Everything_SetReplyID(1)
Everything_SetSearchW(Search$)
Everything_SetRequestFlags(#EVERYTHING_REQUEST_FILE_NAME | #EVERYTHING_REQUEST_PATH | #EVERYTHING_REQUEST_SIZE | #EVERYTHING_REQUEST_DATE_MODIFIED)
Everything_QueryW(bWait);
If Not bWait
ProcedureReturn
EndIf
GetResults()
EndProcedure
Procedure WinCallback(WindowID, Message, WParam, LParam)
Protected Result = #PB_ProcessPureBasicEvents
If (Everything_IsQueryReply(Message,wParam,lParam,1))
GetResults()
Else
Protected last_everything_error = Everything_GetLastError()
If last_everything_error
Debug last_everything_error
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Procedure Main()
If OpenWindow(0, 100, 200, 800, 600, "EveryThing", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
SetWindowCallback(@WinCallback(), 0)
test("purebasic", 0, #False)
Repeat
Protected Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
Protected Quit = 1
EndIf
Until Quit = 1
EndIf
EndProcedure
Main()
I got it to work only after launching the Everything program and changing the dll to the 64bit one. Looks a bit hungrier on my PC, 109MB running it as an app. Anything that provides a good search for windows is certainly a good thing.spikey wrote: Tue May 07, 2024 12:13 pm No, the DLL is an intermediary between your application and the Everything process which does the work and feeds the results back via the callback. It should still work as long as the application is actually running even if not installed as a service. It won't work if Everything isn't running though.
It's not massively arduous to have it running as a service all the time, just 2.6MB RAM on my machine...