Zhorn Software
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
avatar
AbstractSpoon
Posts : 3
Join date : 2021-12-22

API Registration Failure Empty API Registration Failure

Wed Dec 22, 2021 11:14 pm
Hi All

I have written some software that replaced its native reminders with Stickies and all was working well on version 9.0e but is broken under version 10.1a.

In particular my calls to "api do register" keep returning '1'.

I looked at the code sample app which works (sample_cpp) but can't see any obvious differences apart from my app is Unicode so I'm converting to Ansi first. FWIW I also tried sending the command as unicode but that had no effect.

Here's my version for sending commands to Stickies:

Code:
LRESULT CStickiesAPI::SendCommand(int nCommandID, LPCWSTR szCommand, LPCWSTR szStickyID, LPCTSTR szExtra) const
{
 HWND hwndStickies = GetStickiesWindow();

 if (hwndStickies == NULL)
 return FALSE;

 // format command string
 CString sCommand = FormatCommandString(szCommand, szStickyID, szExtra);

 // send command string
 COPYDATASTRUCT cpd = { 0 };

 cpd.dwData = nCommandID;
 cpd.cbData = sCommand.GetLength();

 LPSTR szMBCommand = Misc::WideToMultiByte(sCommand);
 cpd.lpData = (void*)szMBCommand;
 
 return ::SendMessage(hwndStickies, WM_COPYDATA, (WPARAM)m_hwndCallback, (LPARAM)&cpd);
}

I'll keep hacking it about but any suggestions would be much appreciated.
avatar
AbstractSpoon
Posts : 3
Join date : 2021-12-22

API Registration Failure Empty Re: API Registration Failure

Wed Dec 22, 2021 11:36 pm
I'm debugging the sample app now and notice that the check for success (return value == 0) has been commented out because it too returns '1'.

So it seems like the API behaviour has changed - Is that correct?

Also, is what's being returned now a BOOL? ie. I can test for it?
Sooyke
Sooyke
Posts : 430
Join date : 2018-04-28

API Registration Failure Empty Re: API Registration Failure

Thu Dec 23, 2021 4:46 am
API Registration Failure 397510

From the changes list  stickies version 10 :  https://www.zhornsoftware.co.uk/stickies/versions.html


Return value

https://docs.microsoft.com/en-us/windows/win32/dataxchg/wm-copydata

If the receiving application processes this message, it should return TRUE; otherwise, it should return FALSE.
avatar
AbstractSpoon
Posts : 3
Join date : 2021-12-22

API Registration Failure Empty Re: API Registration Failure

Thu Dec 23, 2021 5:40 am
Many thanks.
Admin
Admin
Admin
Posts : 359
Join date : 2018-03-30
Location : London
http://www.zhornsoftware.co.uk

API Registration Failure Empty Re: API Registration Failure

Sun Jan 02, 2022 1:37 pm
My implementation of the WM_COPYDATA message handler had been incorrect for years.  See here:

https://docs.microsoft.com/en-us/cpp/mfc/reference/cwnd-class?view=msvc-170

...where it says "Returns TRUE if the receiving application successfully accepts the data. Otherwise, returns FALSE."

I had to weigh up whether I kept in consistent and broken, or to fix it and maybe break stuff.  I opted for the latter of course ... but I do try hard to keep track of anything I alter and put it in the release notes to help out.  Sorry it broke your app - but it means our code adheres to the standard now Smile

Tom

AbstractSpoon likes this post

Sponsored content

API Registration Failure Empty Re: API Registration Failure

Back to top
Permissions in this forum:
You can reply to topics in this forum