diff --git a/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs b/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs index d2768d5168..4cf4dbaab1 100644 --- a/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs +++ b/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs @@ -9,69 +9,68 @@ namespace Wox.Plugin.Everything.Everything public sealed class EverythingAPI { #region DllImport - [DllImport(EVERYTHING_DLL_NAME, CharSet = CharSet.Unicode)] + [DllImport(Main.DLL, CharSet = CharSet.Unicode)] private static extern int Everything_SetSearchW(string lpSearchString); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern void Everything_SetMatchPath(bool bEnable); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern void Everything_SetMatchCase(bool bEnable); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern void Everything_SetMatchWholeWord(bool bEnable); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern void Everything_SetRegex(bool bEnable); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern void Everything_SetMax(int dwMax); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern void Everything_SetOffset(int dwOffset); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern bool Everything_GetMatchPath(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern bool Everything_GetMatchCase(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern bool Everything_GetMatchWholeWord(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern bool Everything_GetRegex(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern UInt32 Everything_GetMax(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern UInt32 Everything_GetOffset(); - [DllImport(EVERYTHING_DLL_NAME, CharSet = CharSet.Unicode)] + [DllImport(Main.DLL, CharSet = CharSet.Unicode)] private static extern string Everything_GetSearchW(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern StateCode Everything_GetLastError(); - [DllImport(EVERYTHING_DLL_NAME, CharSet = CharSet.Unicode)] + [DllImport(Main.DLL, CharSet = CharSet.Unicode)] private static extern bool Everything_QueryW(bool bWait); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern void Everything_SortResultsByPath(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern int Everything_GetNumFileResults(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern int Everything_GetNumFolderResults(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern int Everything_GetNumResults(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern int Everything_GetTotFileResults(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern int Everything_GetTotFolderResults(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern int Everything_GetTotResults(); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern bool Everything_IsVolumeResult(int nIndex); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern bool Everything_IsFolderResult(int nIndex); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern bool Everything_IsFileResult(int nIndex); - [DllImport(EVERYTHING_DLL_NAME, CharSet = CharSet.Unicode)] + [DllImport(Main.DLL, CharSet = CharSet.Unicode)] private static extern void Everything_GetResultFullPathNameW(int nIndex, StringBuilder lpString, int nMaxCount); - [DllImport(EVERYTHING_DLL_NAME)] + [DllImport(Main.DLL)] private static extern void Everything_Reset(); #endregion - const string EVERYTHING_DLL_NAME = "Everything.dll"; enum StateCode { OK, diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index 8ee17eafa9..104057c017 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -5,10 +5,8 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.ServiceProcess; using System.Windows; using Wox.Infrastructure.Storage; -using Wox.Infrastructure; using Wox.Plugin.Everything.Everything; namespace Wox.Plugin.Everything @@ -17,20 +15,14 @@ namespace Wox.Plugin.Everything { private readonly EverythingAPI _api = new EverythingAPI(); - private const string EverythingProcessName = "Everything"; - private const string PortableEverything = "PortableEverything"; - internal static string LibraryPath; + public const string SDK = "EverythingSDK"; + public const string DLL = "Everything.dll"; + internal static string SDKPath; private PluginInitContext _context; - private readonly Settings _settings; - private readonly PluginJsonStorage _storage; - - public Main() - { - _storage = new PluginJsonStorage(); - _settings = _storage.Load(); - } + private Settings _settings; + private PluginJsonStorage _storage; public void Save() { @@ -48,21 +40,6 @@ namespace Wox.Plugin.Everything _settings.MaxSearchCount = 50; } - if (keyword == "uninstalleverything") - { - Result r = new Result(); - r.Title = "Uninstall Everything"; - r.SubTitle = "You need to uninstall everything service if you can not move/delete wox folder"; - r.IcoPath = "Images\\find.png"; - r.Action = c => - { - UnInstallEverything(); - return true; - }; - r.Score = 2000; - results.Add(r); - } - try { var searchList = _api.Search(keyword, maxCount: _settings.MaxSearchCount).ToList(); @@ -100,7 +77,6 @@ namespace Wox.Plugin.Everything } catch (IPCErrorException) { - StartEverything(); results.Add(new Result { Title = _context.API.GetTranslation("wox_plugin_everything_is_not_running"), @@ -150,14 +126,35 @@ namespace Wox.Plugin.Everything public void Init(PluginInitContext context) { _context = context; + _storage = new PluginJsonStorage(); + _settings = _storage.Load(); var pluginDirectory = context.CurrentPluginMetadata.PluginDirectory; - var libraryDirectory = Path.Combine(pluginDirectory, PortableEverything, CpuType()); - LibraryPath = Path.Combine(libraryDirectory, "Everything.dll"); - LoadLibrary(LibraryPath); - //Helper.AddDLLDirectory(libraryDirectory); + var bundledSDKDirectory = Path.Combine(pluginDirectory, SDK, CpuType()); + var bundledSDKPath = Path.Combine(bundledSDKDirectory, DLL); - StartEverything(); + var SDKDirectory = Path.Combine(_storage.DirectoryPath, SDK, CpuType()); + SDKPath = Path.Combine(SDKDirectory, DLL); + if (!Directory.Exists(SDKDirectory)) + { + Directory.CreateDirectory(SDKDirectory); + } + + if (!File.Exists(SDKPath)) + { + File.Copy(bundledSDKPath, SDKPath); + } + else + { + var newSDK = new FileInfo(bundledSDKPath).LastWriteTimeUtc; + var oldSDK = new FileInfo(SDKPath).LastWriteTimeUtc; + if (oldSDK != newSDK) + { + File.Copy(bundledSDKPath, SDKPath, true); + } + } + + LoadLibrary(SDKPath); } private string CpuType() @@ -165,112 +162,6 @@ namespace Wox.Plugin.Everything return Environment.Is64BitOperatingSystem ? "x64" : "x86"; } - - private void StartEverything() - { - if (!CheckEverythingServiceRunning()) - { - if (InstallAndRunEverythingService()) - { - StartEverythingClient(); - } - } - else - { - StartEverythingClient(); - } - } - - private bool InstallAndRunEverythingService() - { - try - { - Process p = new Process(); - p.StartInfo.Verb = "runas"; - p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - p.StartInfo.FileName = GetEverythingPath(); - p.StartInfo.UseShellExecute = true; - p.StartInfo.Arguments = "-install-service"; - p.Start(); - return true; - } - catch (Exception e) - { - return false; - } - } - - private bool UnInstallEverything() - { - try - { - Process p = new Process(); - p.StartInfo.Verb = "runas"; - p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - p.StartInfo.FileName = GetEverythingPath(); - p.StartInfo.UseShellExecute = true; - p.StartInfo.Arguments = "-uninstall-service"; - p.Start(); - - Process[] proc = Process.GetProcessesByName(EverythingProcessName); - foreach (Process process in proc) - { - process.Kill(); - } - return true; - } - catch (Exception e) - { - return false; - } - } - - private void StartEverythingClient() - { - try - { - Process p = new Process(); - p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - p.StartInfo.FileName = GetEverythingPath(); - p.StartInfo.UseShellExecute = true; - p.StartInfo.Arguments = "-startup"; - p.Start(); - } - catch (Exception e) - { - _context.API.ShowMsg("Start Everything failed"); - } - } - - private bool CheckEverythingServiceRunning() - { - try - { - ServiceController sc = new ServiceController(EverythingProcessName); - return sc.Status == ServiceControllerStatus.Running; - } - catch - { - - } - return false; - } - - private bool CheckEverythingIsRunning() - { - return Process.GetProcessesByName(EverythingProcessName).Length > 0; - } - - private string GetEverythingPath() - { - string directory = Path.Combine( - _context.CurrentPluginMetadata.PluginDirectory, - PortableEverything, CpuType(), - "Everything.exe" - ); - return directory; - } - public string GetTranslatedPluginTitle() { return _context.API.GetTranslation("wox_plugin_everything_plugin_name"); diff --git a/Plugins/Wox.Plugin.Everything/PortableEverything/x64/Everything.dll b/Plugins/Wox.Plugin.Everything/PortableEverything/x64/Everything.dll deleted file mode 100644 index 20c2ed86ca..0000000000 Binary files a/Plugins/Wox.Plugin.Everything/PortableEverything/x64/Everything.dll and /dev/null differ diff --git a/Plugins/Wox.Plugin.Everything/PortableEverything/x64/Everything.exe b/Plugins/Wox.Plugin.Everything/PortableEverything/x64/Everything.exe deleted file mode 100644 index d02f5a37fe..0000000000 Binary files a/Plugins/Wox.Plugin.Everything/PortableEverything/x64/Everything.exe and /dev/null differ diff --git a/Plugins/Wox.Plugin.Everything/PortableEverything/x86/Everything.dll b/Plugins/Wox.Plugin.Everything/PortableEverything/x86/Everything.dll deleted file mode 100644 index 19761064e1..0000000000 Binary files a/Plugins/Wox.Plugin.Everything/PortableEverything/x86/Everything.dll and /dev/null differ diff --git a/Plugins/Wox.Plugin.Everything/PortableEverything/x86/Everything.exe b/Plugins/Wox.Plugin.Everything/PortableEverything/x86/Everything.exe deleted file mode 100644 index db310db054..0000000000 Binary files a/Plugins/Wox.Plugin.Everything/PortableEverything/x86/Everything.exe and /dev/null differ diff --git a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj index e721aad5ff..1cf7768ad2 100644 --- a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj +++ b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj @@ -71,6 +71,12 @@ + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -89,18 +95,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - diff --git a/Plugins/Wox.Plugin.Everything/nativesrc/Everything.c b/Plugins/Wox.Plugin.Everything/nativesrc/Everything.c deleted file mode 100644 index fa74002337..0000000000 --- a/Plugins/Wox.Plugin.Everything/nativesrc/Everything.c +++ /dev/null @@ -1,1801 +0,0 @@ - -// disable warnings -#pragma warning(disable : 4996) // deprecation - -#define EVERYTHINGUSERAPI __declspec(dllexport) - -// include -#include "Everything.h" -#include "Everything_IPC.h" - -// return copydata code -#define _EVERYTHING_COPYDATA_QUERYCOMPLETEA 0 -#define _EVERYTHING_COPYDATA_QUERYCOMPLETEW 1 - -// internal state -static BOOL _Everything_MatchPath = FALSE; -static BOOL _Everything_MatchCase = FALSE; -static BOOL _Everything_MatchWholeWord = FALSE; -static BOOL _Everything_Regex = FALSE; -static DWORD _Everything_LastError = FALSE; -static DWORD _Everything_Max = EVERYTHING_IPC_ALLRESULTS; -static DWORD _Everything_Offset = 0; -static BOOL _Everything_IsUnicodeQuery = FALSE; -static BOOL _Everything_IsUnicodeSearch = FALSE; -static LPVOID _Everything_Search = NULL; // wchar or char -static LPVOID _Everything_List = NULL; // EVERYTHING_IPC_LISTW or EVERYTHING_IPC_LISTA -static volatile BOOL _Everything_Initialized = FALSE; -static volatile LONG _Everything_InterlockedCount = 0; -static CRITICAL_SECTION _Everything_cs; -static HWND _Everything_ReplyWindow = 0; -static DWORD _Everything_ReplyID = 0; - -static VOID _Everything_Initialize(VOID) -{ - if (!_Everything_Initialized) - { - if (InterlockedIncrement(&_Everything_InterlockedCount) == 1) - { - // do the initialization.. - InitializeCriticalSection(&_Everything_cs); - - _Everything_Initialized = 1; - } - else - { - // wait for initialization.. - while (!_Everything_Initialized) Sleep(0); - } - } -} - -static VOID _Everything_Lock(VOID) -{ - _Everything_Initialize(); - - EnterCriticalSection(&_Everything_cs); -} - -static VOID _Everything_Unlock(VOID) -{ - LeaveCriticalSection(&_Everything_cs); -} - -// aVOID other libs -static int _Everything_StringLengthA(LPCSTR start) -{ - register LPCSTR s; - - s = start; - - while(*s) - { - s++; - } - - return (int)(s-start); -} - -static int _Everything_StringLengthW(LPCWSTR start) -{ - register LPCWSTR s; - - s = start; - - while(*s) - { - s++; - } - - return (int)(s-start); -} - -VOID EVERYTHINGAPI Everything_SetSearchW(LPCWSTR lpString) -{ - int len; - - _Everything_Lock(); - - if (_Everything_Search) HeapFree(GetProcessHeap(),0,_Everything_Search); - - len = _Everything_StringLengthW(lpString) + 1; - - _Everything_Search = HeapAlloc(GetProcessHeap(),0,len*sizeof(wchar_t)); - if (_Everything_Search) - { - CopyMemory(_Everything_Search,lpString,len*sizeof(wchar_t)); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_MEMORY; - } - - _Everything_IsUnicodeSearch = 1; - - _Everything_Unlock(); -} - -VOID EVERYTHINGAPI Everything_SetSearchA(LPCSTR lpString) -{ - int size; - - _Everything_Lock(); - - if (_Everything_Search) HeapFree(GetProcessHeap(),0,_Everything_Search); - - size = _Everything_StringLengthA(lpString) + 1; - - _Everything_Search = (LPWSTR )HeapAlloc(GetProcessHeap(),0,size); - if (_Everything_Search) - { - CopyMemory(_Everything_Search,lpString,size); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_MEMORY; - } - - _Everything_IsUnicodeSearch = 0; - - _Everything_Unlock(); -} - -LPCSTR EVERYTHINGAPI Everything_GetSearchA(VOID) -{ - LPCSTR ret; - - _Everything_Lock(); - - if (_Everything_Search) - { - if (_Everything_IsUnicodeSearch) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = NULL; - } - else - { - ret = (LPCSTR)_Everything_Search; - } - } - else - { - ret = ""; - } - - _Everything_Unlock(); - - return ret; -} - -LPCWSTR EVERYTHINGAPI Everything_GetSearchW(VOID) -{ - LPCWSTR ret; - - _Everything_Lock(); - - if (_Everything_Search) - { - if (!_Everything_IsUnicodeSearch) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = NULL; - } - else - { - ret = (LPCWSTR)_Everything_Search; - } - } - else - { - ret = L""; - } - - _Everything_Unlock(); - - return ret; -} - -VOID EVERYTHINGAPI Everything_SetMatchPath(BOOL bEnable) -{ - _Everything_Lock(); - - _Everything_MatchPath = bEnable; - - _Everything_Unlock(); -} - -VOID EVERYTHINGAPI Everything_SetMatchCase(BOOL bEnable) -{ - _Everything_Lock(); - - _Everything_MatchCase = bEnable; - - _Everything_Unlock(); -} - -VOID EVERYTHINGAPI Everything_SetMatchWholeWord(BOOL bEnable) -{ - _Everything_Lock(); - - _Everything_MatchWholeWord = bEnable; - - _Everything_Unlock(); -} - -VOID EVERYTHINGAPI Everything_SetRegex(BOOL bEnable) -{ - _Everything_Lock(); - - _Everything_Regex = bEnable; - - _Everything_Unlock(); -} - -VOID EVERYTHINGAPI Everything_SetMax(DWORD dwMax) -{ - _Everything_Lock(); - - _Everything_Max = dwMax; - - _Everything_Unlock(); -} - -VOID EVERYTHINGAPI Everything_SetOffset(DWORD dwOffset) -{ - _Everything_Lock(); - - _Everything_Offset = dwOffset; - - _Everything_Unlock(); -} - -VOID EVERYTHINGAPI Everything_SetReplyWindow(HWND hWnd) -{ - _Everything_Lock(); - - _Everything_ReplyWindow = hWnd; - - _Everything_Unlock(); -} - -VOID EVERYTHINGAPI Everything_SetReplyID(DWORD nId) -{ - _Everything_Lock(); - - _Everything_ReplyID = nId; - - _Everything_Unlock(); -} - -BOOL EVERYTHINGAPI Everything_GetMatchPath(VOID) -{ - BOOL ret; - - _Everything_Lock(); - - ret = _Everything_MatchPath; - - _Everything_Unlock(); - - return ret; -} - -BOOL EVERYTHINGAPI Everything_GetMatchCase(VOID) -{ - BOOL ret; - - _Everything_Lock(); - - ret = _Everything_MatchCase; - - _Everything_Unlock(); - - return ret; -} - -BOOL EVERYTHINGAPI Everything_GetMatchWholeWord(VOID) -{ - BOOL ret; - - _Everything_Lock(); - - ret = _Everything_MatchWholeWord; - - _Everything_Unlock(); - - return ret; -} - -BOOL EVERYTHINGAPI Everything_GetRegex(VOID) -{ - BOOL ret; - - _Everything_Lock(); - - ret = _Everything_Regex; - - _Everything_Unlock(); - - return ret; -} - -DWORD EVERYTHINGAPI Everything_GetMax(VOID) -{ - BOOL ret; - - _Everything_Lock(); - - ret = _Everything_Max; - - _Everything_Unlock(); - - return ret; -} - -DWORD EVERYTHINGAPI Everything_GetOffset(VOID) -{ - BOOL ret; - - _Everything_Lock(); - - ret = _Everything_Offset; - - _Everything_Unlock(); - - return ret; -} - -HWND EVERYTHINGAPI Everything_GetReplyWindow(VOID) -{ - HWND ret; - - _Everything_Lock(); - - ret = _Everything_ReplyWindow; - - _Everything_Unlock(); - - return ret; -} - -DWORD EVERYTHINGAPI Everything_GetReplyID(VOID) -{ - DWORD ret; - - _Everything_Lock(); - - ret = _Everything_ReplyID; - - _Everything_Unlock(); - - return ret; -} - -// custom window proc -static LRESULT EVERYTHINGAPI _Everything_window_proc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - switch(msg) - { - case WM_COPYDATA: - { - COPYDATASTRUCT *cds = (COPYDATASTRUCT *)lParam; - - switch(cds->dwData) - { - case _EVERYTHING_COPYDATA_QUERYCOMPLETEA: - - if (!_Everything_IsUnicodeQuery) - { - if (_Everything_List) HeapFree(GetProcessHeap(),0,_Everything_List); - - _Everything_List = (EVERYTHING_IPC_LISTW *)HeapAlloc(GetProcessHeap(),0,cds->cbData); - - if (_Everything_List) - { - CopyMemory(_Everything_List,cds->lpData,cds->cbData); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_MEMORY; - } - - PostQuitMessage(0); - - return TRUE; - } - - break; - - case _EVERYTHING_COPYDATA_QUERYCOMPLETEW: - - if (_Everything_IsUnicodeQuery) - { - if (_Everything_List) HeapFree(GetProcessHeap(),0,_Everything_List); - - _Everything_List = (EVERYTHING_IPC_LISTW *)HeapAlloc(GetProcessHeap(),0,cds->cbData); - - if (_Everything_List) - { - CopyMemory(_Everything_List,cds->lpData,cds->cbData); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_MEMORY; - } - - PostQuitMessage(0); - - return TRUE; - } - - break; - } - - break; - } - } - - return DefWindowProc(hwnd,msg,wParam,lParam); -} - -// get the search length -static int _Everything_GetSearchLengthW(VOID) -{ - if (_Everything_Search) - { - if (_Everything_IsUnicodeSearch) - { - return _Everything_StringLengthW((LPCWSTR )_Everything_Search); - } - else - { - return MultiByteToWideChar(CP_ACP,0,(LPCSTR )_Everything_Search,-1,0,0); - } - } - - return 0; -} - -// get the search length -static int _Everything_GetSearchLengthA(VOID) -{ - if (_Everything_Search) - { - if (_Everything_IsUnicodeSearch) - { - return WideCharToMultiByte(CP_ACP,0,(LPCWSTR )_Everything_Search,-1,0,0,0,0); - } - else - { - return _Everything_StringLengthA((LPCSTR )_Everything_Search); - } - } - - return 0; -} - -// get the search length -static VOID _Everything_GetSearchTextW(LPWSTR wbuf) -{ - int wlen; - - if (_Everything_Search) - { - wlen = _Everything_GetSearchLengthW(); - - if (_Everything_IsUnicodeSearch) - { - CopyMemory(wbuf,_Everything_Search,(wlen+1) * sizeof(wchar_t)); - - return; - } - else - { - MultiByteToWideChar(CP_ACP,0,(LPCSTR )_Everything_Search,-1,wbuf,wlen+1); - - return; - } - } - - *wbuf = 0; -} - -// get the search length -static VOID _Everything_GetSearchTextA(LPSTR buf) -{ - int len; - - if (_Everything_Search) - { - len = _Everything_GetSearchLengthW(); - - if (_Everything_IsUnicodeSearch) - { - WideCharToMultiByte(CP_ACP,0,(LPCWSTR )_Everything_Search,-1,buf,len+1,0,0); - - return; - } - else - { - CopyMemory(buf,_Everything_Search,len+1); - - return; - } - } - - *buf = 0; -} - -static DWORD EVERYTHINGAPI _Everything_thread_proc(VOID *param) -{ - HWND everything_hwnd; - COPYDATASTRUCT cds; - WNDCLASSEX wcex; - HWND hwnd; - MSG msg; - int ret; - int len; - int size; - union - { - EVERYTHING_IPC_QUERYA *queryA; - EVERYTHING_IPC_QUERYW *queryW; - VOID *query; - }q; - - ZeroMemory(&wcex,sizeof(wcex)); - wcex.cbSize = sizeof(wcex); - - if (!GetClassInfoEx(GetModuleHandle(0),TEXT("EVERYTHING_DLL"),&wcex)) - { - ZeroMemory(&wcex,sizeof(wcex)); - wcex.cbSize = sizeof(wcex); - wcex.hInstance = GetModuleHandle(0); - wcex.lpfnWndProc = _Everything_window_proc; - wcex.lpszClassName = TEXT("EVERYTHING_DLL"); - - if (!RegisterClassEx(&wcex)) - { - _Everything_LastError = EVERYTHING_ERROR_REGISTERCLASSEX; - - return 0; - } - } - - hwnd = CreateWindow( - TEXT("EVERYTHING_DLL"), - TEXT(""), - 0, - 0,0,0,0, - 0,0,GetModuleHandle(0),0); - - if (hwnd) - { - everything_hwnd = FindWindow(EVERYTHING_IPC_WNDCLASS,0); - if (everything_hwnd) - { - LPVOID a; - - if (param) - { - // unicode - len = _Everything_GetSearchLengthW(); - - size = sizeof(EVERYTHING_IPC_QUERYW) - sizeof(wchar_t) + len*sizeof(wchar_t) + sizeof(wchar_t); - } - else - { - // ansi - len = _Everything_GetSearchLengthA(); - - size = sizeof(EVERYTHING_IPC_QUERYA) - sizeof(char) + (len*sizeof(char)) + sizeof(char); - } - - // alloc - a = HeapAlloc(GetProcessHeap(),0,size); - q.query = (EVERYTHING_IPC_QUERYW *)a; - - if (q.query) - { - if (param) - { - q.queryW->max_results = _Everything_Max; - q.queryW->offset = _Everything_Offset; - q.queryW->reply_copydata_message = _EVERYTHING_COPYDATA_QUERYCOMPLETEW; - q.queryW->search_flags = (_Everything_Regex?EVERYTHING_IPC_REGEX:0) | (_Everything_MatchCase?EVERYTHING_IPC_MATCHCASE:0) | (_Everything_MatchWholeWord?EVERYTHING_IPC_MATCHWHOLEWORD:0) | (_Everything_MatchPath?EVERYTHING_IPC_MATCHPATH:0); - q.queryW->reply_hwnd = (INT32) hwnd; - - _Everything_GetSearchTextW((LPWSTR) q.queryW->search_string); - } - else - { - q.queryA->max_results = _Everything_Max; - q.queryA->offset = _Everything_Offset; - q.queryA->reply_copydata_message = _EVERYTHING_COPYDATA_QUERYCOMPLETEA; - q.queryA->search_flags = (_Everything_Regex?EVERYTHING_IPC_REGEX:0) | (_Everything_MatchCase?EVERYTHING_IPC_MATCHCASE:0) | (_Everything_MatchWholeWord?EVERYTHING_IPC_MATCHWHOLEWORD:0) | (_Everything_MatchPath?EVERYTHING_IPC_MATCHPATH:0); - q.queryA->reply_hwnd = (INT32)hwnd; - - _Everything_GetSearchTextA((LPSTR) q.queryA->search_string); - } - - cds.cbData = size; - cds.dwData = param?EVERYTHING_IPC_COPYDATAQUERYW:EVERYTHING_IPC_COPYDATAQUERYA; - cds.lpData = q.query; - - if (SendMessage(everything_hwnd,WM_COPYDATA,(WPARAM)hwnd,(LPARAM)&cds) == TRUE) - { - // message pump - loop: - - WaitMessage(); - - // update windows - while(PeekMessage(&msg,NULL,0,0,0)) - { - ret = (int)GetMessage(&msg,0,0,0); - if (ret == -1) goto exit; - if (!ret) goto exit; - - // let windows handle it. - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - goto loop; - - exit: - - // get result from window. - DestroyWindow(hwnd); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_IPC; - } - - // get result from window. - HeapFree(GetProcessHeap(),0,q.query); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_MEMORY; - } - } - else - { - // the everything window was not found. - // we can optionally RegisterWindowMessage("EVERYTHING_IPC_CREATED") and - // wait for Everything to post this message to all top level windows when its up and running. - _Everything_LastError = EVERYTHING_ERROR_IPC; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_CREATEWINDOW; - } - - return 0; -} - -static BOOL EVERYTHINGAPI _Everything_Query(BOOL bUnicode) -{ - HANDLE hthread; - DWORD threadid; - VOID *param; - - // reset the error flag. - _Everything_LastError = 0; - - if (bUnicode) - { - param = (VOID *)1; - } - else - { - param = 0; - } - - _Everything_IsUnicodeQuery = bUnicode; - - hthread = CreateThread(0,0,_Everything_thread_proc,param,0,&threadid); - - if (hthread) - { - WaitForSingleObject(hthread,INFINITE); - - CloseHandle(hthread); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_CREATETHREAD; - } - - return (_Everything_LastError == 0)?TRUE:FALSE; -} - - -BOOL _Everything_SendIPCQuery(BOOL bUnicode) -{ - HWND everything_hwnd; - COPYDATASTRUCT cds; - int ret; - int len; - int size; - union - { - EVERYTHING_IPC_QUERYA *queryA; - EVERYTHING_IPC_QUERYW *queryW; - VOID *query; - }q; - - _Everything_IsUnicodeQuery = bUnicode; - - // find the everything ipc window. - everything_hwnd = FindWindow(EVERYTHING_IPC_WNDCLASS,0); - if (everything_hwnd) - { - if (bUnicode) - { - // unicode - len = _Everything_GetSearchLengthW(); - - size = sizeof(EVERYTHING_IPC_QUERYW) - sizeof(wchar_t) + len*sizeof(wchar_t) + sizeof(wchar_t); - } - else - { - // ansi - len = _Everything_GetSearchLengthA(); - - size = sizeof(EVERYTHING_IPC_QUERYA) - sizeof(char) + (len*sizeof(char)) + sizeof(char); - } - - // alloc - q.query = (EVERYTHING_IPC_QUERYW *)HeapAlloc(GetProcessHeap(),0,size); - - if (q.query) - { - if (bUnicode) - { - q.queryW->max_results = _Everything_Max; - q.queryW->offset = _Everything_Offset; - q.queryW->reply_copydata_message = _Everything_ReplyID; - q.queryW->search_flags = (_Everything_Regex?EVERYTHING_IPC_REGEX:0) | (_Everything_MatchCase?EVERYTHING_IPC_MATCHCASE:0) | (_Everything_MatchWholeWord?EVERYTHING_IPC_MATCHWHOLEWORD:0) | (_Everything_MatchPath?EVERYTHING_IPC_MATCHPATH:0); - q.queryW->reply_hwnd = (INT32) _Everything_ReplyWindow; - - _Everything_GetSearchTextW((LPWSTR) q.queryW->search_string); - } - else - { - q.queryA->max_results = _Everything_Max; - q.queryA->offset = _Everything_Offset; - q.queryA->reply_copydata_message = _Everything_ReplyID; - q.queryA->search_flags = (_Everything_Regex?EVERYTHING_IPC_REGEX:0) | (_Everything_MatchCase?EVERYTHING_IPC_MATCHCASE:0) | (_Everything_MatchWholeWord?EVERYTHING_IPC_MATCHWHOLEWORD:0) | (_Everything_MatchPath?EVERYTHING_IPC_MATCHPATH:0); - q.queryA->reply_hwnd = (INT32) _Everything_ReplyWindow; - - _Everything_GetSearchTextA((LPSTR) q.queryA->search_string); - } - - cds.cbData = size; - cds.dwData = bUnicode?EVERYTHING_IPC_COPYDATAQUERYW:EVERYTHING_IPC_COPYDATAQUERYA; - cds.lpData = q.query; - - if (SendMessage(everything_hwnd,WM_COPYDATA,(WPARAM)_Everything_ReplyWindow,(LPARAM)&cds)) - { - // sucessful. - ret = TRUE; - } - else - { - // no ipc - _Everything_LastError = EVERYTHING_ERROR_IPC; - - ret = FALSE; - } - - // get result from window. - HeapFree(GetProcessHeap(),0,q.query); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_MEMORY; - - ret = FALSE; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_IPC; - - ret = FALSE; - } - - return ret; -} - -BOOL EVERYTHINGAPI Everything_QueryA(BOOL bWait) -{ - BOOL ret; - - _Everything_Lock(); - - if (bWait) - { - ret = _Everything_Query(FALSE); - } - else - { - ret = _Everything_SendIPCQuery(FALSE); - } - - _Everything_Unlock(); - - return ret; -} - -BOOL EVERYTHINGAPI Everything_QueryW(BOOL bWait) -{ - BOOL ret; - - _Everything_Lock(); - - if (bWait) - { - ret = _Everything_Query(TRUE); - } - else - { - ret = _Everything_SendIPCQuery(TRUE); - } - - _Everything_Unlock(); - - return ret; -} - -static int _Everything_CompareA(const VOID *a,const VOID *b) -{ - int i; - - i = stricmp(EVERYTHING_IPC_ITEMPATH(_Everything_List,a),EVERYTHING_IPC_ITEMPATH(_Everything_List,b)); - - if (!i) - { - return stricmp(EVERYTHING_IPC_ITEMFILENAMEA(_Everything_List,a),EVERYTHING_IPC_ITEMFILENAMEA(_Everything_List,b)); - } - else - if (i > 0) - { - return 1; - } - else - { - return -1; - } -} - -static int _Everything_CompareW(const VOID *a,const VOID *b) -{ - int i; - - i = stricmp(EVERYTHING_IPC_ITEMPATH(_Everything_List,a),EVERYTHING_IPC_ITEMPATH(_Everything_List,b)); - - if (!i) - { - return wcsicmp(EVERYTHING_IPC_ITEMFILENAMEW(_Everything_List,a),EVERYTHING_IPC_ITEMFILENAMEW(_Everything_List,b)); - } - else - if (i > 0) - { - return 1; - } - else - { - return -1; - } -} - -VOID EVERYTHINGAPI Everything_SortResultsByPath(VOID) -{ - _Everything_Lock(); - - if (_Everything_List) - { - if (_Everything_IsUnicodeQuery) - { - qsort(((EVERYTHING_IPC_LISTW *)_Everything_List)->items,((EVERYTHING_IPC_LISTW *)_Everything_List)->numitems,sizeof(EVERYTHING_IPC_ITEMW),_Everything_CompareW); - } - else - { - qsort(((EVERYTHING_IPC_LISTA *)_Everything_List)->items,((EVERYTHING_IPC_LISTA *)_Everything_List)->numitems,sizeof(EVERYTHING_IPC_ITEMA),_Everything_CompareA); - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - } - - _Everything_Unlock(); -} - -DWORD EVERYTHINGAPI Everything_GetLastError(VOID) -{ - DWORD ret; - - _Everything_Lock(); - - ret = _Everything_LastError; - - _Everything_Unlock(); - - return ret; -} - -int EVERYTHINGAPI Everything_GetNumFileResults(VOID) -{ - int ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (_Everything_IsUnicodeQuery) - { - ret = ((EVERYTHING_IPC_LISTW *)_Everything_List)->numfiles; - } - else - { - ret = ((EVERYTHING_IPC_LISTA *)_Everything_List)->numfiles; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = 0; - } - - _Everything_Unlock(); - - return ret; -} - -int EVERYTHINGAPI Everything_GetNumFolderResults(VOID) -{ - int ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (_Everything_IsUnicodeQuery) - { - ret = ((EVERYTHING_IPC_LISTW *)_Everything_List)->numfolders; - } - else - { - ret = ((EVERYTHING_IPC_LISTA *)_Everything_List)->numfolders; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = 0; - } - - _Everything_Unlock(); - - return ret; -} - -int EVERYTHINGAPI Everything_GetNumResults(VOID) -{ - int ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (_Everything_IsUnicodeQuery) - { - ret = ((EVERYTHING_IPC_LISTW *)_Everything_List)->numitems; - } - else - { - ret = ((EVERYTHING_IPC_LISTA *)_Everything_List)->numitems; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = 0; - } - - _Everything_Unlock(); - - return ret; -} - -int EVERYTHINGAPI Everything_GetTotFileResults(VOID) -{ - int ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (_Everything_IsUnicodeQuery) - { - ret = ((EVERYTHING_IPC_LISTW *)_Everything_List)->totfiles; - } - else - { - ret = ((EVERYTHING_IPC_LISTA *)_Everything_List)->totfiles; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = 0; - } - - _Everything_Unlock(); - - return ret; -} - -int EVERYTHINGAPI Everything_GetTotFolderResults(VOID) -{ - int ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (_Everything_IsUnicodeQuery) - { - ret = ((EVERYTHING_IPC_LISTW *)_Everything_List)->totfolders; - } - else - { - ret = ((EVERYTHING_IPC_LISTA *)_Everything_List)->totfolders; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = 0; - } - - _Everything_Unlock(); - - return ret; -} - -int EVERYTHINGAPI Everything_GetTotResults(VOID) -{ - int ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (_Everything_IsUnicodeQuery) - { - ret = ((EVERYTHING_IPC_LISTW *)_Everything_List)->totitems; - } - else - { - ret = ((EVERYTHING_IPC_LISTA *)_Everything_List)->totitems; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = 0; - } - - _Everything_Unlock(); - - return ret; -} - -BOOL EVERYTHINGAPI Everything_IsVolumeResult(int nIndex) -{ - BOOL ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = FALSE; - - goto exit; - } - - if (nIndex >= Everything_GetNumResults()) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = FALSE; - - goto exit; - } - - if (_Everything_IsUnicodeQuery) - { - ret = ((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex].flags & EVERYTHING_IPC_DRIVE; - } - else - { - ret = ((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex].flags & EVERYTHING_IPC_DRIVE; - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = FALSE; - } - -exit: - - _Everything_Unlock(); - - return ret; -} - -BOOL EVERYTHINGAPI Everything_IsFolderResult(int nIndex) -{ - BOOL ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = FALSE; - - goto exit; - } - - if (nIndex >= Everything_GetNumResults()) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = FALSE; - - goto exit; - } - - if (_Everything_IsUnicodeQuery) - { - ret = ((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex].flags & (EVERYTHING_IPC_DRIVE|EVERYTHING_IPC_FOLDER); - } - else - { - ret = ((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex].flags & (EVERYTHING_IPC_DRIVE|EVERYTHING_IPC_FOLDER); - } - } - else - { - ret = FALSE; - } - -exit: - - _Everything_Unlock(); - - return ret; -} - -BOOL EVERYTHINGAPI Everything_IsFileResult(int nIndex) -{ - BOOL ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = FALSE; - - goto exit; - } - - if (nIndex >= Everything_GetNumResults()) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = FALSE; - - goto exit; - } - - if (_Everything_IsUnicodeQuery) - { - ret = !(((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex].flags & (EVERYTHING_IPC_DRIVE|EVERYTHING_IPC_FOLDER)); - } - else - { - ret = !(((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex].flags & (EVERYTHING_IPC_DRIVE|EVERYTHING_IPC_FOLDER)); - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = FALSE; - } - -exit: - - _Everything_Unlock(); - - return ret; -} - -LPCWSTR EVERYTHINGAPI Everything_GetResultFileNameW(int nIndex) -{ - LPCWSTR ret; - - _Everything_Lock(); - - if ((_Everything_List) && (_Everything_IsUnicodeQuery)) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = NULL; - - goto exit; - } - - if (nIndex >= (int)((EVERYTHING_IPC_LISTW *)_Everything_List)->numitems) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = NULL; - - goto exit; - } - - ret = EVERYTHING_IPC_ITEMFILENAMEW(_Everything_List,&((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex]); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = NULL; - } - -exit: - - _Everything_Unlock(); - - return ret; -} - -LPCSTR EVERYTHINGAPI Everything_GetResultFileNameA(int nIndex) -{ - LPCSTR ret; - - _Everything_Lock(); - - if ((_Everything_List) && (!_Everything_IsUnicodeQuery)) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = NULL; - - goto exit; - } - - if (nIndex >= (int)((EVERYTHING_IPC_LISTA *)_Everything_List)->numitems) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = NULL; - - goto exit; - } - - ret = EVERYTHING_IPC_ITEMFILENAMEA(_Everything_List,&((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex]); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = NULL; - } - -exit: - - _Everything_Unlock(); - - return ret; -} - -LPCWSTR EVERYTHINGAPI Everything_GetResultPathW(int nIndex) -{ - LPCWSTR ret; - - _Everything_Lock(); - - if ((_Everything_List) && (_Everything_IsUnicodeQuery)) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = NULL; - - goto exit; - } - - if (nIndex >= (int)((EVERYTHING_IPC_LISTW *)_Everything_List)->numitems) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = NULL; - - goto exit; - } - - ret = EVERYTHING_IPC_ITEMPATHW(_Everything_List,&((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex]); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = NULL; - } - -exit: - - _Everything_Unlock(); - - return ret; -} - -LPCSTR EVERYTHINGAPI Everything_GetResultPathA(int nIndex) -{ - LPCSTR ret; - - _Everything_Lock(); - - if (_Everything_List) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = NULL; - - goto exit; - } - - if (nIndex >= (int)((EVERYTHING_IPC_LISTA *)_Everything_List)->numitems) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - ret = NULL; - - goto exit; - } - - ret = EVERYTHING_IPC_ITEMPATHA(_Everything_List,&((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex]); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - ret = NULL; - } - -exit: - - _Everything_Unlock(); - - return ret; -} - -// max is in chars -static int _Everything_CopyW(LPWSTR buf,int bufmax,int catlen,LPCWSTR s) -{ - int wlen; - - if (buf) - { - buf += catlen; - bufmax -= catlen; - } - - wlen = _Everything_StringLengthW(s); - if (!wlen) - { - if (buf) - { - buf[wlen] = 0; - } - - return catlen; - } - - // terminate - if (wlen > bufmax-1) wlen = bufmax-1; - - if (buf) - { - CopyMemory(buf,s,wlen*sizeof(wchar_t)); - - buf[wlen] = 0; - } - - return wlen + catlen; -} - -static int _Everything_CopyA(LPSTR buf,int max,int catlen,LPCSTR s) -{ - int len; - - if (buf) - { - buf += catlen; - max -= catlen; - } - - len = _Everything_StringLengthA(s); - if (!len) - { - if (buf) - { - buf[len] = 0; - } - - return catlen; - } - - // terminate - if (len > max-1) len = max-1; - - if (buf) - { - CopyMemory(buf,s,len*sizeof(char)); - - buf[len] = 0; - } - - return len + catlen; - -} - -// max is in chars -static int _Everything_CopyWFromA(LPWSTR buf,int bufmax,int catlen,LPCSTR s) -{ - int wlen; - - if (buf) - { - buf += catlen; - bufmax -= catlen; - } - - wlen = MultiByteToWideChar(CP_ACP,0,s,_Everything_StringLengthA(s),0,0); - if (!wlen) - { - if (buf) - { - buf[wlen] = 0; - } - - return catlen; - } - - // terminate - if (wlen > bufmax-1) wlen = bufmax-1; - - if (buf) - { - MultiByteToWideChar(CP_ACP,0,s,_Everything_StringLengthA(s),buf,wlen); - - buf[wlen] = 0; - } - - return wlen + catlen; -} - -static int _Everything_CopyAFromW(LPSTR buf,int max,int catlen,LPCWSTR s) -{ - int len; - - if (buf) - { - buf += catlen; - max -= catlen; - } - - len = WideCharToMultiByte(CP_ACP,0,s,_Everything_StringLengthW(s),0,0,0,0); - if (!len) - { - if (buf) - { - buf[len] = 0; - } - - return catlen; - } - - // terminate - if (len > max-1) len = max-1; - - if (buf) - { - WideCharToMultiByte(CP_ACP,0,s,_Everything_StringLengthW(s),buf,len,0,0); - - buf[len] = 0; - } - - return len + catlen; - -} - -int EVERYTHINGUSERAPI Everything_GetResultFullPathNameW(int nIndex,LPWSTR wbuf,int wbuf_size_in_wchars) -{ - int len; - - _Everything_Lock(); - - if (_Everything_List) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - len = _Everything_CopyW(wbuf,wbuf_size_in_wchars,0,L""); - - goto exit; - } - - if (nIndex >= (int)((EVERYTHING_IPC_LISTW *)_Everything_List)->numitems) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - len = _Everything_CopyW(wbuf,wbuf_size_in_wchars,0,L""); - - goto exit; - } - - len = 0; - - if (_Everything_IsUnicodeQuery) - { - len = _Everything_CopyW(wbuf,wbuf_size_in_wchars,len,EVERYTHING_IPC_ITEMPATHW(_Everything_List,&((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex])); - } - else - { - len = _Everything_CopyWFromA(wbuf,wbuf_size_in_wchars,len,EVERYTHING_IPC_ITEMPATHA(_Everything_List,&((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex])); - } - - if (len) - { - len = _Everything_CopyW(wbuf,wbuf_size_in_wchars,len,L"\\"); - } - - if (_Everything_IsUnicodeQuery) - { - len = _Everything_CopyW(wbuf,wbuf_size_in_wchars,len,EVERYTHING_IPC_ITEMFILENAMEW(_Everything_List,&((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex])); - } - else - { - len = _Everything_CopyWFromA(wbuf,wbuf_size_in_wchars,len,EVERYTHING_IPC_ITEMFILENAMEA(_Everything_List,&((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex])); - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - len = _Everything_CopyW(wbuf,wbuf_size_in_wchars,0,L""); - } - -exit: - - _Everything_Unlock(); - - return len; -} - -int EVERYTHINGUSERAPI Everything_GetResultFullPathNameA(int nIndex,LPSTR buf,int bufsize) -{ - int len; - - _Everything_Lock(); - - if (_Everything_List) - { - if (nIndex < 0) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - len = _Everything_CopyA(buf,bufsize,0,""); - - goto exit; - } - - if (nIndex >= (int)((EVERYTHING_IPC_LISTW *)_Everything_List)->numitems) - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDINDEX; - - len = _Everything_CopyA(buf,bufsize,0,""); - - goto exit; - } - - len = 0; - - if (_Everything_IsUnicodeQuery) - { - len = _Everything_CopyAFromW(buf,bufsize,len,EVERYTHING_IPC_ITEMPATHW(_Everything_List,&((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex])); - } - else - { - len = _Everything_CopyA(buf,bufsize,len,EVERYTHING_IPC_ITEMPATHA(_Everything_List,&((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex])); - } - - if (len) - { - len = _Everything_CopyA(buf,bufsize,len,"\\"); - } - - if (_Everything_IsUnicodeQuery) - { - len = _Everything_CopyAFromW(buf,bufsize,len,EVERYTHING_IPC_ITEMFILENAMEW(_Everything_List,&((EVERYTHING_IPC_LISTW *)_Everything_List)->items[nIndex])); - } - else - { - len = _Everything_CopyA(buf,bufsize,len,EVERYTHING_IPC_ITEMFILENAMEA(_Everything_List,&((EVERYTHING_IPC_LISTA *)_Everything_List)->items[nIndex])); - } - } - else - { - _Everything_LastError = EVERYTHING_ERROR_INVALIDCALL; - - len = _Everything_CopyA(buf,bufsize,0,""); - } - -exit: - - _Everything_Unlock(); - - return len; -} - -BOOL EVERYTHINGAPI Everything_IsQueryReply(UINT message,WPARAM wParam,LPARAM lParam,DWORD nId) -{ - if (message == WM_COPYDATA) - { - COPYDATASTRUCT *cds = (COPYDATASTRUCT *)lParam; - - if (cds) - { - if (cds->dwData == _Everything_ReplyID) - { - if (_Everything_IsUnicodeQuery) - { - if (_Everything_List) HeapFree(GetProcessHeap(),0,_Everything_List); - - _Everything_List = (EVERYTHING_IPC_LISTW *)HeapAlloc(GetProcessHeap(),0,cds->cbData); - - if (_Everything_List) - { - CopyMemory(_Everything_List,cds->lpData,cds->cbData); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_MEMORY; - } - - return TRUE; - } - else - { - if (_Everything_List) HeapFree(GetProcessHeap(),0,_Everything_List); - - _Everything_List = (EVERYTHING_IPC_LISTW *)HeapAlloc(GetProcessHeap(),0,cds->cbData); - - if (_Everything_List) - { - CopyMemory(_Everything_List,cds->lpData,cds->cbData); - } - else - { - _Everything_LastError = EVERYTHING_ERROR_MEMORY; - } - - return TRUE; - } - } - } - } - - return FALSE; -} - -VOID EVERYTHINGUSERAPI Everything_Reset(VOID) -{ - _Everything_Lock(); - - if (_Everything_Search) - { - HeapFree(GetProcessHeap(),0,_Everything_Search); - - _Everything_Search = 0; - } - - if (_Everything_List) - { - HeapFree(GetProcessHeap(),0,_Everything_List); - - _Everything_List = 0; - } - - // reset state - _Everything_MatchPath = FALSE; - _Everything_MatchCase = FALSE; - _Everything_MatchWholeWord = FALSE; - _Everything_Regex = FALSE; - _Everything_LastError = FALSE; - _Everything_Max = EVERYTHING_IPC_ALLRESULTS; - _Everything_Offset = 0; - _Everything_IsUnicodeQuery = FALSE; - _Everything_IsUnicodeSearch = FALSE; - - _Everything_Unlock(); -} - -//VOID DestroyResultArray(VOID *) - -// testing -/* -int main(int argc,char **argv) -{ - char buf[MAX_PATH]; - wchar_t wbuf[MAX_PATH]; - - // set search -// Everything_SetSearchA("sonic"); - Everything_SetSearchW(L"sonic"); - -// Everything_QueryA(); - Everything_QueryW(TRUE); - -// Everything_GetResultFullPathNameA(0,buf,sizeof(buf)); - Everything_GetResultFullPathNameW(0,wbuf,sizeof(wbuf)/sizeof(wchar_t)); - -// MessageBoxA(0,buf,"result 1",MB_OK); - MessageBoxW(0,wbuf,L"result 1",MB_OK); - -// MessageBoxA(0,resultA.cFileName,"result 1",MB_OK); -// MessageBoxW(0,resultW.cFileName,L"result 1",MB_OK); -} -*/ \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Everything/nativesrc/Everything.def b/Plugins/Wox.Plugin.Everything/nativesrc/Everything.def deleted file mode 100644 index 389f868855..0000000000 --- a/Plugins/Wox.Plugin.Everything/nativesrc/Everything.def +++ /dev/null @@ -1,51 +0,0 @@ -LIBRARY Everything - -EXPORTS - - Everything_GetLastError - - Everything_SetSearchA - Everything_SetSearchW - Everything_SetMatchPath - Everything_SetMatchCase - Everything_SetMatchWholeWord - Everything_SetRegex - Everything_SetMax - Everything_SetOffset - - Everything_GetSearchA - Everything_GetSearchW - Everything_GetMatchPath - Everything_GetMatchCase - Everything_GetMatchWholeWord - Everything_GetRegex - Everything_GetMax - Everything_GetOffset - - Everything_QueryA - Everything_QueryW - - Everything_IsQueryReply - - Everything_SortResultsByPath - - Everything_GetNumFileResults - Everything_GetNumFolderResults - Everything_GetNumResults - Everything_GetTotFileResults - Everything_GetTotFolderResults - Everything_GetTotResults - - Everything_IsVolumeResult - Everything_IsFolderResult - Everything_IsFileResult - - Everything_GetResultFileNameA - Everything_GetResultFileNameW - Everything_GetResultPathA - Everything_GetResultPathW - Everything_GetResultFullPathNameA - Everything_GetResultFullPathNameW - - Everything_Reset - \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Everything/nativesrc/Everything.h b/Plugins/Wox.Plugin.Everything/nativesrc/Everything.h deleted file mode 100644 index 1a1770ba57..0000000000 --- a/Plugins/Wox.Plugin.Everything/nativesrc/Everything.h +++ /dev/null @@ -1,95 +0,0 @@ - -#ifndef _EVERYTHING_DLL_ -#define _EVERYTHING_DLL_ - -#ifndef _INC_WINDOWS -#include -#endif - -#define EVERYTHING_OK 0 -#define EVERYTHING_ERROR_MEMORY 1 -#define EVERYTHING_ERROR_IPC 2 -#define EVERYTHING_ERROR_REGISTERCLASSEX 3 -#define EVERYTHING_ERROR_CREATEWINDOW 4 -#define EVERYTHING_ERROR_CREATETHREAD 5 -#define EVERYTHING_ERROR_INVALIDINDEX 6 -#define EVERYTHING_ERROR_INVALIDCALL 7 - -#ifndef EVERYTHINGAPI -#define EVERYTHINGAPI __stdcall -#endif - -#ifndef EVERYTHINGUSERAPI -#define EVERYTHINGUSERAPI __declspec(dllimport) -#endif - -// write search state -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetSearchW(LPCWSTR lpString); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetSearchA(LPCSTR lpString); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetMatchPath(BOOL bEnable); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetMatchCase(BOOL bEnable); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetMatchWholeWord(BOOL bEnable); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetRegex(BOOL bEnable); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetMax(DWORD dwMax); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetOffset(DWORD dwOffset); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetReplyWindow(HWND hWnd); -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetReplyID(DWORD nId); - -// read search state -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_GetMatchPath(VOID); -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_GetMatchCase(VOID); -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_GetMatchWholeWord(VOID); -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_GetRegex(VOID); -EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetMax(VOID); -EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetOffset(VOID); -EVERYTHINGUSERAPI LPCSTR EVERYTHINGAPI Everything_GetSearchA(VOID); -EVERYTHINGUSERAPI LPCWSTR EVERYTHINGAPI Everything_GetSearchW(VOID); -EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetLastError(VOID); -EVERYTHINGUSERAPI HWND EVERYTHINGAPI Everything_GetReplyWindow(VOID); -EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetReplyID(VOID); - -// execute query -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_QueryA(BOOL bWait); -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_QueryW(BOOL bWait); - -// query reply -BOOL EVERYTHINGAPI Everything_IsQueryReply(UINT message,WPARAM wParam,LPARAM lParam,DWORD nId); - -// write result state -EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SortResultsByPath(VOID); - -// read result state -EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetNumFileResults(VOID); -EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetNumFolderResults(VOID); -EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetNumResults(VOID); -EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetTotFileResults(VOID); -EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetTotFolderResults(VOID); -EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetTotResults(VOID); -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_IsVolumeResult(int nIndex); -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_IsFolderResult(int nIndex); -EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_IsFileResult(int nIndex); -EVERYTHINGUSERAPI LPCWSTR EVERYTHINGAPI Everything_GetResultFileNameW(int nIndex); -EVERYTHINGUSERAPI LPCSTR EVERYTHINGAPI Everything_GetResultFileNameA(int nIndex); -EVERYTHINGUSERAPI LPCWSTR EVERYTHINGAPI Everything_GetResultPathW(int nIndex); -EVERYTHINGUSERAPI LPCSTR EVERYTHINGAPI Everything_GetResultPathA(int nIndex); -EVERYTHINGUSERAPI int Everything_GetResultFullPathNameW(int nIndex,LPWSTR wbuf,int wbuf_size_in_wchars); -EVERYTHINGUSERAPI int Everything_GetResultFullPathNameA(int nIndex,LPSTR buf,int bufsize); -EVERYTHINGUSERAPI VOID Everything_Reset(VOID); - -#ifdef UNICODE -#define Everything_SetSearch Everything_SetSearchW -#define Everything_GetSearch Everything_GetSearchW -#define Everything_Query Everything_QueryW -#define Everything_GetResultFileName Everything_GetResultFileNameW -#define Everything_GetResultPath Everything_GetResultPathW -#else -#define Everything_SetSearch Everything_SetSearchA -#define Everything_GetSearch Everything_GetSearchA -#define Everything_Query Everything_QueryA -#define Everything_GetResultFileName Everything_GetResultFileNameA -#define Everything_GetResultPath Everything_GetResultPathA -#endif - - -#endif - diff --git a/Plugins/Wox.Plugin.Everything/nativesrc/Everything_IPC.h b/Plugins/Wox.Plugin.Everything/nativesrc/Everything_IPC.h deleted file mode 100644 index 3c2af015e9..0000000000 --- a/Plugins/Wox.Plugin.Everything/nativesrc/Everything_IPC.h +++ /dev/null @@ -1,287 +0,0 @@ - -// Everything IPC - -#ifndef _EVERYTHING_IPC_H_ -#define _EVERYTHING_IPC_H_ - -// C -#ifdef __cplusplus -extern "C" { -#endif - -// 1 byte packing for our varible sized structs -#pragma pack(push, 1) - -// WM_USER (send to the taskbar notification window) -// SendMessage(FindWindow(EVERYTHING_IPC_WNDCLASS,0),WM_USER,EVERYTHING_IPC_*,lParam) -// version format: major.minor.revision.build -// example: 1.1.4.309 -#define EVERYTHING_IPC_GET_MAJOR_VERSION 0 // int major_version = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_MAJOR_VERSION,0); -#define EVERYTHING_IPC_GET_MINOR_VERSION 1 // int minor_version = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_MINOR_VERSION,0); -#define EVERYTHING_IPC_GET_REVISION 2 // int revision = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_REVISION,0); -#define EVERYTHING_IPC_GET_BUILD_NUMBER 3 // int build = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_BUILD,0); - -// uninstall options -#define EVERYTHING_IPC_DELETE_START_MENU_SHORTCUTS 100 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_START_MENU_SHORTCUTS,0); -#define EVERYTHING_IPC_DELETE_QUICK_LAUNCH_SHORTCUT 101 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_QUICK_LAUNCH_SHORTCUT,0); -#define EVERYTHING_IPC_DELETE_DESKTOP_SHORTCUT 102 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_DESKTOP_SHORTCUT,0); -#define EVERYTHING_IPC_DELETE_FOLDER_CONTEXT_MENU 103 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_FOLDER_CONTEXT_MENU,0); -#define EVERYTHING_IPC_DELETE_RUN_ON_SYSTEM_STARTUP 104 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_RUN_ON_SYSTEM_STARTUP,0); - -// install options -#define EVERYTHING_IPC_CREATE_START_MENU_SHORTCUTS 200 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_START_MENU_SHORTCUTS,0); -#define EVERYTHING_IPC_CREATE_QUICK_LAUNCH_SHORTCUT 201 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_QUICK_LAUNCH_SHORTCUT,0); -#define EVERYTHING_IPC_CREATE_DESKTOP_SHORTCUT 202 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_DESKTOP_SHORTCUT,0); -#define EVERYTHING_IPC_CREATE_FOLDER_CONTEXT_MENU 203 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_FOLDER_CONTEXT_MENU,0); -#define EVERYTHING_IPC_CREATE_RUN_ON_SYSTEM_STARTUP 204 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_RUN_ON_SYSTEM_STARTUP,0); - -// get option status; 0 = no, 1 = yes, 2 = indeterminate (partially installed) -#define EVERYTHING_IPC_IS_START_MENU_SHORTCUTS 300 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_START_MENU_SHORTCUTS,0); -#define EVERYTHING_IPC_IS_QUICK_LAUNCH_SHORTCUT 301 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_QUICK_LAUNCH_SHORTCUT,0); -#define EVERYTHING_IPC_IS_DESKTOP_SHORTCUT 302 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_DESKTOP_SHORTCUT,0); -#define EVERYTHING_IPC_IS_FOLDER_CONTEXT_MENU 303 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_FOLDER_CONTEXT_MENU,0); -#define EVERYTHING_IPC_IS_RUN_ON_SYSTEM_STARTUP 304 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_RUN_ON_SYSTEM_STARTUP,0); - -// find the everything window -#define EVERYTHING_IPC_WNDCLASS TEXT("EVERYTHING_TASKBAR_NOTIFICATION") - -// find a everything search window -#define EVERYTHING_IPC_SEARCH_WNDCLASS TEXT("EVERYTHING") - -// this global window message is sent to all top level windows when everything starts. -#define EVERYTHING_IPC_CREATED TEXT("EVERYTHING_IPC_CREATED") - -// search flags for querys -#define EVERYTHING_IPC_MATCHCASE 0x00000001 // match case -#define EVERYTHING_IPC_MATCHWHOLEWORD 0x00000002 // match whole word -#define EVERYTHING_IPC_MATCHPATH 0x00000004 // include paths in search -#define EVERYTHING_IPC_REGEX 0x00000008 // enable regex - -// item flags -#define EVERYTHING_IPC_FOLDER 0x00000001 // The item is a folder. (its a file if not set) -#define EVERYTHING_IPC_DRIVE 0x00000002 // The folder is a drive. Path will be an empty string. - // (will also have the folder bit set) - -// the WM_COPYDATA message for a query. -#define EVERYTHING_IPC_COPYDATAQUERYA 1 -#define EVERYTHING_IPC_COPYDATAQUERYW 2 - -// all results -#define EVERYTHING_IPC_ALLRESULTS 0xFFFFFFFF // all results - -// macro to get the filename of an item -#define EVERYTHING_IPC_ITEMFILENAMEA(list,item) (CHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMA *)(item))->filename_offset) -#define EVERYTHING_IPC_ITEMFILENAMEW(list,item) (WCHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->filename_offset) - -// macro to get the path of an item -#define EVERYTHING_IPC_ITEMPATHA(list,item) (CHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->path_offset) -#define EVERYTHING_IPC_ITEMPATHW(list,item) (WCHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->path_offset) - -// -// Varible sized query struct sent to everything. -// -// sent in the form of a WM_COPYDAYA message with EVERYTHING_IPC_COPYDATAQUERY 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 CHAR plus the length of the search string in bytes plus -// one CHAR for the null terminator. -// -// NOTE: to determine the size of this structure use -// ASCII: sizeof(EVERYTHING_IPC_QUERYA) - sizeof(CHAR) + strlen(search_string)*sizeof(CHAR) + sizeof(CHAR) -// UNICODE: sizeof(EVERYTHING_IPC_QUERYW) - sizeof(WCHAR) + unicode_length_in_wchars(search_string)*sizeof(WCHAR) + sizeof(WCHAR) -// -// 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_COPYDATAQUERYW, the results sent from Everything will be Unicode. -// - -typedef struct EVERYTHING_IPC_QUERYW -{ - // the window that will receive the new results. - INT32 reply_hwnd; - - // the value to set the dwData member in the COPYDATASTRUCT struct - // sent by Everything when the query is complete. - INT32 reply_copydata_message; - - // search flags (see EVERYTHING_MATCHCASE | EVERYTHING_MATCHWHOLEWORD | EVERYTHING_MATCHPATH) - INT32 search_flags; - - // only return results after 'offset' results (0 to return the first result) - // useful for scrollable lists - INT32 offset; - - // the number of results to return - // zero to return no results - // EVERYTHING_IPC_ALLRESULTS to return ALL results - INT32 max_results; - - // null terminated string. arbitrary sized search_string buffer. - INT32 search_string[1]; - -}EVERYTHING_IPC_QUERYW; - -// ASCII version -typedef struct EVERYTHING_IPC_QUERYA -{ - // the window that will receive the new results. - INT32 reply_hwnd; - - // the value to set the dwData member in the COPYDATASTRUCT struct - // sent by Everything when the query is complete. - INT32 reply_copydata_message; - - // search flags (see EVERYTHING_MATCHCASE | EVERYTHING_MATCHWHOLEWORD | EVERYTHING_MATCHPATH) - INT32 search_flags; - - // only return results after 'offset' results (0 to return the first result) - // useful for scrollable lists - INT32 offset; - - // the number of results to return - // zero to return no results - // EVERYTHING_IPC_ALLRESULTS to return ALL results - INT32 max_results; - - // null terminated string. arbitrary sized search_string buffer. - INT32 search_string[1]; - -}EVERYTHING_IPC_QUERYA; - -// -// Varible sized result list struct received from Everything. -// -// Sent in the form of a WM_COPYDATA message to the hwnd specifed in the -// EVERYTHING_IPC_QUERY struct. -// the dwData member of the COPYDATASTRUCT struct will match the sent -// reply_copydata_message member in the EVERYTHING_IPC_QUERY struct. -// -// make a copy of the data before returning. -// -// return TRUE if you processed the WM_COPYDATA message. -// - -typedef struct EVERYTHING_IPC_ITEMW -{ - // item flags - DWORD flags; - - // The offset of the filename from the beginning of the list structure. - // (wchar_t *)((char *)everything_list + everythinglist->name_offset) - DWORD filename_offset; - - // The offset of the filename from the beginning of the list structure. - // (wchar_t *)((char *)everything_list + everythinglist->path_offset) - DWORD path_offset; - -}EVERYTHING_IPC_ITEMW; - -typedef struct EVERYTHING_IPC_ITEMA -{ - // item flags - DWORD flags; - - // The offset of the filename from the beginning of the list structure. - // (char *)((char *)everything_list + everythinglist->name_offset) - DWORD filename_offset; - - // The offset of the filename from the beginning of the list structure. - // (char *)((char *)everything_list + everythinglist->path_offset) - DWORD path_offset; - -}EVERYTHING_IPC_ITEMA; - -typedef struct EVERYTHING_IPC_LISTW -{ - // the total number of folders found. - DWORD totfolders; - - // the total number of files found. - DWORD totfiles; - - // totfolders + totfiles - DWORD totitems; - - // the number of folders available. - DWORD numfolders; - - // the number of files available. - DWORD numfiles; - - // the number of items available. - DWORD numitems; - - // index offset of the first result in the item list. - DWORD offset; - - // arbitrary sized item list. - // use numitems to determine the actual number of items available. - EVERYTHING_IPC_ITEMW items[1]; - -}EVERYTHING_IPC_LISTW; - -typedef struct EVERYTHING_IPC_LISTA -{ - // the total number of folders found. - DWORD totfolders; - - // the total number of files found. - DWORD totfiles; - - // totfolders + totfiles - DWORD totitems; - - // the number of folders available. - DWORD numfolders; - - // the number of files available. - DWORD numfiles; - - // the number of items available. - DWORD numitems; - - // index offset of the first result in the item list. - DWORD offset; - - // arbitrary sized item list. - // use numitems to determine the actual number of items available. - EVERYTHING_IPC_ITEMA items[1]; - -}EVERYTHING_IPC_LISTA; - -#ifdef UNICODE -#define EVERYTHING_IPC_COPYDATAQUERY EVERYTHING_IPC_COPYDATAQUERYW -#define EVERYTHING_IPC_ITEMFILENAME EVERYTHING_IPC_ITEMFILENAMEW -#define EVERYTHING_IPC_ITEMPATH EVERYTHING_IPC_ITEMPATHW -#define EVERYTHING_IPC_QUERY EVERYTHING_IPC_QUERYW -#define EVERYTHING_IPC_ITEM EVERYTHING_IPC_ITEMW -#define EVERYTHING_IPC_LIST EVERYTHING_IPC_LISTW -#else -#define EVERYTHING_IPC_COPYDATAQUERY EVERYTHING_IPC_COPYDATAQUERYA -#define EVERYTHING_IPC_ITEMFILENAME EVERYTHING_IPC_ITEMFILENAMEA -#define EVERYTHING_IPC_ITEMPATH EVERYTHING_IPC_ITEMPATHA -#define EVERYTHING_IPC_QUERY EVERYTHING_IPC_QUERYA -#define EVERYTHING_IPC_ITEM EVERYTHING_IPC_ITEMA -#define EVERYTHING_IPC_LIST EVERYTHING_IPC_LISTA -#endif - - -// restore packing -#pragma pack(pop) - -// end extern C -#ifdef __cplusplus -} -#endif - -#endif // _EVERYTHING_H_ - diff --git a/Plugins/Wox.Plugin.Everything/nativesrc/dll.sln b/Plugins/Wox.Plugin.Everything/nativesrc/dll.sln deleted file mode 100644 index 5f394cb794..0000000000 --- a/Plugins/Wox.Plugin.Everything/nativesrc/dll.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll", "dll.vcxproj", "{7C90030E-6EDB-445E-A61B-5540B7355C59}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7C90030E-6EDB-445E-A61B-5540B7355C59}.Debug|Win32.ActiveCfg = Debug|x64 - {7C90030E-6EDB-445E-A61B-5540B7355C59}.Debug|Win32.Build.0 = Debug|x64 - {7C90030E-6EDB-445E-A61B-5540B7355C59}.Debug|x64.ActiveCfg = Debug|x64 - {7C90030E-6EDB-445E-A61B-5540B7355C59}.Debug|x64.Build.0 = Debug|x64 - {7C90030E-6EDB-445E-A61B-5540B7355C59}.Release|Win32.ActiveCfg = Release|Win32 - {7C90030E-6EDB-445E-A61B-5540B7355C59}.Release|Win32.Build.0 = Release|Win32 - {7C90030E-6EDB-445E-A61B-5540B7355C59}.Release|x64.ActiveCfg = Release|x64 - {7C90030E-6EDB-445E-A61B-5540B7355C59}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Plugins/Wox.Plugin.Everything/nativesrc/dll.vcxproj b/Plugins/Wox.Plugin.Everything/nativesrc/dll.vcxproj deleted file mode 100644 index ebc74b25e3..0000000000 --- a/Plugins/Wox.Plugin.Everything/nativesrc/dll.vcxproj +++ /dev/null @@ -1,291 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {7C90030E-6EDB-445E-A61B-5540B7355C59} - dll - Win32Proj - - - - DynamicLibrary - false - MultiByte - v90 - - - DynamicLibrary - MultiByte - v90 - - - DynamicLibrary - false - MultiByte - v90 - - - DynamicLibrary - MultiByte - v90 - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - %(AdditionalIncludeDirectories) - BZ_NO_STDIO;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - - - $(OutDir)Everything.dll - - - true - true - Console - 0 - true - true - false - - - MachineX86 - - - %(AdditionalManifestFiles) - - - - - X64 - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - CompileAsC - - - ComCtl32.lib;UxTheme.lib;Ws2_32.lib;shlwapi.lib;ole32.lib;htmlhelp.lib;%(AdditionalDependencies) - $(OutDir)Everything.dll - true - $(OutDir)dll.pdb - Console - false - - - MachineX64 - - - %(AdditionalManifestFiles) - - - - - - - - - MaxSpeed - AnySuitable - true - Speed - false - false - %(AdditionalIncludeDirectories) - BZ_NO_STDIO;%(PreprocessorDefinitions) - true - Sync - Default - MultiThreaded - true - Fast - - - Level3 - - - Cdecl - CompileAsC - - - - - - - true - - - NotSet - $(OutDir)Everything.dll - %(AdditionalManifestDependencies) - false - everything.def - false - true - Windows - 0 - true - true - - - false - - - MachineX86 - - - %(AdditionalManifestFiles) - false - false - - - - - - - - - X64 - - - MaxSpeed - AnySuitable - true - Speed - false - false - %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - Default - MultiThreaded - true - Fast - - - Level3 - - - CompileAsC - - - true - - - comctl32.lib;UxTheme.lib;Ws2_32.lib;HTMLHelp.lib;msimg32.lib;%(AdditionalDependencies) - NotSet - $(OutDir)Everything.dll - %(AdditionalManifestDependencies) - false - true - Windows - true - true - - - false - - - MachineX64 - - - %(AdditionalManifestFiles) - false - false - - - - - - - - - - - - - - - - diff --git a/Plugins/Wox.Plugin.Everything/nativesrc/dll.vcxproj.filters b/Plugins/Wox.Plugin.Everything/nativesrc/dll.vcxproj.filters deleted file mode 100644 index 93496a8d7d..0000000000 --- a/Plugins/Wox.Plugin.Everything/nativesrc/dll.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {072e536f-0b4e-4b52-bbf4-45486ca2a90b} - cpp;c;cxx;def;odl;idl;hpj;bat;asm - - - - - src - - - - - src - - - - - src - - - src - - - \ No newline at end of file diff --git a/PreSolutionBuild/PreSolutionBuild.vcxproj b/PreSolutionBuild/PreSolutionBuild.vcxproj index aae8e8ffd7..f32f539700 100644 --- a/PreSolutionBuild/PreSolutionBuild.vcxproj +++ b/PreSolutionBuild/PreSolutionBuild.vcxproj @@ -64,25 +64,17 @@ WIN32;_DEBUG;$(NMakePreprocessorDefinitions) - taskkill /f /fi "IMAGENAME eq Wox.exe" -$(SolutionDir)Output\$(Configuration)\Plugins\Wox.Plugin.Everything\PortableEverything\$(PlatformTarget)\Everything.exe -stop-service - + taskkill /f /fi "IMAGENAME eq Wox.exe" WIN32;NDEBUG;$(NMakePreprocessorDefinitions) - taskkill /f /fi "IMAGENAME eq Wox.exe" -$(SolutionDir)Output\$(Configuration)\Plugins\Wox.Plugin.Everything\PortableEverything\$(PlatformTarget)\Everything.exe -stop-service - + taskkill /f /fi "IMAGENAME eq Wox.exe" - taskkill /f /fi "IMAGENAME eq Wox.exe" -$(SolutionDir)Output\$(Configuration)\Plugins\Wox.Plugin.Everything\PortableEverything\$(PlatformTarget)\Everything.exe -stop-service - + taskkill /f /fi "IMAGENAME eq Wox.exe" - taskkill /f /fi "IMAGENAME eq Wox.exe" -$(SolutionDir)Output\$(Configuration)\Plugins\Wox.Plugin.Everything\PortableEverything\$(PlatformTarget)\Everything.exe -stop-service - + taskkill /f /fi "IMAGENAME eq Wox.exe" diff --git a/Wox.Core/Plugin/PluginInstaller.cs b/Wox.Core/Plugin/PluginInstaller.cs index dce4545555..adf5f85915 100644 --- a/Wox.Core/Plugin/PluginInstaller.cs +++ b/Wox.Core/Plugin/PluginInstaller.cs @@ -34,7 +34,7 @@ namespace Wox.Core.Plugin return; } - string pluginFolerPath = PluginManager.UserDirectory; + string pluginFolerPath = Infrastructure.Wox.UserDirectory; string newPluginName = plugin.Name .Replace("/", "_") diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index aeed2d95c8..b0cd7cfd97 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -33,16 +33,13 @@ namespace Wox.Core.Plugin private static IEnumerable InstantQueryPlugins { get; set; } public static IPublicAPI API { private set; get; } - public const string DirectoryName = "Plugins"; - public static readonly string PreinstalledDirectory = Path.Combine(Infrastructure.Wox.ProgramPath, DirectoryName); - public static readonly string UserDirectory = Path.Combine(Infrastructure.Wox.DataPath, DirectoryName); - private static readonly string[] Directories = { PreinstalledDirectory, UserDirectory }; + private static readonly string[] Directories = {Infrastructure.Wox.PreinstalledDirectory, Infrastructure.Wox.UserDirectory }; private static void ValidateUserDirectory() { - if (!Directory.Exists(UserDirectory)) + if (!Directory.Exists(Infrastructure.Wox.UserDirectory)) { - Directory.CreateDirectory(UserDirectory); + Directory.CreateDirectory(Infrastructure.Wox.UserDirectory); } } diff --git a/Wox.Core/Resource/ResourceMerger.cs b/Wox.Core/Resource/ResourceMerger.cs index 1f17dd7b53..c5a0791f60 100644 --- a/Wox.Core/Resource/ResourceMerger.cs +++ b/Wox.Core/Resource/ResourceMerger.cs @@ -34,7 +34,7 @@ namespace Wox.Core.Resource internal static void UpdatePluginLanguages() { - RemoveResource(PluginManager.DirectoryName); + RemoveResource(Infrastructure.Wox.Plugins); foreach (var plugin in PluginManager.GetPluginsForInterface()) { var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location; diff --git a/Wox.Infrastructure/Image/ImageLoader.cs b/Wox.Infrastructure/Image/ImageLoader.cs index 7a0b1e40c0..f27a4b6688 100644 --- a/Wox.Infrastructure/Image/ImageLoader.cs +++ b/Wox.Infrastructure/Image/ImageLoader.cs @@ -21,7 +21,7 @@ namespace Wox.Infrastructure.Image private static readonly string DefaultIcon = Path.Combine(Wox.ProgramPath, "Images", "app.png"); private static readonly string ErrorIcon = Path.Combine(Wox.ProgramPath, "Images", "app_error.png"); - private static readonly string[] ImageExtions = + private static readonly string[] ImageExtions = { ".png", ".jpg", @@ -100,8 +100,12 @@ namespace Wox.Infrastructure.Image } public static void PreloadImages() { - ImageSources[DefaultIcon] = new BitmapImage(new Uri(DefaultIcon)); - ImageSources[ErrorIcon] = new BitmapImage(new Uri(ErrorIcon)); + foreach (var icon in new[] { DefaultIcon, ErrorIcon }) + { + ImageSource img = new BitmapImage(new Uri(DefaultIcon)); + img.Freeze(); + ImageSources[icon] = img; + } Task.Factory.StartNew(() => { Stopwatch.Debug("Preload images from cache", () => diff --git a/Wox.Infrastructure/Storage/PluginSettingsStorage.cs b/Wox.Infrastructure/Storage/PluginSettingsStorage.cs index 18ad200e5b..707d263ca8 100644 --- a/Wox.Infrastructure/Storage/PluginSettingsStorage.cs +++ b/Wox.Infrastructure/Storage/PluginSettingsStorage.cs @@ -6,7 +6,7 @@ namespace Wox.Infrastructure.Storage { public PluginJsonStorage() { - DirectoryName = "Plugins"; + DirectoryName = Wox.Plugins; // C# releated, add python releated below var assemblyName = DataType.Assembly.GetName().Name; diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs index 4ae784a600..cbda123f0a 100644 --- a/Wox.Infrastructure/Wox.cs +++ b/Wox.Infrastructure/Wox.cs @@ -7,7 +7,10 @@ namespace Wox.Infrastructure public static class Wox { public const string Name = "Wox"; + public const string Plugins = "Plugins"; public static readonly string ProgramPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Name); + public static readonly string UserDirectory = Path.Combine(DataPath, Plugins); + public static readonly string PreinstalledDirectory = Path.Combine(ProgramPath, Plugins); } }