Try changing the p/invoke signature to take a byte[], and use
Encoding.ASCII.GetBytes on the unicode string. That should give you the
narrow character string.
Mike Boilen
Developer
.NET Compact Framework
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.gotdotnet.com/team/netcf/FAQ.aspx
--------------------
| Content-Class: urn:content-classes:message
| From: "newcomer" <
[email protected]>
| Sender: "newcomer" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
| Subject: Re: Managed to unmanaged TCHAR *
| Date: Tue, 21 Oct 2003 15:45:47 -0700
| Lines: 36
| Message-ID: <
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOYJRG1kqEAJI6eSdeicCTQ+Wad2Q==
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:36464
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| odd. that's what I tried the first time, but it didn't
| seem to work. Every time the DLL tries reading the
| string, it has a native exception.
|
| >-----Original Message-----
| >Just use a string.
| >
| >--
| >Chris Tacke, eMVP
| >Co-Founder and Advisory Board Member
| >
www.OpenNETCF.org
| >---
| >Windows CE Product Manager
| >Applied Data Systems
| >
www.applieddata.net
| >
| in message
| >| >> hello,
| >>
| >> I'm trying to invoke a function written in C that
| takes a
| >> (TCHAR *) filename (which will convert to char * and
| use
| >> fopen). In my managed code I have a String that I call
| >> ToCharArray() on to get a unicode character array. I
| try
| >> passing a reference to the first character into my dll
| >> function, but it seems to throw a native exception.
| What
| >> am I supposed to use in .NET CF? Thanks
| >
| >
| >.
| >
|