WM_COPYDATA between two applications

Hello,

I'm running VC++ 2005.

I have two program and want to exchange some data, a string, between them.

In the sender program I have this function:

BOOL CFSGClientDlg::SendCommand(CString command)
{
	COPYDATASTRUCT cds;
	LRESULT rc;
	TCHAR *buf;

	buf = new TCHAR[MAX_COPY_LENGTH];
	memset(buf,'\0',MAX_COPY_LENGTH);
	_tcscpy_s(buf,MAX_COPY_LENGTH,sOrderno.GetBuffer());
	sOrderno.ReleaseBuffer();

	cds.dwData = 0;
	cds.cbData = sOrderno.GetLength()+1;
	cds.lpData = (void*)buf;

	rc = m_pSCMLaserCWnd->SendMessage(WM_COPYDATA,
		(WPARAM)AfxGetApp()->m_pMainWnd->GetSafeHwnd(),
		(LPARAM)&cds);


	if (rc ==NULL)
	{
		DWORD errcode = GetLastError();
		return false;
	} // if (rc==NULL)
	return true;
}

And in the receiver program I have this:

BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
	CString sData=(TCHAR*)(pCopyDataStruct->lpData);
.... doing stuff with sData...
	return CFrameWnd::OnCopyData(pWnd, pCopyDataStruct);
}

I can see that the string I send is OK, but when I get to the receiving
part I get a couple of characters correkt and then just rubbish...

What have I done wrong?

// Anders
-- 
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
0
andis59 (75)
6/16/2008 2:39:40 PM
vc.mfc 33608 articles. 0 followers. Follow

21 Replies
1109 Views

Similar Articles

[PageSpeed] 59

Do both of your applications have the same unicode settings?


should this line:
> cds.cbData = sOrderno.GetLength()+1;

be:
> cds.cbData = sOrderno.GetLength()+sizeof(TCHAR);


AliR.


"Anders Eriksson" <andis59@gmail.com> wrote in message 
news:1s37n3yj1am4g.dlg@ostling.com...
> Hello,
>
> I'm running VC++ 2005.
>
> I have two program and want to exchange some data, a string, between them.
>
> In the sender program I have this function:
>
> BOOL CFSGClientDlg::SendCommand(CString command)
> {
> COPYDATASTRUCT cds;
> LRESULT rc;
> TCHAR *buf;
>
> buf = new TCHAR[MAX_COPY_LENGTH];
> memset(buf,'\0',MAX_COPY_LENGTH);
> _tcscpy_s(buf,MAX_COPY_LENGTH,sOrderno.GetBuffer());
> sOrderno.ReleaseBuffer();
>
> cds.dwData = 0;
> cds.cbData = sOrderno.GetLength()+1;
> cds.lpData = (void*)buf;
>
> rc = m_pSCMLaserCWnd->SendMessage(WM_COPYDATA,
> (WPARAM)AfxGetApp()->m_pMainWnd->GetSafeHwnd(),
> (LPARAM)&cds);
>
>
> if (rc ==NULL)
> {
> DWORD errcode = GetLastError();
> return false;
> } // if (rc==NULL)
> return true;
> }
>
> And in the receiver program I have this:
>
> BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
> {
> CString sData=(TCHAR*)(pCopyDataStruct->lpData);
> ... doing stuff with sData...
> return CFrameWnd::OnCopyData(pWnd, pCopyDataStruct);
> }
>
> I can see that the string I send is OK, but when I get to the receiving
> part I get a couple of characters correkt and then just rubbish...
>
> What have I done wrong?
>
> // Anders
> -- 
> English is not my first, or second, language
> so anything strange, or insulting, is due to
> the translation.
> Please correct me so I may improve my English! 


0
AliR3470 (3235)
6/16/2008 2:51:36 PM
On Mon, 16 Jun 2008 09:51:36 -0500, AliR (VC++ MVP) wrote:

> cds.cbData = sOrderno.GetLength()+sizeof(TCHAR);

Hello AliR,

Yes both applications has the same unicode settings and I have changed to
the above but I still get rubbish.

The string that I send is "test4" and the string I receive is "tes면醾繁釱繁䝠"

I think is has something to do with me using unicode but I can't figure out
what I have done wrong?


// Anders
-- 
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
0
andis59 (75)
6/16/2008 3:02:43 PM
"Anders Eriksson" <andis59@gmail.com> ha scritto nel messaggio 
news:1lc1uzpis62xv$.dlg@ostling.com...
> On Mon, 16 Jun 2008 09:51:36 -0500, AliR (VC++ MVP) wrote:
>
>> cds.cbData = sOrderno.GetLength()+sizeof(TCHAR);

it's:

cds.cbData = sOrderno.GetLength() * sizeof(TCHAR);

(scale * by sizeof(TCHAR))

