#include "FiveWin.ch"
#include "EVERY.CH"
STATIC hDLL
DLL FUNCTION Everything_GetBuildNumber() AS LONG PASCAL FROM "Everything_GetBuildNumber" LIB hDll
DLL FUNCTION Everything_SetSearchA( cSearch AS LPSTR ) AS VOID PASCAL FROM "Everything_SetSearchA" LIB hDll
DLL FUNCTION Everything_QueryA( lWait AS BOOL ) AS BOOL PASCAL FROM "Everything_QueryA" LIB hDll
DLL FUNCTION Everything_GetNumResults() AS LONG PASCAL FROM "Everything_GetNumResults" LIB hDll
// need to check Parameter Type
DLL FUNCTION Everything_SetRequestFlags( nFlag AS DWORD ) AS VOID PASCAL FROM "Everything_SetRequestFlags" LIB hDll
DLL FUNCTION Everything_GetResultFullPathNameA( nNum AS _INT, cBuffer AS LPSTR, nSize AS _INT ) AS VOID PASCAL FROM "Everything_GetResultFullPathNameA" LIB hDll
PROCEDURE Main()
LOCAL aList := {}
LOCAL oWnd, oListbox, cPath, oFont
LOCAL oText_1, cFilter := SPACE( 32 )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 20
ACTIVATE FONT oFont
#IFDEF __HMG__
END FONT
#ENDIF
DEFINE WINDOW oWnd FROM 0, 0 TO 600, 400 PIXEL TITLE "Search With Everything" ICON "A1MAIN" NOMINIMIZE NOMAXIMIZE
@ 40, 0 LISTBOX oListbox VAR cPath ITEMS aList SIZE 400 - 20, 600 - 80 PIXEL FONT oFont ;
ON DBLCLICK( GoFindFile( TRIM( cPath ) ), oWnd:End() ) ;
OF oWnd
@ 010, 010 GET oText_1 VAR cFilter SIZE 360, 30 PIXEL PICTURE "@!" FONT oFont OF oWnd UPDATE VALID EverySearch( cFilter, oListbox )
oWnd:bResized := { | nType, nWidth, nHeight | oWnd:SetSize( 400, 600 ) }
#IFDEF __HMG__
END WINDOW
#ENDIF
oText_1:SetFocus()
ACTIVATE WINDOW oWnd CENTER
RETURN
STATIC PROCEDURE GoFindFile( cPath )
MsgInfo( cPath )
RETURN
FUNCTION EverySearch( cText, oListbox )
LOCAL n, nNum, buf, nRet, bufsize := 250
LOCAL aResult := {}
LOCAL cItem, aItems := {}
IF IsWin64()
hDll = LoadLibrary( "everything64.dll" )
ELSE
hDll = LoadLibrary( "everything32.dll" )
ENDIF
// MsgInfo( Everything_GetBuildNumber() )
Everything_SetSearchA( cText )
Everything_SetRequestFlags( nOr( EVERYTHING_REQUEST_PATH, EVERYTHING_REQUEST_FILE_NAME, EVERYTHING_REQUEST_SIZE ) )
Everything_QueryA( .T. )
nNum := Everything_GetNumResults()
FOR n := 1 TO nNum
buf := SPACE( bufsize )
nRet := Everything_GetResultFullPathNameA( n, @buf, bufsize )
AADD( aResult, UPPER( TRIM( buf ) ) )
NEXT
FreeLibrary( hDll )
// sort it here
aResult := ASORT( aResult )
nNum := LEN( aResult )
FOR n := 1 TO nNum
cItem := aResult[ n ]
cItem := STRTRAN( cItem, CHR( 0 ), "" )
cItem := TRIM( cItem )
IF EMPTY( cItem )
LOOP
ENDIF
AADD( aItems, cItem )
NEXT
oListbox:SetItems( aItems )
oListbox:refresh()
RETURN .T.
*+ EOF: EVERY2.PRG