Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Passing string from c# to c++ but c++ only gets the first character of string

$
0
0

I am trying to pass a string from c# to c++ it works perfectly but c++ only gets the first character of the string 

C# Code:

[DllImport("IDEDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
 static extern void DirCreate(string name);

DirCreate(text1.Text);

C++ Code:

extern "C"
{
__declspec(dllexport) void DirCreate(const char *path)
{
std::cout << path << std::endl;
}
}

Example: 
Input: Hello!
Output: H


Viewing all articles
Browse latest Browse all 1710

Trending Articles