I have a problem calling this function from a c++ DLL in c#
INT32 WINAPI PM_COM_GetText(INT32 TextId, char* pBuf, INT32 BufSize);
It writes a Text in a buffer for a given text id. I try to call it with the following c# code, but I constantly get an access violation and don't undrestand why:
public string GetText(Int32 TextId)
{
Int32 BufSize = 256;
StringBuilder Str = new StringBuilder(BufSize);
PM_COM_GetText(TextId, Str, BufSize);
return Str.ToString();
}
[DllImport("ComDll.dll", CharSet = CharSet.Ansi)]
private static extern Int32 PM_COM_GetText(Int32 TextId, StringBuilder Str, Int32 BufSize);
I don't see what's wrong, it looks to me like many other code snippets I found in the web.
Any ideas? Thanks in advance!