I
IdleBrain
Hello
I am trying to call a C++ DLL from C#:
C# code:
[DllImport("Log")]
static extern void LogMsg(String wsString1);
static void Main(string[] args)
{
LogMsg("Works!");
}
C++ DLL:
__declspec(dllexport) ULONG LogMsg(WCHAR* wsString1)
{
}
The problem is that the wsString1 from C# is being converted to a
garbage message.
Can some one help me on this conversion from C# string to WCHAR*.
I read somewhere that C# string is converted to LPTSTR in C++.
So, I even tried:
__declspec(dllexport) ULONG LogMsgNew(LPTSTR lpString1)
{
LogMsg(T2W(lpString1));
}
Any help is greatly appreciated. Thanks in advance
I am trying to call a C++ DLL from C#:
C# code:
[DllImport("Log")]
static extern void LogMsg(String wsString1);
static void Main(string[] args)
{
LogMsg("Works!");
}
C++ DLL:
__declspec(dllexport) ULONG LogMsg(WCHAR* wsString1)
{
}
The problem is that the wsString1 from C# is being converted to a
garbage message.
Can some one help me on this conversion from C# string to WCHAR*.
I read somewhere that C# string is converted to LPTSTR in C++.
So, I even tried:
__declspec(dllexport) ULONG LogMsgNew(LPTSTR lpString1)
{
LogMsg(T2W(lpString1));
}
Any help is greatly appreciated. Thanks in advance