_tcscpy is a TCHAR macro that resolves to either strcpy(ASCII) or wcscpy(Unicode). That means you need an LPCTSTR argument.
Then L"new data" does not produce the correct string. Use the TEXT or _T macro. This will call MultibyteToWideChar on the Unicode side.
- __declspec(dllexport) int __stdcall Test(LPCTSTR as_test)
-
{
-
_tcscpy(as_test, TEXT("new data");
-
-
return 0;
-
}
I know you are passing in an array of C# strings but I suggest you pass in onyl one string until you get a result.
Next, _tcscpy does not check that you have enough memory to make a copy. Plus the address is the address of the C# string. That causes _tcscpy to overwrite the C# string and you have no idea what the format of a C# string object is. Therefore, I expect corruption here.
I don't see where you are marshaling the code on the C++ side and I don't see you using IDispatch on the C++ side. That is, COM does your marshaling aand it does it through IDispatch.
You can't simply copy from one language to the other.