SendMessage string getting cut off to 15 characters

Im trying to send a user defined structure from one exe to another.
In my sending executable i use the code below. I put 3 things in a structure and pass the structure using SendMessage

[code] ipatInput input;
input.type = "load";
input.token = token;
input.fileName = fileName;

cds.dwData = 0;
cds.cbData = sizeof(input);
cds.lpData = &input;

SendMessage(myhwnd, WM_COPYDATA, NULL, (LPARAM)&cds);

My receiving program receives the data but the filaName property inside the structure has a value. This only happends if fileName is greater then 15 characters (null terminated -> 16bytes?) I dont understand why. I keep seeing some stuff about marshaling but i dont understand. What do i need to do to get this full string across instead of just if its less then 16 characters.

Thank you so much for your help


  • [color=Blue]Think about it - you are passing the size of the structure and the address to the structure. That means that each byte in that region is passed OK. However, MEMBERS OF THE STRUCTURE are probably pointers and no longer valid in a context of receiving process. What you need is to pass a structure which FULLY describes your data with all filenames and such. If your data has dynamic size (path however cannot be larger than 260 characters) then you need to create a dynamic block of memory (instead of input structure) and COPY into that memory all your related data and then pass it as a SINGLE block. Release memory AFTER SendMessage() returns.[/color]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion