SDK command to get file attributes

Have a suggestion for "Everything"? Please post it here.
Post Reply
benshepherd
Posts: 19
Joined: Thu Oct 13, 2016 12:28 pm

SDK command to get file attributes

Post by benshepherd »

I presume file attributes (size, modified date, permissions, etc) are stored in the database? In that case, would it be possible to provide a SDK command (or several) to extract the file attributes for each search result? I'm writing a Python script that interfaces with Everything and it would be nice to have the file sizes instantly rather than having to wait for the file system (which is slow for several thousand results).

Also, if you want the Python code to talk to Everything for the examples on the website, just let me know. It was very straightforward to set up.

Thanks for this fantastic software!

Ben
void
Developer
Posts: 17155
Joined: Fri Oct 16, 2009 11:31 pm

Re: SDK command to get file attributes

Post by void »

Current only file names can retrieved with the Everything 1.3 SDK.

There will be a Everything 1.4.1 beta release soon, once released I will be updated the SDK which will support retrieving date modified and size information.

Everything 1.4.1 adds a simple IPC call to get filenames, dates, sizes and attributes.

Code: Select all

// the WM_COPYDATA message for a query.
// requires Everything 1.4.1
#define EVERYTHING_IPC_COPYDATA_QUERY2A									17
#define EVERYTHING_IPC_COPYDATA_QUERY2W									18

#define EVERYTHING_IPC_QUERY2_REQUEST_NAME								0x00000001
#define EVERYTHING_IPC_QUERY2_REQUEST_PATH								0x00000002
#define EVERYTHING_IPC_QUERY2_REQUEST_FULL_PATH_AND_NAME					0x00000004
#define EVERYTHING_IPC_QUERY2_REQUEST_EXTENSION							0x00000008
#define EVERYTHING_IPC_QUERY2_REQUEST_SIZE								0x00000010
#define EVERYTHING_IPC_QUERY2_REQUEST_DATE_CREATED						0x00000020
#define EVERYTHING_IPC_QUERY2_REQUEST_DATE_MODIFIED						0x00000040
#define EVERYTHING_IPC_QUERY2_REQUEST_DATE_ACCESSED						0x00000080
#define EVERYTHING_IPC_QUERY2_REQUEST_ATTRIBUTES							0x00000100
#define EVERYTHING_IPC_QUERY2_REQUEST_FILE_LIST_FILE_NAME					0x00000200
#define EVERYTHING_IPC_QUERY2_REQUEST_RUN_COUNT							0x00000400
#define EVERYTHING_IPC_QUERY2_REQUEST_DATE_RUN							0x00000800
#define EVERYTHING_IPC_QUERY2_REQUEST_DATE_RECENTLY_CHANGED				0x00001000
#define EVERYTHING_IPC_QUERY2_REQUEST_HIGHLIGHTED_NAME					0x00002000
#define EVERYTHING_IPC_QUERY2_REQUEST_HIGHLIGHTED_PATH					0x00004000
#define EVERYTHING_IPC_QUERY2_REQUEST_HIGHLIGHTED_FULL_PATH_AND_NAME		0x00008000

#pragma pack (push,1)

//
// Varible sized query struct sent to everything.
//
// sent in the form of a WM_COPYDAYA message with 
// EVERYTHING_IPC_COPYDATA_QUERY2 as the 
// dwData member in the COPYDATASTRUCT struct.
// set the lpData member of the COPYDATASTRUCT struct to 
// point to your EVERYTHING_IPC_QUERY struct.
// set the cbData member of the COPYDATASTRUCT struct to 
// the size of the 
// EVERYTHING_IPC_QUERY struct minus the size of 
// a TCHAR plus the length of the search string in bytes plus 
// one TCHAR for the null terminator.
//
// NOTE: Everything will only do one query per window.
// Sending another query when a query has not completed 
// will cancel the old query and start the new one. 
//
// Everything will send the results to the reply_hwnd in the form of a 
// WM_COPYDAYA message with the dwData value you specify.
// 
// Everything will return TRUE if successful.
// returns FALSE if not supported.
//
// If you query with EVERYTHING_IPC_COPYDATA_QUERYW, the 
// results sent from Everything will be Unicode.
//