Giovanni



0
6/16/2008 3:16:22 PM
"Anders Eriksson" <andis59@gmail.com> ha scritto nel messaggio 
news:1s37n3yj1am4g.dlg@ostling.com...

> In the sender program I have this function:
>
> BOOL CFSGClientDlg::SendCommand(CString command)

Pass input string by reference:

 BOOL CFSGClientDlg::SendCommand(const CString & command)

> {
> COPYDATASTRUCT cds;
> LRESULT rc;
> TCHAR *buf;
>
> buf = new TCHAR[MAX_COPY_LENGTH];
> memset(buf,'\0',MAX_COPY_LENGTH);

Do:

  memset( buf, 0, MAX_COPY_LENGTH * sizeof( TCHAR ) );

or

  ZeroMemory( buf, MAX_COPY_LENGTH * sizeof( TCHAR ) );


> _tcscpy_s(buf,MAX_COPY_LENGTH, sOrderno.GetBuffer());

No need of GetBuffer here; try this:

 _tcscpy_s(buf, MAX_COPY_LENGTH, sOrderno );

That should be OK (there's implicit LPCTSTR conversion operator defined for 
CString).


> cds.cbData = sOrderno.GetLength()+1;

The above should be:

 cds.cbData = (sOrderno.GetLength()+1) * sizeof(TCHAR);


Giovanni



0
6/16/2008 3:21:34 PM
"Giovanni Dicanio" <giovanni.dicanio@invalid.com> ha scritto nel messaggio 
news:Owbh6T8zIHA.3920@TK2MSFTNGP02.phx.gbl...

> BOOL CFSGClientDlg::SendCommand(const CString & command)

>
>> {
>> COPYDATASTRUCT cds;
>> LRESULT rc;
>> TCHAR *buf;
>>
>> buf = new TCHAR[MAX_COPY_LENGTH];

BTW: why do you allocate a fixed size "big" buffer (using MAX_COPY_LENGTH) ?

You may consider not wasting memory, and just allocate required bytes:

 // Number of TCHAR's, including NUL end-of-string (+1)
 int tcharCount = command.GetLength() + 1;

 // Allocate buffer to store them
 TCHAR * buf = new TCHAR[ tcharCount ];

 // Copy from original string
 StringCchCopy( buf, tcharCount, command );

 ...

>> cds.cbData = sOrderno.GetLength()+1;

 cds.cbData = tcharCount * sizeof(TCHAR);


Moreover, note that someone must delete[] the buffer allocated new[]. Else, 
you will have memory leaks.

HTH,
Giovanni



0
6/16/2008 3:30:06 PM
"AliR (VC++ MVP)" <AliR@online.nospam> ha scritto nel messaggio 
news:z5v5k.5263$N87.121@nlpi068.nbdc.sbc.com...
> Do both of your applications have the same unicode settings?
>
>
> should this line:
>> cds.cbData = sOrderno.GetLength()+1;
>
> be:
>> cds.cbData = sOrderno.GetLength()+sizeof(TCHAR);

I believe AliR meant * sizeof(TCHAR) (not + ).

However, there is also the need to transmit NUL (0 end-of-string).

So (...GetLength() + 1) * sizeof(TCHAR) should be used.

Giovanni



0
6/16/2008 3:37:55 PM
"Anders Eriksson" <andis59@gmail.com> ha scritto nel messaggio 
news:1s37n3yj1am4g.dlg@ostling.com...

Not related to your problem, but I think worth correcting:

> BOOL CFSGClientDlg::SendCommand(CString command)
....
> if (rc ==NULL)
> {
> DWORD errcode = GetLastError();
> return false;
> } // if (rc==NULL)
> return true;
> }

The function returns BOOL, so you should use TRUE and FALSE instead of 
'true' and 'false' (which are fine for 'bool').

Giovanni


0
6/16/2008 3:47:01 PM
"Anders Eriksson" <andis59@gmail.com> ha scritto nel messaggio 
news:1s37n3yj1am4g.dlg@ostling.com...

> I'm running VC++ 2005.
>
> I have two program and want to exchange some data, a string, between them.
>
> In the sender program I have this function:
>
> BOOL CFSGClientDlg::SendCommand(CString command)

I did a small MFC test using a dialog-based app, and developed this routine 
for sending (it works for me in Unicode builds with VS2008):

<code>

BOOL CDataSenderDlg::SendCommand( const CString & command )
{
    // Number of TCHAR's, including terminating NUL
    int charCount = command.GetLength() + 1;

    // Dynamically allocate buffer for string
    TCHAR * buf = new TCHAR[ charCount ];

    // Copy source string to destination buffer
    _tcscpy_s( buf, charCount, command );

    // Prepare structure for WM_COPYDATA
    COPYDATASTRUCT copyData;
    copyData.dwData = /* some ID code here... */;
    copyData.cbData = charCount * sizeof(TCHAR);
    copyData.lpData = (void * )buf;

    // Send message
    BOOL processed = (BOOL) m_pWndReceiver->SendMessage(
        WM_COPYDATA,
        reinterpret_cast<WPARAM>( this->GetSafeHwnd() ),
        reinterpret_cast<LPARAM>( &copyData )
    );

    // Cleanup allocated buffer
    delete[] buf;
    buf = NULL;

    if ( !processed )
    {
        // ... do something for error here
        return FALSE;
    }

    // All right
    return TRUE;
}

</code>

HTH,
Giovanni



0
6/16/2008 4:16:41 PM
Hi Giovanni,

Thanks for correcting my mistake. :)

