Page 1 of 1

Declaration of _Everything_SendAPIBoolCommand?

Posted: Wed Jun 14, 2023 4:38 pm
by vefatica
A definition for _Everything_SendAPIBoolCommand is in everything.c. But it's not declared anywhere. How do I use it in another module?

Thanks.

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Wed Jun 14, 2023 11:11 pm
by void
The SDK source code is provided in the SDK:

Code: Select all

static BOOL _Everything_SendAPIBoolCommand(int command,LPARAM lParam)
{
	HWND everything_hwnd;
	
	everything_hwnd = FindWindow(EVERYTHING_IPC_WNDCLASS,0);
	if (everything_hwnd)
	{
		_Everything_LastError = 0;
			
		if (SendMessage(everything_hwnd,EVERYTHING_WM_IPC,command,lParam))
		{
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	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;
		
		return FALSE;
	}
}
In short, find the Everything IPC window and send a window message.

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 12:57 am
by vefatica
Having included everything.c in my project, I can't use it in another module.

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 1:07 am
by void
Are you looking to export this function so it can be called externally from a dll?

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 1:52 am
by vefatica
No.

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 1:55 am
by void
Remove static from the function definition and declare the function as:

Code: Select all

BOOL _Everything_SendAPIBoolCommand(int command,LPARAM lParam);

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 2:13 am
by vefatica
Removed "static" in everything.c (declaration and definition). I get "linker: unresolved external" when I try to call it from another source module.

It works if I put the definition in my own source module.

And doing it in my own FindWindow/SendMessage also works.

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 2:31 am
by void
You'll need to include the following in your module:

Code: Select all

BOOL _Everything_SendAPIBoolCommand(int command,LPARAM lParam);
(can also be declared in one of your header files)

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 2:47 am
by vefatica
I tried all that, several times. No matter where I declare it (without "static") if the definition (without "static") is in everything.c and I call it from another source module I can't link with it. That's unlike a number of other functions defined in everything.c (e.g., Everything_SetRegex (and friends)) which I can call from another source module.

It is not critical. As I said if I define _Everything_SendAPIBoolCommand in my own source module (as it's defined in everything.c) it works. And my own function (using FindWindow and SendMessage) also works. I was hoping to learn something here.

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 3:17 am
by void
This issue can occur if the definition still contains the static keyword.

Please make sure both the declaration and definition do not have the static keyword in everything.c

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 3:49 am
by vefatica
As I said, I tried that.

Here's another (related?) question. I invented my own ...

everything.h (modelled after Everything_Exit, which I can successfully use)
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_ShowOptionsDialog(void); // vef

everything.c (modelled after Everything_Exit, which I can successfully use)
BOOL EVERYTHINGAPI Everything_ShowOptionsDialog(void) // vef
{
return _Everything_SendAPIBoolCommand(EVERYTHING_IPC_ID_TRAY_OPTIONS, 0);
}

everything.c and es.cpp are included in my project

es.cpp includes everything.h and calls Everything_ShowOptionsDialog().

The project builds OK.

Everything_ShowOptionsDialog() doesn't work. It returns 0;

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 4:05 am
by void
Please try wrapping the _Everything_SendAPIBoolCommand declaration in an extern "C":

Code: Select all

#ifdef __cplusplus
extern "C" {
#endif

BOOL _Everything_SendAPIBoolCommand(int command,LPARAM lParam);

#ifdef __cplusplus
}
#endif


EVERYTHING_IPC_ID_TRAY_OPTIONS is not an IPC command.
It will not work with _Everything_SendAPIBoolCommand

Please try:

Code: Select all

SendMessage(FindWindow(EVERYTHING_IPC_WNDCLASS,0),WM_COMMAND,MAKEWPARAM(EVERYTHING_IPC_ID_TRAY_OPTIONS,0),0);

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 4:18 am
by vefatica
My mistake! Is there an IPC command to open the options dialog (also open the search window and open a new search window).

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 4:33 am
by void
There's no EVERYTHING_WM_IPC command to open the options window or create a new window.

You will need to send a WM_COMMAND to the same tray window instead.

Code: Select all

#define EVERYTHING_IPC_ID_TRAY_NEW_SEARCH_WINDOW		40001
#define EVERYTHING_IPC_ID_TRAY_CONNECT_TO_ETP_SERVER		40004
#define EVERYTHING_IPC_ID_TRAY_OPTIONS				40005
#define EVERYTHING_IPC_ID_TRAY_EXIT				40006
#define EVERYTHING_IPC_ID_TRAY_SHOW_SEARCH_WINDOW		40007
#define EVERYTHING_IPC_ID_TRAY_TOGGLE_SEARCH_WINDOW		40008

Re: Declaration of _Everything_SendAPIBoolCommand?

Posted: Thu Jun 15, 2023 4:37 am
by vefatica
That's what I have been doing. It works fine but I was curious about another way.

Thanks for all the help. Sorry if I've been a pain.