// ASCII version
typedef struct EVERYTHING_IPC_QUERY2
{
	// the window that will receive the new results.
	// only 32bits are required to store a window handle. (even on x64)
	DWORD reply_hwnd;
	
	// the value to set the dwData member in the COPYDATASTRUCT struct 
	// sent by Everything when the query is complete.
	DWORD reply_copydata_message;
	
	// search flags (see EVERYTHING_IPC_MATCHCASE | 
	// EVERYTHING_IPC_MATCHWHOLEWORD | EVERYTHING_IPC_MATCHPATH)
	DWORD search_flags; 
	
	// only return results after 'offset' results (0 to return from the first result)
	// useful for scrollable lists
	DWORD offset; 
	
	// the number of results to return 
	// zero to return no results
	// EVERYTHING_IPC_ALLRESULTS to return ALL results
	DWORD max_results;
	
	// request types.
	// one or more of EVERYTHING_IPC_QUERY2_REQUEST_* types.
	DWORD request_flags;

	// sort type, set to one of EVERYTHING_IPC_SORT_* types.
	// if Everything does not have this sort type as a fast sort type, then it 
	// will default to by name.
	DWORD sort_type;

	// followed by null terminated search.
	// TCHAR search_string[1];
		
}EVERYTHING_IPC_QUERY2;

typedef struct EVERYTHING_IPC_ITEM2
{
	// item flags one of (EVERYTHING_IPC_FOLDER|
	// EVERYTHING_IPC_DRIVE|EVERYTHING_IPC_ROOT)
	DWORD flags;
	
	// offset from the start of the EVERYTHING_IPC_LIST2
	// struct to the data content
	DWORD data_offset;

	// data found at data_offset
	// if EVERYTHING_IPC_QUERY2_REQUEST_NAME is set, 
	// DWORD name_length (excluding the null terminator); followed by null terminated text.
	
	// if EVERYTHING_IPC_QUERY2_REQUEST_PATH is set, 
	// DWORD name_length (excluding the null terminator); followed by null terminated text.
	
	// if EVERYTHING_IPC_QUERY2_REQUEST_FULL_PATH_AND_NAME is set, 
	// DWORD name_length (excluding the null terminator); followed by null terminated text.
	
	// if EVERYTHING_IPC_QUERY2_REQUEST_SIZE is set, LARGE_INTERGER size;

	// if EVERYTHING_IPC_QUERY2_REQUEST_EXTENSION is set, 
	// DWORD name_length (excluding the null terminator); followed by null terminated text;

	// if EVERYTHING_IPC_QUERY2_REQUEST_TYPE_NAME is set, 
	// DWORD name_length (excluding the null terminator); followed by null terminated text;

	// if EVERYTHING_IPC_QUERY2_REQUEST_DATE_CREATED is set, FILETIME date;
	// if EVERYTHING_IPC_QUERY2_REQUEST_DATE_MODIFIED is set, FILETIME date;
	// if EVERYTHING_IPC_QUERY2_REQUEST_DATE_ACCESSED is set, FILETIME date;
	// if EVERYTHING_IPC_QUERY2_REQUEST_ATTRIBUTES is set, DWORD attributes;

	// if EVERYTHING_IPC_QUERY2_REQUEST_FILELIST_FILENAME is set,
	// DWORD name_length (excluding the null terminator); followed by null terminated text;
	
	// if EVERYTHING_IPC_QUERY2_REQUEST_RUN_COUNT is set, DWORD run_count;
	// if EVERYTHING_IPC_QUERY2_REQUEST_DATE_RUN is set, FILETIME date;
	// if EVERYTHING_IPC_QUERY2_REQUEST_DATE_RECENTLY_CHANGED is set, FILETIME date;
	// if EVERYTHING_IPC_QUERY2_REQUEST_HIGHLIGHTED_NAME is set, 
	// DWORD name_length (excluding the null terminator); 
	// followed by null terminated text; ** = *, *text* = highlighted text
	
	// if EVERYTHING_IPC_QUERY2_REQUEST_HIGHLIGHTED_PATH is set, 
	// DWORD name_length (excluding the null terminator); 
	// followed by null terminated text; ** = *, *text* = highlighted text

	// if EVERYTHING_IPC_QUERY2_REQUEST_HIGHLIGHTED_FULL_PATH_AND_NAME is set, 
	// DWORD name_length (excluding the null terminator); 
	// followed by null terminated text; ** = *, *text* = highlighted text
	
}EVERYTHING_IPC_ITEM2;