AliR.


"Giovanni Dicanio" <giovanni.dicanio@invalid.com> wrote in message 
news:u8pD9Q8zIHA.3496@TK2MSFTNGP03.phx.gbl...
>
> "Anders Eriksson" <andis59@gmail.com> ha scritto nel messaggio 
> news:1lc1uzpis62xv$.dlg@ostling.com...
>> On Mon, 16 Jun 2008 09:51:36 -0500, AliR (VC++ MVP) wrote:
>>
>>> cds.cbData = sOrderno.GetLength()+sizeof(TCHAR);
>
> it's:
>
> cds.cbData = sOrderno.GetLength() * sizeof(TCHAR);
>
> (scale * by sizeof(TCHAR))
>
> Giovanni
>
>
> 


0
AliR3470 (3235)
6/16/2008 6:51:26 PM
Hi Anders,

u cant copy data from one process to another. Inprocess
u can handel WM_COPYDATA so:


void CBitmapView::SendCopyData(CLICKEVENT Event,CPoint pt /*=CPoint(0,0)*/)
{
 if(!m_pParentWnd || !m_pParentWnd->m_hWnd)
  return;

 CCrossFocus *pHair = m_gdiobj.GetFocus();
 int id=-1;

 if(pHair)
 {
   pt = pHair->GetFocus();
   id = pHair->GetId();
 }

 m_vclick.PosX      = pt.x;
 m_vclick.PosY      = pt.y;
 m_vclick.FocusId   = id;
 m_vclick.PixelUnit = m_gdiobj.GetPixelUnits();
 m_vclick.Event     = Event;

 m_pParentWnd->SendMessage(WM_COPYDATA,(WPARAM)(HWND) m_hWnd,(LPARAM) 
(LPVOID) &m_MyCDS);
}





"Anders Eriksson" <andis59@gmail.com> schrieb im Newsbeitrag 
news:1s37n3yj1am4g.dlg@ostling.com...
> Hello,
>
> I'm running VC++ 2005.
>
> I have two program and want to exchange some data, a string, between them.
>
> In the sender program I have this function:
>
> BOOL CFSGClientDlg::SendCommand(CString command)
> {
> COPYDATASTRUCT cds;
> LRESULT rc;
> TCHAR *buf;
>
> buf = new TCHAR[MAX_COPY_LENGTH];
> memset(buf,'\0',MAX_COPY_LENGTH);
> _tcscpy_s(buf,MAX_COPY_LENGTH,sOrderno.GetBuffer());
> sOrderno.ReleaseBuffer();
>
> cds.dwData = 0;
> cds.cbData = sOrderno.GetLength()+1;
> cds.lpData = (void*)buf;
>
> rc = m_pSCMLaserCWnd->SendMessage(WM_COPYDATA,
> (WPARAM)AfxGetApp()->m_pMainWnd->GetSafeHwnd(),
> (LPARAM)&cds);
>
>
> if (rc ==NULL)
> {
> DWORD errcode = GetLastError();
> return false;
> } // if (rc==NULL)
> return true;
> }
>
> And in the receiver program I have this:
>
> BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
> {
> CString sData=(TCHAR*)(pCopyDataStruct->lpData);
> ... doing stuff with sData...
> return CFrameWnd::OnCopyData(pWnd, pCopyDataStruct);
> }
>
> I can see that the string I send is OK, but when I get to the receiving
> part I get a couple of characters correkt and then just rubbish...
>
> What have I done wrong?
>
> // Anders
> -- 
> English is not my first, or second, language
> so anything strange, or insulting, is due to
> the translation.
> Please correct me so I may improve my English! 


0
kahnpost (16)
6/16/2008 7:19:34 PM
Hi Anders,

u cant copy data from one process to another. Inprocess
u can handel WM_COPYDATA so:


typedef struct ViewClick
{
  int        PosX;
  int        PosY;
  int        FocusId;
  double     PixelUnit;
  CLICKEVENT Event;
}VIEWCLICK;

