473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

WM_COPYDATA problem

Hi

I tried to implement a C++ dll and a Visual Basic .net application, which is able to receive WM_COPYDATA messages from the DLL. Here's my code

DLL
typedef struct _TRANSTA

char teststr[300]
}TRANSTAG

TRANSTAG trans
COPYDATASTRUCT MyCDS
CString test
test = "This is a test."
memcpy(trans.teststr,test,test.GetLength())
MyCDS.cbData = test.GetLength()
MyCDS.lpData = &trans

HWND hwDispatch = FindWindow( NULL, "Form1" )
if( hwDispatch != NULL
SendMessage( hwDispatch
WM_COPYDATA
(WPARAM)(HWND) NULL
(LPARAM) (LPVOID) &MyCDS )

Now, here's the code in the VB.NET application

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> Structure TRANSTA
Public test As Strin
End Structur

Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (<MarshalAsAttribute(UnmanagedType.AsAny)> ByVal hpvDest As Object, <MarshalAsAttribute(UnmanagedType.AsAny)> ByVal hpvSource As Object, ByVal cbCopy As Long

Protected Overrides Sub WndProc(ByRef m As Message
Select Case (m.Msg
Case WM_COPYDAT
NewMessage(m.LParam
Me.Invalidate(
End Selec
MyBase.WndProc(m
End Su

Public Sub NewMessage(ByVal lparam As IntPtr
Dim cds As New COPYDATASTRUC
Dim d As New TRANSTA
CopyMemory(cds, lparam, Len(cds)
CopyMemory(d, cds.lpData, cds.cbData
MsgBox(d.test
End Su

The problem is that the received string doesn't contain anything: The message WM_COPYDATA is captured successfully, but d.test is just empty. Any ideas why

Thank
Gordon
Jul 21 '05 #1
0 1494

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Frank Bechmann | last post by:
I started to write a SciTe director in python. I had a very basic communication running in Pythonwin but I disliked the strong mixture between Pythonwin's basic functionality and the Pythonwin...
3
by: Chris | last post by:
Hi. I'm trying to make a python program that can recieve WM_COPYDATA messages. Not ideal, but the application I'll be receiving them from will only send it that way. So I wrote a small program...
3
by: The Collector | last post by:
Hi, I've been looking for almost two full days now to get full control of WinAMP using python. Simple play/stop functions are no problem. It's the WM_COPYDATA that's used by IPC_PLAYFILE (=add a...
2
by: devendra pardeshi | last post by:
hi friends/seniors i am stuck on one problem in VB 6.0 and need solution. see if u can help me. first i describe the problem. Can u imagin the WinZip scenario. we right click on some file...
1
by: James Kunicki | last post by:
Hi, I am trying to find if there is a structure in VB.NET that uses COPDATSTRUCT. In interfacing to an existing application, the application uses WM_COPYDATA message extensively, between...
0
by: Gordon | last post by:
Hi I tried to implement a C++ dll and a Visual Basic .net application, which is able to receive WM_COPYDATA messages from the DLL. Here's my code DLL typedef struct _TRANSTA char teststr...
3
by: **** KiteOregon **** | last post by:
How do i receive a wm_copydata message from a third party application? I can't seem to get the data or the message at all in my vb.net application, what do i need to do. thanks -- Just...
1
by: Thomas Kehl | last post by:
Hello. I use the fallowing Functions to send Message from one Application to another. This is working correct on a 32bit System. But on a 64Bit System, the Target-Application will no received...
1
by: d-42 | last post by:
Hi, I'm pretty sure I've just got a Marshalling problem, but I'm completely stumped. If there is a better newsgroup to post this in, please point me towards it. First I'm trying to use...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.