learning33

I'm trying to use WM_COPYDATA to send information from a very simple programming language to C#. I'm sending approximately 50 variables at once. What is the best way to organize these variables

I've thought of two ways:
-using the send function 50 times
-sending 50 variables in one string and then splitting them up at delimiters. The only thing I don't like here is that the strings won't have labels.

Is there any way I can structure the sending of 50 strings at once and have every string has it's own label (so that the label and not the order of the variables determines how C# catches them)


Re: Visual C# General structure information in WM_COPYDATA

Jeremy Filburn

You can use more than one delimiter. I would suggest using a comma to separate the label and value. Separate the values by a semicolon.

Example:

label,value;nextLabel,nextValue; etc...

When splitting, first split by ';', then by ','

Make sense






Re: Visual C# General structure information in WM_COPYDATA

learning33

Yeah, clever hack! :-)

Thanks!




Re: Visual C# General structure information in WM_COPYDATA

learning33

I've tried this now, and it works well, but I feel like it makes my code "hard to read", with all the stringsplits and stuff. Another solution I have found that I think will be easier on the eye is using a unique id as wParam for every type of message, and use these id instead of the labels. How does that sound Are there any disadvantages with that So I'd use 50 different Id's (for example "IntPtr dahliaID = new IntPtr(951753);" and "IntPtr roseID = new IntPtr(951754);" instead of 50 labels.




Re: Visual C# General structure information in WM_COPYDATA

learning33

learning33 wrote:
I've tried this now, and it works well, but I feel like it makes my code "hard to read", with all the stringsplits and stuff. Another solution I have found that I think will be easier on the eye is using a unique id as wParam for every type of message, and use these id instead of the labels. How does that sound Are there any disadvantages with that So I'd use 50 different Id's (for example "IntPtr dahliaID = new IntPtr(951753);" and "IntPtr roseID = new IntPtr(951754);" instead of 50 labels.


I guess the downside is I'll have to hold 50 IntPtr objects in memory. I don't know how this will affect performance. Is it ignorable Or is it significant On the plus side I'll have code I find easier to read and I won't need to make as many stringsplits.

Looking for advice on which road to choose...