Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with SendMessageTimeout and/or WM_COPYDATA

221 views
Skip to first unread message

Peter Klinge

unread,
Aug 7, 2000, 3:00:00 AM8/7/00
to
Hi all,

I have build an application using the SendMessageTimeout function with
WM_COPYDATA. This will work fine, but one costumer tells me that he get
the error code 87 (invalid parameter) in most of all calls of this
function. My problem is to have no more information about this error and
I can't go to that costumer to check the system ...

Here the program fragment, I use:

static CmdLineType CmdLine;

void function (void) {
COPYDATASTRUCT Data;
DWORD result;
HWND hwnd; // handle of the
receiving window
HWND HWindow; // handle of the
sending window
...
Data.dwData = 0;
Data.cbData = sizeof (CmdLineType);
Data.lpData = &CmdLine;
if (!SendMessageTimeout (hwnd, WM_COPYDATA, (WPARAM)HWindow,
(LPARAM)&Data, SMTO_NORMAL, 3000, &result)) {
ErrLog (GetLastError ()); PostQuitMessage (1); return;}
....
}

Is there a possibility to find out, what parameter is invalid or what
can be the reason of that error.

Thanks a lot,
Peter

Christian Kaiser

unread,
Aug 8, 2000, 3:00:00 AM8/8/00
to
Without knowing CmdLineType, this could be a LPCTSTR or such. Then sizeof()
will return sizeof(pointer)=4, which is not what you need if your command
line is longer than 3 bytes.

You need (if CmdLineType is LPCTSTR, else you might need to change _tcslen
to strlen or wcslen):

Data.dwData = 0;
Data.cbData = (_tcslen(CmdLine)+1) * sizeof(CmdLine[0]);
Data.lpData = &CmdLine;
...

Christian

Peter Klinge <AME...@t-online.de> wrote in message
news:398EC1F7...@t-online.de...

Peter Klinge

unread,
Aug 9, 2000, 3:00:00 AM8/9/00
to
Thank you, but CmdLineType is an structure, so that the sizoef operator should
work OK. And the error comes only at one costumer, so I think it's an problem
with the PC configuration.

Peter

0 new messages