Skip to content

Commit

Permalink
Add support for Everything both 32-bit and 64-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
orzFly committed Jan 29, 2014
1 parent 529b8c2 commit f9ff9af
Show file tree
Hide file tree
Showing 14 changed files with 2,641 additions and 7 deletions.
Binary file removed Plugins/Wox.Plugin.Everything/Everything.dll
Binary file not shown.
32 changes: 29 additions & 3 deletions Plugins/Wox.Plugin.Everything/EverythingAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Wox.Plugin.Everything
{
public sealed class EverythingAPI
{

#region Const
const string EVERYTHING_DLL_NAME = "Everything.dll";
#endregion
Expand Down Expand Up @@ -46,7 +47,7 @@ public sealed class EverythingAPI
private static extern StateCode Everything_GetLastError();

[DllImport(EVERYTHING_DLL_NAME)]
private static extern bool Everything_Query();
private static extern bool Everything_Query(bool bWait);

[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_SortResultsByPath();
Expand Down Expand Up @@ -175,6 +176,27 @@ public IEnumerable<string> Search(string keyWord)
return Search(keyWord, 0, int.MaxValue);
}

private void no()
{
switch (Everything_GetLastError())
{
case StateCode.CreateThreadError:
throw new CreateThreadException();
case StateCode.CreateWindowError:
throw new CreateWindowException();
case StateCode.InvalidCallError:
throw new InvalidCallException();
case StateCode.InvalidIndexError:
throw new InvalidIndexException();
case StateCode.IPCError:
throw new IPCErrorException();
case StateCode.MemoryError:
throw new MemoryErrorException();
case StateCode.RegisterClassExError:
throw new RegisterClassExException();
}
}

/// <summary>
/// Searches the specified key word.
/// </summary>
Expand All @@ -196,7 +218,9 @@ public IEnumerable<string> Search(string keyWord, int offset, int maxCount)
Everything_SetSearch(keyWord);
Everything_SetOffset(offset);
Everything_SetMax(maxCount);
if (!Everything_Query())
Everything_SetRegex(true);

if (!Everything_Query(true))
{
switch (Everything_GetLastError())
{
Expand All @@ -218,7 +242,9 @@ public IEnumerable<string> Search(string keyWord, int offset, int maxCount)
yield break;
}

const int bufferSize = 256;
Everything_SortResultsByPath();

const int bufferSize = 4096;
StringBuilder buffer = new StringBuilder(bufferSize);
for (int idx = 0; idx < Everything_GetNumResults(); ++idx)
{
Expand Down
35 changes: 32 additions & 3 deletions Plugins/Wox.Plugin.Everything/Main.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,62 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Wox.Plugin.Everything
{
public class Main : IPlugin
{
Wox.Plugin.PluginInitContext context;
EverythingAPI api = new EverythingAPI();

public List<Result> Query(Query query)
{
var results = new List<Result>();
if (query.ActionParameters.Count > 0 && query.ActionParameters[0].Length > 0)
{
IEnumerable<string> enumerable = api.Search(query.ActionParameters[0]);
IEnumerable<string> enumerable = api.Search(query.ActionParameters[0], 0, 100);
foreach (string s in enumerable)
{
Result r = new Result();
r.Title = s;
r.Title = Path.GetFileName(s);
r.SubTitle = s;
r.Action = () =>
{
context.HideApp();
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.UseShellExecute = true;
info.FileName = s;
try
{
System.Diagnostics.Process.Start(info);
}
catch (Exception ex)
{
context.ShowMsg("Could not start " + r.Title, ex.Message, null);
}
};
results.Add(r);
}
}

api.Reset();

return results;
}

[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern int LoadLibrary(string name);

public void Init()
public void Init(Wox.Plugin.PluginInitContext context)
{
this.context = context;

LoadLibrary(Path.Combine(
Path.Combine(context.PluginMetadata.PluginDirecotry, (IntPtr.Size == 4) ? "x86" : "x64"),
"Everything.dll"
));
//init everything
}
}
Expand Down
6 changes: 5 additions & 1 deletion Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -76,7 +79,8 @@
<PropertyGroup>
<PostBuildEvent>xcopy /Y $(TargetDir)$(TargetFileName) $(SolutionDir)Wox\bin\Debug\Plugins\Everything\
xcopy /Y $(TargetDir)plugin.ini $(SolutionDir)Wox\bin\Debug\Plugins\Everything\
xcopy /Y $(ProjectDir)Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\Everything\</PostBuildEvent>
xcopy /Y $(ProjectDir)x86\Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\Everything\x86\
xcopy /Y $(ProjectDir)x64\Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\Everything\x64\</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Binary file not shown.
Binary file removed Plugins/Wox.Plugin.Everything/Wox.Plugin.dll
Binary file not shown.

0 comments on commit f9ff9af

Please sign in to comment.