void CBitmapView::SendCopyData(CLICKEVENT Event,CPoint pt /*=CPoint(0,0)*/)
{
 if(!m_pParentWnd || !m_pParentWnd->m_hWnd)
  return;

 CCrossFocus *pHair = m_gdiobj.GetFocus();
 int id=-1;

 if(pHair)
 {
   pt = pHair->GetFocus();
   id = pHair->GetId();
 }

 m_vclick.PosX      = pt.x;
 m_vclick.PosY      = pt.y;
 m_vclick.FocusId   = id;
 m_vclick.PixelUnit = m_gdiobj.GetPixelUnits();
 m_vclick.Event     = Event;

 m_pParentWnd->SendMessage(WM_COPYDATA,(WPARAM)(HWND) m_hWnd,(LPARAM)
(LPVOID) &m_MyCDS);
}


After send data u can handle it in your Dialog :

BOOL CCamInspectTestDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* 
pCopyDataStruct)
{
 VIEWCLICK *pVclk=0;
 if(pCopyDataStruct->dwData == VIEWCLICKMSG)
  if(pCopyDataStruct->cbData == sizeof(VIEWCLICK))
   if((pVclk = (VIEWCLICK *)pCopyDataStruct->lpData))
   {
    double cal(pVclk->PixelUnit);
    CString str; str.Format("X(%0.4f):Y(%0.4f) Cal(%0.4f) Id(%d) Evt(%d)",
    pVclk->PosX*cal,pVclk->PosY*cal,cal,pVclk->FocusId,pVclk->Event);
    SetWindowText(str);
   }

 return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}


"Anders Eriksson" <andis59@gmail.com> schrieb im Newsbeitrag 
news:1s37n3yj1am4g.dlg@ostling.com...
> Hello,
>
> I'm running VC++ 2005.
>
> I have two program and want to exchange some data, a string, between them.
>
> In the sender program I have this function:
>
> BOOL CFSGClientDlg::SendCommand(CString command)
> {
> COPYDATASTRUCT cds;
> LRESULT rc;
> TCHAR *buf;
>
> buf = new TCHAR[MAX_COPY_LENGTH];
> memset(buf,'\0',MAX_COPY_LENGTH);
> _tcscpy_s(buf,MAX_COPY_LENGTH,sOrderno.GetBuffer());
> sOrderno.ReleaseBuffer();
>
> cds.dwData = 0;
> cds.cbData = sOrderno.GetLength()+1;
> cds.lpData = (void*)buf;
>
> rc = m_pSCMLaserCWnd->SendMessage(WM_COPYDATA,
> (WPARAM)AfxGetApp()->m_pMainWnd->GetSafeHwnd(),
> (LPARAM)&cds);
>
>
> if (rc ==NULL)
> {
> DWORD errcode = GetLastError();
> return false;
> } // if (rc==NULL)
> return true;
> }
>
> And in the receiver program I have this:
>
> BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
> {
> CString sData=(TCHAR*)(pCopyDataStruct->lpData);
> ... doing stuff with sData...
> return CFrameWnd::OnCopyData(pWnd, pCopyDataStruct);
> }
>
> I can see that the string I send is OK, but when I get to the receiving
> part I get a couple of characters correkt and then just rubbish...
>
> What have I done wrong?
>
> // Anders
> -- 
> English is not my first, or second, language
> so anything strange, or insulting, is due to
> the translation.
> Please correct me so I may improve my English! 


0
kahnpost (16)
6/16/2008 7:22:12 PM
"AliR (VC++ MVP)" <AliR@online.nospam> ha scritto nel messaggio 
news:pCy5k.7071$ZE5.1935@nlpi061.nbdc.sbc.com...
> Hi Giovanni,
>
> Thanks for correcting my mistake. :)

:)

This kind of typos can happen to everyone when we don't use the compiler to 
build the code.

Giovanni



0
6/16/2008 9:46:57 PM
"Karsten Schulz" <kahnpost@freenet.de> wrote in message 
news:eA5UKZ%23zIHA.1240@TK2MSFTNGP02.phx.gbl...
> Hi Anders,
>
> u cant copy data from one process to another. Inprocess
> u can handel WM_COPYDATA so:

I'm sorry, but this is not true.  WM_COPYDATA marshalls the data across 
process boundaries.  That is in fact why it exists!

-- David


0
dc2983 (3206)
6/17/2008 12:31:26 AM
On Mon, 16 Jun 2008 16:39:40 +0200, Anders Eriksson wrote:

> I have two program and want to exchange some data, a string, between them.
> 
> I can see that the string I send is OK, but when I get to the receiving
> part I get a couple of characters correkt and then just rubbish...
> 
> What have I done wrong?
> 

Thank you all for your answers! A special Thank You to mr Giovanni Dicanio 
that took the time to explain in detail!

