GetResultFileName

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
aluparu
Posts: 8
Joined: Wed Feb 01, 2017 5:43 pm

GetResultFileName

Post by aluparu »

Hi all
In c# how do I get the filename only using Everything_GetResultFileName (version 1.3) ? I do not see any example with.

for (i = 0; i < EverythingClass.Everything_GetNumResults(); i++)
{
EverythingClass.Everything_GetResultFullPathNameW(i, buf, bufsize);

//if (EverythingClass.Everything_IsFileResult(i))
//{
f = buf.ToString(); // --- > getting the full path

//}
}

Thank you
void
Developer
Posts: 16672
Joined: Fri Oct 16, 2009 11:31 pm

Re: GetResultFileName

Post by void »

Please have a look at the C# example, with the changes below:
http://www.voidtools.com/support/everything/sdk/csharp/

Code: Select all

[DllImport("Everything32.dll")]
public static extern string Everything_GetResultFileNameW(int nIndex);

private void button1_Click(object sender, EventArgs e)
{
	int i;

	// set the search
	Everything_SetSearchW("ABC 123");

	// execute the query
	Everything_QueryW(true);
	
	// clear the old list of results			
	listBox1.Items.Clear();
			
	// loop through the results, adding each result to the listbox.
	for (i = 0; i < Everything_GetNumResults(); i++)
	{
		// add it to the list box				
		listBox1.Items.Insert(i, Everything_GetResultFileNameW(i));
	}
}
aluparu
Posts: 8
Joined: Wed Feb 01, 2017 5:43 pm

Re: GetResultFileName

Post by aluparu »

Thank you
aluparu
Posts: 8
Joined: Wed Feb 01, 2017 5:43 pm

Re: GetResultFileName

Post by aluparu »

I have added this test code with a listbox but the code with this message
has exited with code -2147483645 (0x80000003)

[DllImport("Everything64.dll")]
public static extern string Everything_GetResultFileNameW(int nIndex);


for (i = 0; i < EverythingClass.Everything_GetNumResults(); i++)
{
// add it to the list box
listBox1.Items.Insert(i, EverythingClass.Everything_GetResultFileNameW(i));
}


has exited with code -2147483645 (0x80000003)
void
Developer
Posts: 16672
Joined: Fri Oct 16, 2009 11:31 pm

Re: GetResultFileName

Post by void »

Error 80000003 = Failed to initialize.
[DllImport("Everything64.dll")]
Are you compiling as x64 or should this be:
[DllImport("Everything32.dll")]
aluparu
Posts: 8
Joined: Wed Feb 01, 2017 5:43 pm

Re: GetResultFileName

Post by aluparu »

yes its an X64 environement
void
Developer
Posts: 16672
Joined: Fri Oct 16, 2009 11:31 pm

Re: GetResultFileName

Post by void »

Please try changing:

Code: Select all

[DllImport("Everything64.dll")]
public static extern string Everything_GetResultFileNameW(int nIndex);
to:

Code: Select all

[DllImport("Everything64.dll", CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultFileNameW(int nIndex);
See working example:
http://www.voidtools.com/Everything.SDK ... rp.x64.zip
aluparu
Posts: 8
Joined: Wed Feb 01, 2017 5:43 pm

Re: GetResultFileName

Post by aluparu »

Does not work. I have already tried. EverythingClass.Everything_GetResultFullPathNameW this is working for full path

The code quit when I try the Everything_GetResultFileName as the previous example.

The basic ideea was to filter paths from different folders. I want to search for files on specific folder.

Code: Select all

                   for (i = 0; i <= EverythingClass.Everything_GetNumResults(); i++)
                    {

                        if (EverythingClass.Everything_IsFileResult(i))
                        {
                            EverythingClass.Everything_GetResultFullPathNameW(i, buf, bufsize);
                            f = buf.ToString();
                            if (Path.GetFileName(f.ToLower()).Contains(SearchTextBox.Text.ToLower()))
                            {
                                addToDocFilesArr(f);
                            }
                        }
                    }
The attached link is not working by the way. Error 404: Page not found
Thank you for your time.
void
Developer
Posts: 16672
Joined: Fri Oct 16, 2009 11:31 pm

Re: GetResultFileName

Post by void »

Everything_GetResultFileName is slightly different to the Everything_GetResultFullPathNameW call.

Everything_GetResultFileName returns a string, while Everything_GetResultFullPathNameW builds a string.
The attached link is not working by the way. Error 404: Page not found
Sorry I had a typo in the filename, it should work now
http://www.voidtools.com/Everything.SDK ... rp.x64.zip
aluparu
Posts: 8
Joined: Wed Feb 01, 2017 5:43 pm

Re: GetResultFileName

Post by aluparu »

Everything program is running all folders are indexed
Question Everything installed is version X32 could be this an issue? except this call GetResultFileName everything else is running from my code
(The code have to run in x64 because there are other stuff that are running only x64.)

Visual response on code ...
The thread 0x626cc has exited with code 259 (0x103).
'WindowsApplication1.vshost.exe' (CLR v4.0.30319: WindowsApplication1.vshost.exe): Loaded 'C:\Users\####\Documents\SharpDevelop Projects\99-Testing\Everything.SDK.Example.CSharp.x64\bin\x64\Debug\WindowsApplication1.exe'. Symbols loaded.
The program '[403084] WindowsApplication1.vshost.exe' has exited with code -2147483645 (0x80000003).
void
Developer
Posts: 16672
Joined: Fri Oct 16, 2009 11:31 pm

Re: GetResultFileName

Post by void »

Question Everything installed is version X32 could be this an issue?
It doesn't matter which version of Everything you use. It can be the x86 or x64 version.

Please try the following changes:

[DllImport("Everything64.dll", CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultFileNameW(int nIndex);

to:

[DllImport("Everything64.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr Everything_GetResultFileNameW(int nIndex);

and

listBox1.Items.Insert(i, Everything_GetResultFileNameW(i));

to:

listBox1.Items.Insert(i, Marshal.PtrToStringUni(Everything_GetResultFileNameW(i)));

http://stackoverflow.com/questions/1294 ... g-p-invoke
aluparu
Posts: 8
Joined: Wed Feb 01, 2017 5:43 pm

Re: GetResultFileName

Post by aluparu »

Thank you very much. I am not expert into c#, but the last code made it.
Post Reply