Hello everyone,
I am currently using Excel 2016 MSO 32-bit and i tried using the code below in order to do a simple test of searching files with everything though excel.
The problem is: the code just gives me back "false" and "0" as results.
I think it is not accesing Everything correctly. I have done the corrections needed for the code to work.
I have everything running in the background.
I even tried to put the dll as a reference in the VB window (tools --> reference --> browse) but excel says that it cant add the dll file.
What else can i do to make it work? I do not know anymore what I can try.
Please help! Thanks!!
Note: I am running this version of everything Version 1.5.0.1315a (x64)
'Note: sample copied from
https://www.voidtools.com/support/every ... ual_basic/
'Replaced for VBA usage
' - UINT32 with LONG
' - UINT64 with LARGE_INTEGER
' - INTPtr with LONGPtr
' - System.Text.StringBuilder with String
' - System.DateTime with String
' - filename.Capacity with filesize
Private Type LARGE_INTEGER
lowpart As Long
highpart As Long
End Type
Public Declare PtrSafe Function Everything_SetSearchW Lib "C:\SDK\Everything32.dll" (ByVal ins As LongPtr) As Long
Public Declare PtrSafe Function Everything_SetRequestFlags Lib "C:\SDK\Everything32.dll" (ByVal dwRequestFlags As Long) As Long
Public Declare PtrSafe Function Everything_QueryW Lib "C:\SDK\Everything32.dll" (ByVal bWait As Integer) As Integer
Public Declare PtrSafe Function Everything_GetNumResults Lib "C:\SDK\Everything32.dll" () As Long
Public Declare PtrSafe Function Everything_GetResultFileNameW Lib "C:\SDK\Everything32.dll" (ByVal index As Long) As LongPtr
Public Declare PtrSafe Function Everything_GetLastError Lib "C:\SDK\Everything32.dll" () As Long
Public Declare PtrSafe Function Everything_GetResultFullPathNameW Lib "C:\SDK\Everything32.dll" (ByVal index As Long, ByVal ins As LongPtr, ByVal size As Long) As Long
Public Declare PtrSafe Function Everything_GetResultSize Lib "C:\SDK\Everything32.dll" (ByVal index As Long, ByRef size As LARGE_INTEGER) As Integer 'size UInt32
Public Declare PtrSafe Function Everything_GetResultDateModified Lib "C:\SDK\Everything32.dll" (ByVal index As Long, ByRef ft As LARGE_INTEGER) As Integer 'ft UInt64
Public Const EVERYTHING_REQUEST_FILE_NAME = &H1
Public Const EVERYTHING_REQUEST_PATH = &H2
Public Const EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME = &H4
Public Const EVERYTHING_REQUEST_EXTENSION = &H8
Public Const EVERYTHING_REQUEST_SIZE = &H10
Public Const EVERYTHING_REQUEST_DATE_CREATED = &H20
Public Const EVERYTHING_REQUEST_DATE_MODIFIED = &H40
Public Const EVERYTHING_REQUEST_DATE_ACCESSED = &H80
Public Const EVERYTHING_REQUEST_ATTRIBUTES = &H100
Public Const EVERYTHING_REQUEST_FILE_LIST_FILE_NAME = &H200
Public Const EVERYTHING_REQUEST_RUN_COUNT = &H400
Public Const EVERYTHING_REQUEST_DATE_RUN = &H800
Public Const EVERYTHING_REQUEST_DATE_RECENTLY_CHANGED = &H1000
Public Const EVERYTHING_REQUEST_HIGHLIGHTED_FILE_NAME = &H2000
Public Const EVERYTHING_REQUEST_HIGHLIGHTED_PATH = &H4000
Public Const EVERYTHING_REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = &H8000
Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Public Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Declare PtrSafe Function FileTimeToSystemTime Lib "kernel32" (ByRef ft As LARGE_INTEGER, lpSystemTime As SYSTEMTIME) As Long
Private Declare PtrSafe Function SystemTimeToTzSpecificLocalTime Lib "kernel32" (ByVal tzi As LongPtr, lpst As SYSTEMTIME, lplt As SYSTEMTIME) As Long
Private Declare PtrSafe Function SystemTimeToVariantTime Lib "OLEAUT32.DLL" (lpSystemTime As SYSTEMTIME, vtime As Date) As Long
Sub SimpleTest()
Dim EyText As String
Dim test As Boolean
EyText = "Everything"
Everything_SetSearchW (StrPtr(EyText))
Everything_SetRequestFlags (EVERYTHING_REQUEST_FILE_NAME Or EVERYTHING_REQUEST_PATH Or EVERYTHING_REQUEST_SIZE Or EVERYTHING_REQUEST_DATE_MODIFIED)
test = Everything_QueryW(True)
Debug.Print test
Dim NumResults As Long
Dim i As Long
Dim filename As String
Dim filenameLength As Long
Dim filesize As Long
Dim size As LARGE_INTEGER
Dim ftdm As LARGE_INTEGER
Dim stdm As SYSTEMTIME
Dim ltdm As SYSTEMTIME
Dim DateModified As Date
filename = String(260, 0)
NumResults = Everything_GetNumResults()
Debug.Print NumResults
If NumResults > 0 Then
For i = 0 To NumResults - 1
filenameLength = Everything_GetResultFullPathNameW(i, StrPtr(filename), 260)
Debug.Print Left(filename, filenameLength)
test = Everything_GetResultSize(i, size)
Debug.Print size.lowpart
test = Everything_GetResultDateModified(i, ftdm)
test = FileTimeToSystemTime(ftdm, stdm)
test = SystemTimeToTzSpecificLocalTime(0, stdm, ltdm)
test = SystemTimeToVariantTime(ltdm, DateModified)
Debug.Print DateModified
Next
End If
End Sub