// Anders
-- 
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
0
andis59 (75)
6/17/2008 5:04:59 AM
ok nice,  but code works.

"David Ching" <dc@remove-this.dcsoft.com> schrieb im Newsbeitrag 
news:vCD5k.1755$LG4.1399@nlpi065.nbdc.sbc.com...
> "Karsten Schulz" <kahnpost@freenet.de> wrote in message 
> news:eA5UKZ%23zIHA.1240@TK2MSFTNGP02.phx.gbl...
>> Hi Anders,
>>
>> u cant copy data from one process to another. Inprocess
>> u can handel WM_COPYDATA so:
>
> I'm sorry, but this is not true.  WM_COPYDATA marshalls the data across 
> process boundaries.  That is in fact why it exists!
>
> -- David
>
> 


0
kahnpost (16)
6/17/2008 7:39:27 AM
"Anders Eriksson" <andis59@gmail.com> ha scritto nel messaggio 
news:e7q4qtbcsogd$.dlg@ostling.com...

> Thank you all for your answers! A special Thank You to mr Giovanni Dicanio
> that took the time to explain in detail!

You're welcome Anders.

BTW: "Giovanni" works better than "Mr. Giovanni Dicanio" ;-)

Giovanni



0
6/17/2008 2:30:58 PM
Or there's always "G" :o)

Tom

"Giovanni Dicanio" <giovanni.dicanio@invalid.com> wrote in message 
news:ONLracI0IHA.4876@TK2MSFTNGP04.phx.gbl...
>
> "Anders Eriksson" <andis59@gmail.com> ha scritto nel messaggio 
> news:e7q4qtbcsogd$.dlg@ostling.com...
>
>> Thank you all for your answers! A special Thank You to mr Giovanni 
>> Dicanio
>> that took the time to explain in detail!
>
> You're welcome Anders.
>
> BTW: "Giovanni" works better than "Mr. Giovanni Dicanio" ;-)
>
> Giovanni
>
>
> 

0
tom.nospam (3240)
6/18/2008 9:12:49 PM
"Tom Serface" <tom.nospam@camaswood.com> ha scritto nel messaggio 
news:754D00E4-B0DB-4C47-A8C1-ADD403C349D0@microsoft.com...
> Or there's always "G" :o)

Yes :-)

G


0
6/18/2008 10:23:18 PM
Actually, I would not use 'new'.  I would do

CByteArray buf;
buf.SetSize( (command.GetLength() + 1) * sizeof(TCHAR));

and do

cds.cbData = buf.GetSize();
and
cds.lpData = buf.GetData();

so there would be no need to remember to do the delete at all.

In addition, I have been seriously done in by irresponsible programmers who did a 
	SendMessage(HWND_BROADCAST, WM_COPYDATA, ...)
so I now put a GUID as the first 128 bits of the message and double-check it; see my essay
on WM_COPYDATA.
					joe

On Mon, 16 Jun 2008 17:30:06 +0200, "Giovanni Dicanio" <giovanni.dicanio@invalid.com>
wrote:

