0

I have two application to communicate; C# and C++ MFC . I want to post and CString pointer address to c# and then at c# try to get and maybe change it.

at c++ CString * pstr = "123";

let's say pstr value is 0x112233;

usage must be like

String pointerAddress = "0x112233";
IntPtr processHandle = (IntPtr)Convert.ToInt32(pointerAddress);
String value = Marshal.PtrToStringAnsi(processHandle);
value = value + "456";
IntPtr = Marshal.StringToHGlobalUni(value);

is that possible? Main idea is not converting CString to String, main ides is posting string value. It can be any different format.

siyah
  • 53
  • 6
  • This is impossible, C# doesn't have an idea what is CString. Design interop interface based on primitive types, in your case this can be char* or wchar_t*. – Alex F May 20 '14 at 14:47
  • possible duplicate of [Convert String^ in c# to CString in c++](http://stackoverflow.com/questions/21059950/convert-string-in-c-sharp-to-cstring-in-c) – Rook May 20 '14 at 14:55
  • Main idea is not converting , main idea is posting value through pointers – siyah May 20 '14 at 14:59
  • What are you planning to ***do*** with the pointer once you get it marshaled to the C# side? – Cody Gray - on strike May 20 '14 at 15:02
  • i will use it to reset value which pointer points. So other application can use new value also. – siyah May 20 '14 at 15:04

0 Answers0