PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework
Pinvoke problem - only first character being sent.
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework
Pinvoke problem - only first character being sent.
![]() |
Pinvoke problem - only first character being sent. |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hello,
I am trying to use Pinvoke to use a Win 32 Visual C++ 6.0 dll in a .net C# application. This is the original function signature. BOOL __stdcall GetXMLString( const char* strInputFileName, const char* strPassword, char* strOutput, char* strErrorMessage) This is the signature i am using : [DllImport("C:\\STLKit.dll", CharSet = CharSet.Ansi)] public static extern bool GetXMLString( [In][MarshalAs(UnmanagedType.LPTStr)]string strInputFileName, [In][MarshalAs(UnmanagedType.LPTStr)]string strPassword, StringBuilder strOutput, StringBuilder strErrorMessage); The problem is that ONLY the first character of the string strInputFileName is being passed to the function. Do I need to allocate memory for the strInputFileName ? Any response would be highly appreciated. Thanks, Anirudh |
|
|
|
#2 |
|
Guest
Posts: n/a
|
> [DllImport("C:\\STLKit.dll", CharSet = CharSet.Ansi)]
> public static extern bool GetXMLString( > [In][MarshalAs(UnmanagedType.LPTStr)]string >strInputFileName, > [In][MarshalAs(UnmanagedType.LPTStr)]string strPassword, Get rid of the attributes, you don't need them and in this case the MarshalAs is incorrect. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

