PC Review


Reply
Thread Tools Rate Thread

Pinvoke problem - only first character being sent.

 
 
anirudh
Guest
Posts: n/a
 
      5th Apr 2006
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

 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      5th Apr 2006
> [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.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: PInvoke problem dev15 Microsoft Dot NET Compact Framework 0 30th Jul 2007 09:59 AM
PInvoke RAS problem =?Utf-8?B?QUNQ?= Microsoft Dot NET Compact Framework 13 11th Mar 2005 10:39 AM
Pinvoke String problem Marco Mariv via DotNetMonster.com Microsoft Dot NET Compact Framework 2 2nd Feb 2005 04:22 PM
pinvoke problem Thomas Mobley Microsoft C# .NET 3 8th Jan 2004 03:07 PM
PInvoke problem nicolasr Microsoft C# .NET 2 16th Dec 2003 08:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:36 PM.