https://www.voidtools.com/support/every ... ual_basic/
Here is a section of my code which works perfectly for the unnamed instance of Everything, but for some reason it does not work when I use a Named Instance. Is there something about Named Instances that might cause this VB code to not function properly?
Code: Select all
Module Program
Public Declare Function Everything_SetSearchA Lib "C:\Everything\Everything32.dll" (ByVal search As String) As UInt32
Public Declare Function Everything_SetRequestFlags Lib "C:\Everything\Everything32.dll" (ByVal dwRequestFlags As UInt32) As UInt32
Public Declare Function Everything_QueryA Lib "C:\Everything\Everything32.dll" (ByVal bWait As Integer) As Integer
Public Declare Function Everything_GetNumResults Lib "C:\Everything\Everything32.dll" () As UInt32
Public Declare Function Everything_GetResultFileNameA Lib "C:\Everything\Everything32.dll" (ByVal index As UInt32) As String
Public Declare Function Everything_GetLastError Lib "C:\Everything\Everything32.dll" () As UInt32
Public Declare Function Everything_GetResultFullPathNameA Lib "C:\Everything\Everything32.dll" (ByVal index As UInt32, ByVal buf As System.Text.StringBuilder, ByVal size As UInt32) As UInt32
Public Declare Function Everything_GetResultSize Lib "C:\Everything\Everything32.dll" (ByVal index As UInt32, ByRef size As UInt64) As Integer
Public Declare Function Everything_GetResultDateModified Lib "C:\Everything\Everything32.dll" (ByVal index As UInt32, ByRef ft As UInt64) As Integer
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 Sub Main(args() As String)
If (UBound(args)) <> 1 Then
Console.WriteLine("Arguments Expected-2. First is Search String. Second is Complete File Path.")
Exit Sub
End If
Dim DirectoryPath As String
DirectoryPath = System.IO.Path.GetDirectoryName(args(1))
'Console.WriteLine(DirectoryPath)
If Not (System.IO.Directory.Exists(DirectoryPath)) Then
Console.WriteLine("Folder/Directory Path Does Not Exits")
Exit Sub
End If
Everything_SetSearchA(args(0))
Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME Or EVERYTHING_REQUEST_EXTENSION Or EVERYTHING_REQUEST_PATH Or EVERYTHING_REQUEST_SIZE Or EVERYTHING_REQUEST_DATE_MODIFIED)
Everything_QueryA(1)
Dim NumResults As UInt32
Dim i As UInt32
Dim FullFileFolderPath As New System.Text.StringBuilder(260)
Dim size As UInt64
Dim ftdm As UInt64
Dim DateModified As System.DateTime
Dim strFileExtension As String, DotPosition As Integer
Dim Output As String
Output = ""
NumResults = Everything_GetNumResults()
If NumResults > 0 Then
For i = 0 To NumResults - 1
Everything_GetResultFullPathNameA(i, FullFileFolderPath, FullFileFolderPath.Capacity)
strFileExtension = Everything_GetResultFileNameA(i)
DotPosition = strFileExtension.LastIndexOf(".")
If (DotPosition <> -1) Then
strFileExtension = strFileExtension.Substring(DotPosition, strFileExtension.Length - DotPosition)
Else
strFileExtension = ""
End If
Everything_GetResultSize(i, size)
Everything_GetResultDateModified(i, ftdm)
DateModified = System.DateTime.FromFileTime(ftdm)
Output = Output & FullFileFolderPath.ToString() & "|" & size & "|" & DateModified.ToString() & "|" & strFileExtension & vbCr
Next
Output = Output.Substring(0, Output.Length - 1)
My.Computer.FileSystem.WriteAllText(args(1), Output, False)
End If
End Sub
End Module