Declaration of _Everything_SendAPIBoolCommand?

Plug-in and third party software discussion.
Post Reply
vefatica
Posts: 36
Joined: Sun Jun 11, 2023 6:27 pm

Declaration of _Everything_SendAPIBoolCommand?

Post 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.
void
Developer
Posts: 16680
Joined: Fri Oct 16, 2009 11:31 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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.
vefatica
Posts: 36
Joined: Sun Jun 11, 2023 6:27 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post by vefatica »

Having included everything.c in my project, I can't use it in another module.
void
Developer
Posts: 16680
Joined: Fri Oct 16, 2009 11:31 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post by void »

Are you looking to export this function so it can be called externally from a dll?
vefatica
Posts: 36
Joined: Sun Jun 11, 2023 6:27 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post by vefatica »

No.
void
Developer
Posts: 16680
Joined: Fri Oct 16, 2009 11:31 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post by void »

Remove static from the function definition and declare the function as:

Code: Select all

BOOL _Everything_SendAPIBoolCommand(int command,LPARAM lParam);
vefatica
Posts: 36
Joined: Sun Jun 11, 2023 6:27 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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.
void
Developer
Posts: 16680
Joined: Fri Oct 16, 2009 11:31 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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)
vefatica
Posts: 36
Joined: Sun Jun 11, 2023 6:27 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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.
void
Developer
Posts: 16680
Joined: Fri Oct 16, 2009 11:31 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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
vefatica
Posts: 36
Joined: Sun Jun 11, 2023 6:27 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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;
void
Developer
Posts: 16680
Joined: Fri Oct 16, 2009 11:31 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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);
vefatica
Posts: 36
Joined: Sun Jun 11, 2023 6:27 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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).
void
Developer
Posts: 16680
Joined: Fri Oct 16, 2009 11:31 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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
vefatica
Posts: 36
Joined: Sun Jun 11, 2023 6:27 pm

Re: Declaration of _Everything_SendAPIBoolCommand?

Post 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.
Post Reply