everything_sdk_sys/
bindings.rs

1//! Rust C-bindings for `Everything.h` in Everything-SDK, almost purely handwritten.
2
3use windows::Win32::Foundation::{BOOL, FILETIME, HWND, LPARAM, WPARAM};
4
5// type BOOL = i32;
6pub type DWORD = u32;
7pub type UINT = u32;
8type LPCSTR = windows::core::PCSTR;
9type LPCWSTR = windows::core::PCWSTR;
10type LPSTR = windows::core::PSTR;
11type LPWSTR = windows::core::PWSTR;
12#[allow(non_camel_case_types)]
13pub type LARGE_INTEGER = i64; // Ref: https://github.com/microsoft/windows-rs/issues/2370
14
15// all #define EVERYTHING_* const value
16pub const EVERYTHING_SDK_VERSION: u32 = 2; // if not defined, version is 1.
17
18pub const EVERYTHING_OK: u32 = 0; // no error detected
19pub const EVERYTHING_ERROR_MEMORY: u32 = 1; // out of memory.
20pub const EVERYTHING_ERROR_IPC: u32 = 2; // Everything search client is not running
21pub const EVERYTHING_ERROR_REGISTERCLASSEX: u32 = 3; // unable to register window class.
22pub const EVERYTHING_ERROR_CREATEWINDOW: u32 = 4; // unable to create listening window
23pub const EVERYTHING_ERROR_CREATETHREAD: u32 = 5; // unable to create listening thread
24pub const EVERYTHING_ERROR_INVALIDINDEX: u32 = 6; // invalid index
25pub const EVERYTHING_ERROR_INVALIDCALL: u32 = 7; // invalid call
26pub const EVERYTHING_ERROR_INVALIDREQUEST: u32 = 8; // invalid request data, request data first.
27pub const EVERYTHING_ERROR_INVALIDPARAMETER: u32 = 9; // bad parameter.
28
29pub const EVERYTHING_SORT_NAME_ASCENDING: u32 = 1;
30pub const EVERYTHING_SORT_NAME_DESCENDING: u32 = 2;
31pub const EVERYTHING_SORT_PATH_ASCENDING: u32 = 3;
32pub const EVERYTHING_SORT_PATH_DESCENDING: u32 = 4;
33pub const EVERYTHING_SORT_SIZE_ASCENDING: u32 = 5;
34pub const EVERYTHING_SORT_SIZE_DESCENDING: u32 = 6;
35pub const EVERYTHING_SORT_EXTENSION_ASCENDING: u32 = 7;
36pub const EVERYTHING_SORT_EXTENSION_DESCENDING: u32 = 8;
37pub const EVERYTHING_SORT_TYPE_NAME_ASCENDING: u32 = 9;
38pub const EVERYTHING_SORT_TYPE_NAME_DESCENDING: u32 = 10;
39pub const EVERYTHING_SORT_DATE_CREATED_ASCENDING: u32 = 11;
40pub const EVERYTHING_SORT_DATE_CREATED_DESCENDING: u32 = 12;
41pub const EVERYTHING_SORT_DATE_MODIFIED_ASCENDING: u32 = 13;
42pub const EVERYTHING_SORT_DATE_MODIFIED_DESCENDING: u32 = 14;
43pub const EVERYTHING_SORT_ATTRIBUTES_ASCENDING: u32 = 15;
44pub const EVERYTHING_SORT_ATTRIBUTES_DESCENDING: u32 = 16;
45pub const EVERYTHING_SORT_FILE_LIST_FILENAME_ASCENDING: u32 = 17;
46pub const EVERYTHING_SORT_FILE_LIST_FILENAME_DESCENDING: u32 = 18;
47pub const EVERYTHING_SORT_RUN_COUNT_ASCENDING: u32 = 19;
48pub const EVERYTHING_SORT_RUN_COUNT_DESCENDING: u32 = 20;
49pub const EVERYTHING_SORT_DATE_RECENTLY_CHANGED_ASCENDING: u32 = 21;
50pub const EVERYTHING_SORT_DATE_RECENTLY_CHANGED_DESCENDING: u32 = 22;
51pub const EVERYTHING_SORT_DATE_ACCESSED_ASCENDING: u32 = 23;
52pub const EVERYTHING_SORT_DATE_ACCESSED_DESCENDING: u32 = 24;
53pub const EVERYTHING_SORT_DATE_RUN_ASCENDING: u32 = 25;
54pub const EVERYTHING_SORT_DATE_RUN_DESCENDING: u32 = 26;
55
56pub const EVERYTHING_REQUEST_FILE_NAME: u32 = 0x00000001;
57pub const EVERYTHING_REQUEST_PATH: u32 = 0x00000002;
58pub const EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME: u32 = 0x00000004;
59pub const EVERYTHING_REQUEST_EXTENSION: u32 = 0x00000008;
60pub const EVERYTHING_REQUEST_SIZE: u32 = 0x00000010;
61pub const EVERYTHING_REQUEST_DATE_CREATED: u32 = 0x00000020;
62pub const EVERYTHING_REQUEST_DATE_MODIFIED: u32 = 0x00000040;
63pub const EVERYTHING_REQUEST_DATE_ACCESSED: u32 = 0x00000080;
64pub const EVERYTHING_REQUEST_ATTRIBUTES: u32 = 0x00000100;
65pub const EVERYTHING_REQUEST_FILE_LIST_FILE_NAME: u32 = 0x00000200;
66pub const EVERYTHING_REQUEST_RUN_COUNT: u32 = 0x00000400;
67pub const EVERYTHING_REQUEST_DATE_RUN: u32 = 0x00000800;
68pub const EVERYTHING_REQUEST_DATE_RECENTLY_CHANGED: u32 = 0x00001000;
69pub const EVERYTHING_REQUEST_HIGHLIGHTED_FILE_NAME: u32 = 0x00002000;
70pub const EVERYTHING_REQUEST_HIGHLIGHTED_PATH: u32 = 0x00004000;
71pub const EVERYTHING_REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME: u32 = 0x00008000;
72
73pub const EVERYTHING_TARGET_MACHINE_X86: u32 = 1;
74pub const EVERYTHING_TARGET_MACHINE_X64: u32 = 2;
75pub const EVERYTHING_TARGET_MACHINE_ARM: u32 = 3;
76
77// export 88 functions listed in .def file provided by Everything-SDK, and 2 functions NOT listed in .def file
78// the former require winapi-rs features "winuser" and "shellapi", the latter require "winsvc"
79//
80// it seems they are a little special for `Everything_MSIExitAndStopService` and `Everything_MSIStartService`
81extern "C" {
82
83    // write search state
84    pub fn Everything_SetSearchW(lpString: LPCWSTR);
85    pub fn Everything_SetSearchA(lpString: LPCSTR);
86    pub fn Everything_SetMatchPath(bEnable: BOOL);
87    pub fn Everything_SetMatchCase(bEnable: BOOL);
88    pub fn Everything_SetMatchWholeWord(bEnable: BOOL);
89    pub fn Everything_SetRegex(bEnable: BOOL);
90    pub fn Everything_SetMax(dwMax: DWORD);
91    pub fn Everything_SetOffset(dwOffset: DWORD);
92    pub fn Everything_SetReplyWindow(hWnd: HWND);
93    pub fn Everything_SetReplyID(dwId: DWORD);
94    pub fn Everything_SetSort(dwSort: DWORD); // Everything 1.4.1
95    pub fn Everything_SetRequestFlags(dwRequestFlags: DWORD); // Everything 1.4.1
96
97    // read search state
98    pub fn Everything_GetMatchPath() -> BOOL;
99    pub fn Everything_GetMatchCase() -> BOOL;
100    pub fn Everything_GetMatchWholeWord() -> BOOL;
101    pub fn Everything_GetRegex() -> BOOL;
102    pub fn Everything_GetMax() -> DWORD;
103    pub fn Everything_GetOffset() -> DWORD;
104    pub fn Everything_GetSearchA() -> LPCSTR;
105    pub fn Everything_GetSearchW() -> LPCWSTR;
106    pub fn Everything_GetLastError() -> DWORD;
107    pub fn Everything_GetReplyWindow() -> HWND;
108    pub fn Everything_GetReplyID() -> DWORD;
109    pub fn Everything_GetSort() -> DWORD; // Everything 1.4.1
110    pub fn Everything_GetRequestFlags() -> DWORD; // Everything 1.4.1
111
112    // execute query
113    pub fn Everything_QueryA(bWait: BOOL) -> BOOL;
114    pub fn Everything_QueryW(bWait: BOOL) -> BOOL;
115
116    // query reply
117    pub fn Everything_IsQueryReply(
118        message: UINT,
119        wParam: WPARAM,
120        lParam: LPARAM,
121        dwId: DWORD,
122    ) -> BOOL;
123
124    // write result state
125    pub fn Everything_SortResultsByPath();
126
127    // read result state
128    pub fn Everything_GetNumFileResults() -> DWORD;
129    pub fn Everything_GetNumFolderResults() -> DWORD;
130    pub fn Everything_GetNumResults() -> DWORD;
131    pub fn Everything_GetTotFileResults() -> DWORD;
132    pub fn Everything_GetTotFolderResults() -> DWORD;
133    pub fn Everything_GetTotResults() -> DWORD;
134    pub fn Everything_IsVolumeResult(dwIndex: DWORD) -> BOOL;
135    pub fn Everything_IsFolderResult(dwIndex: DWORD) -> BOOL;
136    pub fn Everything_IsFileResult(dwIndex: DWORD) -> BOOL;
137    pub fn Everything_GetResultFileNameW(dwIndex: DWORD) -> LPCWSTR;
138    pub fn Everything_GetResultFileNameA(dwIndex: DWORD) -> LPCSTR;
139    pub fn Everything_GetResultPathW(dwIndex: DWORD) -> LPCWSTR;
140    pub fn Everything_GetResultPathA(dwIndex: DWORD) -> LPCSTR;
141    pub fn Everything_GetResultFullPathNameA(dwIndex: DWORD, buf: LPSTR, bufsize: DWORD) -> DWORD;
142    pub fn Everything_GetResultFullPathNameW(
143        dwIndex: DWORD,
144        wbuf: LPWSTR,
145        wbuf_size_in_wchars: DWORD,
146    ) -> DWORD;
147    pub fn Everything_GetResultListSort() -> DWORD; // Everything 1.4.1
148    pub fn Everything_GetResultListRequestFlags() -> DWORD; // Everything 1.4.1
149    pub fn Everything_GetResultExtensionW(dwIndex: DWORD) -> LPCWSTR; // Everything 1.4.1
150    pub fn Everything_GetResultExtensionA(dwIndex: DWORD) -> LPCSTR; // Everything 1.4.1
151    pub fn Everything_GetResultSize(dwIndex: DWORD, lpSize: *mut LARGE_INTEGER) -> BOOL; // Everything 1.4.1
152    pub fn Everything_GetResultDateCreated(dwIndex: DWORD, lpDateCreated: *mut FILETIME) -> BOOL; // Everything 1.4.1
153    pub fn Everything_GetResultDateModified(dwIndex: DWORD, lpDateModified: *mut FILETIME) -> BOOL; // Everything 1.4.1
154    pub fn Everything_GetResultDateAccessed(dwIndex: DWORD, lpDateAccessed: *mut FILETIME) -> BOOL; // Everything 1.4.1
155    pub fn Everything_GetResultAttributes(dwIndex: DWORD) -> DWORD; // Everything 1.4.1
156    pub fn Everything_GetResultFileListFileNameW(dwIndex: DWORD) -> LPCWSTR; // Everything 1.4.1
157    pub fn Everything_GetResultFileListFileNameA(dwIndex: DWORD) -> LPCSTR; // Everything 1.4.1
158    pub fn Everything_GetResultRunCount(dwIndex: DWORD) -> DWORD; // Everything 1.4.1
159    pub fn Everything_GetResultDateRun(dwIndex: DWORD, lpDateRun: *mut FILETIME) -> BOOL;
160    pub fn Everything_GetResultDateRecentlyChanged(
161        dwIndex: DWORD,
162        lpDateRecentlyChanged: *mut FILETIME,
163    ) -> BOOL;
164    pub fn Everything_GetResultHighlightedFileNameW(dwIndex: DWORD) -> LPCWSTR; // Everything 1.4.1
165    pub fn Everything_GetResultHighlightedFileNameA(dwIndex: DWORD) -> LPCSTR; // Everything 1.4.1
166    pub fn Everything_GetResultHighlightedPathW(dwIndex: DWORD) -> LPCWSTR; // Everything 1.4.1
167    pub fn Everything_GetResultHighlightedPathA(dwIndex: DWORD) -> LPCSTR; // Everything 1.4.1
168    pub fn Everything_GetResultHighlightedFullPathAndFileNameW(dwIndex: DWORD) -> LPCWSTR; // Everything 1.4.1
169    pub fn Everything_GetResultHighlightedFullPathAndFileNameA(dwIndex: DWORD) -> LPCSTR; // Everything 1.4.1
170
171    // reset state and free any allocated memory
172    pub fn Everything_Reset();
173    pub fn Everything_CleanUp();
174
175    pub fn Everything_GetMajorVersion() -> DWORD;
176    pub fn Everything_GetMinorVersion() -> DWORD;
177    pub fn Everything_GetRevision() -> DWORD;
178    pub fn Everything_GetBuildNumber() -> DWORD;
179    pub fn Everything_Exit() -> BOOL;
180    // can be called as admin or standard user. will self elevate if needed. (NOT in .def)
181    #[cfg(feature = "vendored")]
182    pub fn Everything_MSIExitAndStopService(msihandle: *const std::ffi::c_void) -> UINT;
183    // MUST be called as an admin (NOT in .def)
184    #[cfg(feature = "vendored")]
185    pub fn Everything_MSIStartService(msihandle: *const std::ffi::c_void) -> UINT;
186    pub fn Everything_IsDBLoaded() -> BOOL; // Everything 1.4.1
187    pub fn Everything_IsAdmin() -> BOOL; // Everything 1.4.1
188    pub fn Everything_IsAppData() -> BOOL; // Everything 1.4.1
189    pub fn Everything_RebuildDB() -> BOOL; // Everything 1.4.1
190    pub fn Everything_UpdateAllFolderIndexes() -> BOOL; // Everything 1.4.1
191    pub fn Everything_SaveDB() -> BOOL; // Everything 1.4.1
192    pub fn Everything_SaveRunHistory() -> BOOL; // Everything 1.4.1
193    pub fn Everything_DeleteRunHistory() -> BOOL; // Everything 1.4.1
194    pub fn Everything_GetTargetMachine() -> DWORD; // Everything 1.4.1
195    pub fn Everything_IsFastSort(sortType: DWORD) -> BOOL; // Everything 1.4.1.859
196    pub fn Everything_IsFileInfoIndexed(fileInfoType: DWORD) -> BOOL; // Everything 1.4.1.859
197
198    pub fn Everything_GetRunCountFromFileNameW(lpFileName: LPCWSTR) -> DWORD; // Everything 1.4.1
199    pub fn Everything_GetRunCountFromFileNameA(lpFileName: LPCSTR) -> DWORD; // Everything 1.4.1
200    pub fn Everything_SetRunCountFromFileNameW(lpFileName: LPCWSTR, dwRunCount: DWORD) -> BOOL; // Everything 1.4.1
201    pub fn Everything_SetRunCountFromFileNameA(lpFileName: LPCSTR, dwRunCount: DWORD) -> BOOL; // Everything 1.4.1
202    pub fn Everything_IncRunCountFromFileNameW(lpFileName: LPCWSTR) -> DWORD; // Everything 1.4.1
203    pub fn Everything_IncRunCountFromFileNameA(lpFileName: LPCSTR) -> DWORD; // Everything 1.4.1
204}