Andy Baker
Andy Baker
<pug...@googlemail.com> wrote in message
news:5b2bd884-532d-456a...@f63g2000hsf.googlegroups.com...
Can you please show your P/Invoke declaration for this function?
Perhaps you've forgotten CharSet?
Try this also:
[DllImport(CharSet = CharSet.Ansi)]
SDCERR GetCurrentConfig(ref uint num, StringBuilder name);
1) Look at the MarshalAsAttribute which tells .NET how to translate its
unicode string between it and unmanaged code; the attribute is applied to the
argument, here's the example from MSDN:
void MyMethod( [MarshalAs(LPStr)] string s);
2) The other option is to write the wrapper in managed C++; if you go this
route your method calls will look something like this:
void MyMethod(String^ s)
{
IntPtr ptr = Marshal::StringToHGlobalAnsi(str);;
try
{
SDCERR err = GetCurrentConfig( (char*)ptr.ToPointer() );
}
finally
{
if (ptr.ToPointer()) Marshal::FreeHGlobal(ptr);
}
}
HTH - KH
"Pavel Minaev" <int...@gmail.com> wrote in message
news:1f2323cd-7b69-47a4...@w7g2000hsa.googlegroups.com...
Andy Baker
"KH" <K...@discussions.microsoft.com> wrote in message
news:9C5B61AE-FAD6-496B...@microsoft.com...