>
>"Giovanni Dicanio" <giovanni.dicanio@invalid.com> ha scritto nel messaggio 
>news:Owbh6T8zIHA.3920@TK2MSFTNGP02.phx.gbl...
>
>> BOOL CFSGClientDlg::SendCommand(const CString & command)
>
>>
>>> {
>>> COPYDATASTRUCT cds;
>>> LRESULT rc;
>>> TCHAR *buf;
>>>
>>> buf = new TCHAR[MAX_COPY_LENGTH];
>
>BTW: why do you allocate a fixed size "big" buffer (using MAX_COPY_LENGTH) ?
>
>You may consider not wasting memory, and just allocate required bytes:
>
> // Number of TCHAR's, including NUL end-of-string (+1)
> int tcharCount = command.GetLength() + 1;
>
> // Allocate buffer to store them
> TCHAR * buf = new TCHAR[ tcharCount ];
>
> // Copy from original string
> StringCchCopy( buf, tcharCount, command );
>
> ...
>
>>> cds.cbData = sOrderno.GetLength()+1;
>
> cds.cbData = tcharCount * sizeof(TCHAR);
>
>
>Moreover, note that someone must delete[] the buffer allocated new[]. Else, 
>you will have memory leaks.
>
>HTH,
>Giovanni
>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
6/23/2008 12:56:21 AM
"Joseph M. Newcomer" <newcomer@flounder.com> ha scritto nel messaggio 
news:5vst54dfklnsarqdgjil3g910ufrmrkg4e@4ax.com...
> Actually, I would not use 'new'.  I would do
>
> CByteArray buf;
> buf.SetSize( (command.GetLength() + 1) * sizeof(TCHAR));

I agree with you about using a container class.
I would use std::vector< BYTE >.

I used 'new' just to keep the code as near as possible to original OP's 
version.


> In addition, I have been seriously done in by irresponsible programmers 
> who did a
> SendMessage(HWND_BROADCAST, WM_COPYDATA, ...)
> so I now put a GUID as the first 128 bits of the message and double-check 
> it

I do agree with you.
In fact in code I posted I wrote "some ID code here ..." (and GUID you 
suggested is an excellent option, of course).

<code>
....
    // Prepare structure for WM_COPYDATA
    COPYDATASTRUCT copyData;
    copyData.dwData = /* some ID code here... */;
....
</code>


Giovanni


0
6/23/2008 8:17:47 AM
"Giovanni Dicanio" <giovanni.dicanio@invalid.com> ha scritto nel messaggio 
news:%23YH2$nQ1IHA.4040@TK2MSFTNGP04.phx.gbl...

> In fact in code I posted I wrote "some ID code here ..." (and GUID you 
> suggested is an excellent option, of course).
>
> <code>
> ...
>    // Prepare structure for WM_COPYDATA
>    COPYDATASTRUCT copyData;
>    copyData.dwData = /* some ID code here... */;

dwData is DWORD i.e. 32 bits, so it is not possible to use a GUID (because a 
GUID is 128 bits) here.

But it could be possible to put a GUID as header bytes for 
COPYDATASTRUCT.lpData .

Giovanni



0
6/23/2008 8:34:17 AM
Reply:

Similar Artilces:

Is there a two a shortcut to Save As with two letters?
I know that Ctrl + S is the shortcut to Save document. I wonder, is there a shorcut to Save As other than the F12 key? Thanks. If it is a new (unsaved) document, then Ctrl+S will trigger the SaveAs dialog too because Word is unable to simply Save as it doesn't know what name or location to save it. -- Terry Farrell - MSWord MVP "Octavio" <inquirer@inquirer.com> wrote in message news:#vaLSFXtKHA.4860@TK2MSFTNGP05.phx.gbl... > I know that Ctrl + S is the shortcut to Save document. > I wonder, is there a shorcut to Save As other than the F12 ke...

Two field entry questions
I don't know if VBA will be involved, but... I have a Word document with some tables and some of the cells of that table should have text entered. What I'd really like to have those cells which require entry to initially be yellow in color, but whenever text is entered (either when the cursor has left the table cell, or also acceptable when any text appears in the table cell) the background color should go away. My second question is that there are some places in my document where I have entered spaces with an underline to indicate that it should be filled out. However, wh...

WM_COPYDATA,...
Hi, can someone tell me what the path of a WM_COPDATA is? You start At SendMessage/PostMessage and it goes to the target apps Handler routine, but what happens with the data in between the SendMessage and getting it on the target data. Will the Memory be stored temporarilly somewhere and read from there or how will the memory delivered? TIA,... Regards Kerem -- ----------------------- Beste Gr�sse / Best regards / Votre bien devoue Kerem G�mr�kc� Latest Project: http://www.codeplex.com/restarts Latest Open-Source Projects: http://entwicklung.junetz.de ----------------------- "Thi...

overlay two time series in a chart with different data amound
I have the stock quotes of two different companies. Of stock A I have daily data and of stock B I only have weekly data. I'd like to overlay the two companies' stock quotes in a diagram. How do I have to configure excel for that it stretches the quote for the company for which I only have weekly data? any help is appreciated? Nicolas -- if you reply via email, please remove the NOSPAM from my address. Try leaving blanks for the days when you have no data. Excel (using X scatter graph) can handle gaps. Put the dates, data for stock1 and data for stock2 in 3 consecutiv columns. A...

How to combine two Money Files?
I have two separate money files, one with all my stock info, and the other with checking, savings accounts, etc. I would like to combine the two into one file. Is there a way to do this? (I'm using Money 2003 small business) Decide which one of the two you want to make your main one. From the "other" one export all accounts in QIF format. Load the new "main" file and import the QIF files. Make sure to import them all together to avoid any transfers being double counted (use CTRL + Click when asked which file to import). -- Regards Bob Peel, Microsoft MVP - M...

Conflict of two macros?
Hi all, I have the below two codes in my worksheet, the first one is run using a button and the second one is an automatic macro to enter fixed dates. There seems to be a conflict, as each time I use the button to add a row, I get an error, and when I go to debug it highlights this row in the second macro --> If Target.Value = "" Then Is there a solution? I can't see why there is an error, as both are separate codes? Any help will be appreciated! Thanks! ********************* ***The first code: Private Sub CommandButton1_Click() For i = 1 To 10000 ...

Averaging a Value between Two Serial Dates
Hi all, I have two spreadsheets. The first spreadsheet contains two columns, one for start date/time (in serial format) and the second for stop date/time (in serial format). The second spreadsheet contains two columns. One containing a serial date/time and the other containing a meteorological value (eg. temperature). I want Excel to read the start and stop date/time from the first spreadhseet and then search the second spreadsheet for all temperature values which were recorded during this time frame. Lastly, I want Excel to average these values. Is this possible using a single Excel func...

Vlookup for two sheets in same workbook
Ok. I am desparate. I've working on this for hours; I have VIN numbers in sheet 1 in the range I2:I5521 I have VIN numbers in sheet 2 in the range G2:G4717. I need to see if the VIN numbers in sheet 2 are on sheet 1, of so highlight the cell or delete the VIN number. I'd really like to delete the duplicate. Roberta select column G in the second worksheet and name it "ColumnG" without the quotes. Then, select cells I2 down to I5521 in the first worksheet and choose Format Conditional Formatting... Change Condition 1 to: Formula: =VLOOKUP(I2,ColumnG,1,FALSE)=I2 ...

application.EnableEvents
When using the above keyword and setting it to False with a worksheet change event. How can I run my macros using worksheet change event, if I forget to reset it to True? You can't. With .EnableEvents set to false, events won't fire, and their corresponding event macros won't run. Just don't forget! You can always enter application.enableevents = true in the immediate window of the VBE. You could even create a macro to run that line of code. In article <8E65B43B-08C5-470E-AE35-F292E36D8D53@microsoft.com>, "nc" <nc@discussions.microsoft.com&g...

terminating an application
Hi, I'm trying to terminated my application from within its CWinApp derived class, i'm diong this by calling PostQuitMessage, But it isn't working. How can I get my application to terminate from initinstance? heres my current non-working code: try { CViceMP3Dlg dlg; m_pMainWnd = &dlg; if(!ExitApp) { int nResponse = dlg.DoModal(); } return FALSE; } catch (char *str) { CString csStr(""); csStr.Format("Exception: %s",str); AfxMessageBox(csStr); PostQuitMessage(1); } I also don't like tha...

Two quick questions
Firstly, I am using Excel 97 SR-2. My questions are: If I enter a date in a cell then drag the fill handle down the column it increased by one day each time. Is it possible to create 2 rows with the same date, then the next two increase by one etc. If so, how do I do it? Secondly, if there is a formula in a cell but no data for it to use it displays ####. Is it possible to stop this until data is entered? Regards, Tim. -- timdee ------------------------------------------------------------------------ timdee's Profile: http://www.excelforum.com/member.php?action=getinfo&userid...

SendMessageTimeout, Wm_COPYDATA, interlocking
HI, I am trying to port a sofwtare on pocket pc. Here is the architecture : I have two different processes (client/server)that communicates via a WM_COPYDATA. In the direction of Server->Client, SendMessage is used In the direction of CLient->Server, SendMessageTimeout with SMTO_BLOCK (Prevents the calling thread from processing any other requests until the function returns) The problem is on pocket SendMessageTimeout only have a SMTO_NORMAL parameter. It means the calling thread is not blocked. Here is the situation : My server sends to my client a WM_COPYDATA via a SendMessag...

CRM 4 set up with two NICs
Can CRM 4 handle 2 network cards on the application server? "ilibhart" <ilibhart@discussions.microsoft.com> wrote in message news:9E9A2487-07A0-4D96-96B6-A6FC46189177@microsoft.com... > Can CRM 4 handle 2 network cards on the application server? Yes, it can. I have at least one CRM implementation running on a machine with 2 NICs, each in different subnets. ...

New user not added to TWO database
Hello, I've recently noticed that newly created users are not added to the TWO database when they are created in GP. This prevents the user from being able to log in (they get an error message saying to contact the system administrator). Is there a SQL query I can run to fix this problem? Thanks Josh Josh, No SQL. Go into Tools > Setup > User Access and add the user to the companies that you want them to access. -- Lyle U Josh Kandiko wrote: > Hello, > > I've recently noticed that newly created users are not added to the > TWO database when they are cre...

Comparing two tables 09-17-07
Hello, I have a problem which I don't know how to solve. I have two tables. T1 and T2. T1 has a field with phone numbers named PN1 and T2 also has a field with phone numbers named PN2. T1 also has a field named F1. What I need is to find out which records of T2 have the same phone number as in T1. So actually I want to compare entries of the two phone number fields of the two tables. And what I need is wherever the entries of both fields are the same to have the ID number which is in a field in T2 entered in the field F1 of table 1. So if PN2 of T2 the same with PN1 of T1, then I mu...

WM_COPYDATA question
Can you send WM_COPYDATA messages asynchronously? For example, using postmessage() instead of sendmessage()? >Can you send WM_COPYDATA messages asynchronously? For example, using >postmessage() instead of sendmessage()? AFAIK you have to use SendMessage. Dave On Jul 1, 10:15=A0am, "Nick Schultz" <nick.schu...@flir.com> wrote: > Can you send WM_COPYDATA messages asynchronously? =A0For example, using > postmessage() instead of sendmessage()? The quick answer is "no": You must use SendMessage and cannot use PostMessage. The docs formerly include...

Comparing two tables 07-05-07
Hi, I'm still getting used to Access and needed a little help. I have two tables with virtually the same data and i was wanting to compare them using an SQL query so i can see what data is missing? Is anyone able to help? Thanks On Thu, 5 Jul 2007 16:24:02 -0700, Adrian <Adrian@discussions.microsoft.com> wrote: >Hi, >I'm still getting used to Access and needed a little help. > >I have two tables with virtually the same data and i was wanting to compare >them using an SQL query so i can see what data is missing? > >Is anyone able to help? > >Thank...

WM_COPYDATA, overhead
I've been following Joseph Newcomers tutorial on utilizing WM_COPYDATA for inter process communicaton. I need to transfer a variable amount of data to the client program. Most of the time it is in the order of 40 bytes, but could be up to 1kb. I created 5 structures, each with a different array size. I examine the size of the data to be sent and picked the structure with the most appropriate size. In the message, I set dwData to a flag indicating the type of message. The recipient then casts the received data to the appropriate structure. Well that was the idea... I havent yet succe...

Printing with Two Viewss
I have two views with each document and I would like to print what is in the second view. When the second view has focus, then Print Preview and Print are greyed out on the File Menu and I can't find any information on what has to be done to print. My second view is CView class. I will appreciate any help. --Wes Wes, By far the easiest way to start is createing an empty project with print/print preview support, and one without. Then, see what code you'll have to add to view number two. Remove this code from view number one. Then, just hold your thumbs, hoping that the com...

Two sided, fold over business card
I've been asked to create a telephone number list for our family. There will be close to 50 phone #s,when you take into account home, work, and cell nummbers. I'd like to make a double size high business card that could be folded over. I would like to be able to fill up both sides of the card. The problem is, I have quite a bit of info that needs to fit into a wallet. The question is.....what software would I use to do this? I have Office 2000 pro, so I thought I could use Excel, Word, or Publisher. I also have Microsoft Home Publisher 2000 and Avery Designpro as well. ...

CWinThread, CWnd, WM_COPYDATA, IPC
I'm trying to use WM_COPYDATA as an IPC method between two applications (a client and a server). I'd like the IPC to not bother the main GUI thread, so I thought of having both the client and server apps have a CWinThread with an invisible CWnd. Then, the client could send a WM_COPYDATA message to the server CWnd, and the server could send data back to the clients CWnd. The questions: Is this safe? I've never used a CWinThread before. I always use worker threads. How (where) do I construct the CWnd, and how do I make it not be a child of the main gui? Can a CWinThread me...

Select two records then select the next two records
I am still somewhat a beginner at this access stuff but I have something that I am sure can be done but I don't know how to do it. I am using ACCESS 2003. I have a database with contacts with auto id, last name, first name, ect. At my company we everyday we get together and pray for two of the contacts. So I would like to have a query that can select two contacts and then somehow next time I run that query I get the next two contacts. I am thinking I need to make a form that selects two contacts and stores them in a table? and then next time I run a query it can just add...

Two ? from an Outlook newbie
Greetings I have two question I need some help with. First: I am not able to find go to newsgroups at all in my Outlook 2003. So I have to open OE to access newsgroups. But in Outlook 2003 when I compose a new message and click on "to:" for addressing the email I get the following error message. "Can't contact LDAP Directory Server (81)", then when it opens the address book to select names it is set for opening the newsgroups and not the contacts folder. I have to click on the pull down menu to select the contacts folder. How can I eliminate the error messag...

how can i relate between two columns in two sheets?
Question no too clear - you can use this space to give a detailed question. But here goes: On Sheet1 I can type formulas such as =Sheet2!A1 =SUM(Sheet2!A:A10) If I type = and then click on the cell A1 of a worksheet called My Yearly Totals, I will get the formula ='My Yearly Totals'!A1 Note that a sheet name having spaces get surrounded by single quotes. Does this answer your question? best wishes -- Bernard Liengme Microsoft Excel MVP people.stfx.ca/bliengme email address: remove uppercase characters REMEMBER: Microsoft is closing the newsgroups; We will all me...

Data Verification: Comparing Two Identical Tables in MS ACCESS
I am using Access for entering a large number of questionanaires and other tests all by hand and in order to reduce errors I am using manual first entry and second entry. I am looking for a way to compare the records in each table against one another and be able to view and edit the discrepancies. It would also be nice if there was a way to limit the results to a specific record. Does anyone have an idea on how it would be possible to make this happen in Access? I have tried the VBA approach using some complicated code I found but it is limiting and I would like to find a way to do it with mi...