typedef struct EVERYTHING_IPC_LIST2
{
	// number of items found.
	DWORD totitems;
	
	// the number of items available.
	DWORD numitems;

	// index offset of the first result in the item list.
	DWORD offset;
	
	// valid request types.
	DWORD request_flags;
	
	// this sort type.
	// one of EVERYTHING_IPC_SORT_* types.
	// maybe different to requested sort type.
	DWORD sort_type;
	
	// items follow.
	// EVERYTHING_IPC_ITEM2 items[numitems]
	
}EVERYTHING_IPC_LIST2;

#pragma pack (pop)

#ifdef UNICODE
#define EVERYTHING_IPC_COPYDATA_QUERY2	EVERYTHING_IPC_COPYDATA_QUERY2W
#else
#define EVERYTHING_IPC_COPYDATA_QUERY2	EVERYTHING_IPC_COPYDATA_QUERY2A
#endif

benshepherd
Posts: 19
Joined: Thu Oct 13, 2016 12:28 pm

Re: SDK command to get file attributes

Post by benshepherd »

Exactly what I wanted! Thanks, and I look forward to getting the beta release!
benshepherd
Posts: 19
Joined: Thu Oct 13, 2016 12:28 pm

Re: SDK command to get file attributes

Post by benshepherd »

Any progress on updating the SDK?
void
Developer
Posts: 17155
Joined: Fri Oct 16, 2009 11:31 pm

Re: SDK command to get file attributes

Post by void »

I'm working on offline help, localization and the website, the SDK is next on my TODO list.
benshepherd
Posts: 19
Joined: Thu Oct 13, 2016 12:28 pm

Re: SDK command to get file attributes

Post by benshepherd »

OK - thanks!
benshepherd
Posts: 19
Joined: Thu Oct 13, 2016 12:28 pm

Re: SDK command to get file attributes

Post by benshepherd »

I can see there's been some update to the SDK documentation on the website, mentioning Everything_GetResultSize and Everything_SetRequestFlags. But those functions aren't yet in the DLL. Any idea when they might be added?
void
Developer
Posts: 17155
Joined: Fri Oct 16, 2009 11:31 pm

Re: SDK command to get file attributes

Post by void »

I've updated the SDK to support EVERYTHING_IPC_QUERY2:
http://www.voidtools.com/Everything-SDK.zip

The wiki still needs updating and I'm developing another API for EVERYTHING_IPC_WM_QUERY_CREATE.

Code: Select all

Everything_SetSearchW(L"ABC 123");
Everything_SetRequestFlags(EVERYTHING_REQUEST_HIGHLIGHTED_FILE_NAME|EVERYTHING_REQUEST_PATH|EVERYTHING_REQUEST_SIZE);
Everything_SetSort(EVERYTHING_SORT_SIZE_DESCENDING);

Everything_QueryW(TRUE);

{
	DWORD i;
		
	for(i=0;i<Everything_GetNumResults();i++)
	{
		LARGE_INTEGER size;
		
		Everything_GetResultSize(i,&size);
		
		printf("Name: %S\n",Everything_GetResultHighlightedFileNameW(i));
		printf("Path: %S\n",Everything_GetResultPathW(i));
		printf("Size: %I64u\n",size.QuadPart);
	}
}
http://www.voidtools.com/support/everything/sdk/
benshepherd
Posts: 19
Joined: Thu Oct 13, 2016 12:28 pm

Re: SDK command to get file attributes

Post by benshepherd »

I downloaded the DLL but I still don't see the Everything_SetRequestFlags call. Am I being stupid?
void
Developer
Posts: 17155
Joined: Fri Oct 16, 2009 11:31 pm

Re: SDK command to get file attributes

Post by void »

Is Everything_SetRequestFlags declared in the Include\Everything.h file?
void
Developer
Posts: 17155
Joined: Fri Oct 16, 2009 11:31 pm

Re: SDK command to get file attributes

Post by void »

Please try:
http://www.voidtools.com/Everything-SDKupdate1.zip

The other SDK was missing the updated dll/lib.
benshepherd
Posts: 19
Joined: Thu Oct 13, 2016 12:28 pm

Re: SDK command to get file attributes

Post by benshepherd »

Yep, that works. Thanks!
Post Reply