Everything [voidtools] via dll?

Just starting out? Need help? Post your questions and find answers here.
highend
Enthusiast
Enthusiast
Posts: 169
Joined: Tue Jun 17, 2014 4:49 pm

Everything [voidtools] via dll?

Post by highend »

Hello,

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 :mrgreen:
User avatar
Kiffi
Addict
Addict
Posts: 1503
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Everything [voidtools] via dll?

Post by Kiffi »

should be possible:

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
Greetings ... Peter
Hygge
highend
Enthusiast
Enthusiast
Posts: 169
Joined: Tue Jun 17, 2014 4:49 pm

Re: Everything [voidtools] via dll?

Post by highend »

It's that easy? Wow^^

Works flawlessly, thanks Peter!
acreis
Enthusiast
Enthusiast
Posts: 204
Joined: Fri Jun 01, 2012 12:20 am

Re: Everything [voidtools] via dll?

Post by acreis »

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()


BarryG
Addict
Addict
Posts: 4178
Joined: Thu Apr 18, 2019 8:17 am

Re: Everything [voidtools] via dll?

Post by BarryG »

I was hoping to test acreis's code above but it just returns "2" (error) in the Debug Output, from the callback code. Anyone know how to fix? Thanks.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 771
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Everything [voidtools] via dll?

Post by spikey »

According to the header that's EVERYTHING_ERROR_IPC. The DLL can't talk to the process.

What's your specific setup? You can run Everything in several different ways - that maybe significant. It seems to be working ok for me.
BarryG
Addict
Addict
Posts: 4178
Joined: Thu Apr 18, 2019 8:17 am

Re: Everything [voidtools] via dll?

Post by BarryG »

Tried it on both Win 10 Pro and Win 11 Pro. So you're saying that your debug output is listing files?
User avatar
spikey
Enthusiast
Enthusiast
Posts: 771
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Everything [voidtools] via dll?

Post by spikey »

Yup. I'm on Win 11 Home with the 64-bit version of Everything running as a service.
BarryG
Addict
Addict
Posts: 4178
Joined: Thu Apr 18, 2019 8:17 am

Re: Everything [voidtools] via dll?

Post by BarryG »

Ah, that's why. I don't have the service running. I thought the point of this code was to use the DLL to do the searching, with no service? The code snippet doesn't say to run a service, so I had no idea. The SDK archive doesn't even have any executable to run as a service.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 771
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Everything [voidtools] via dll?

Post by spikey »

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...
User avatar
CDXbow
Enthusiast
Enthusiast
Posts: 100
Joined: Mon Aug 12, 2019 5:32 am
Location: Oz

Re: Everything [voidtools] via dll?

Post by CDXbow »

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...
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.
User avatar
blueb
Addict
Addict
Posts: 1116
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Everything [voidtools] via dll?

Post by blueb »

Working fine here (64bit version).

It's very fast! I'll have to do some testing. :)
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply