-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorker.cs
More file actions
53 lines (44 loc) · 1.13 KB
/
Worker.cs
File metadata and controls
53 lines (44 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// Copyright 2020 - Jeffrey "botman" Broome
//
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace OpenFileByName
{
class Worker
{
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool PostMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private static HandleRef FormHandle;
private string Input;
public Worker(IntPtr InFormHandle, string InInput)
{
FormHandle = new HandleRef(this, InFormHandle);
Input = InInput;
}
public void Run()
{
try
{
foreach(string FilePath in OpenFileCustomCommand.SolutionFilenames)
{
string FileName = Path.GetFileName(FilePath);
if ((Input == "") || FileName.IndexOf(Input, StringComparison.CurrentCultureIgnoreCase) >= 0)
{
ListViewItem item = new ListViewItem(FileName);
item.SubItems.Add(FilePath);
OpenFileDialog.items.Add(item);
}
}
}
catch
{
}
PostMessage(FormHandle, OpenFileDialog.WM_WORKER_DONE, IntPtr.Zero, IntPtr.Zero);
}
}
}