RE: passing string array to C++
- From: v-phuang@xxxxxxxxxxxxxxxxxxxx ("Peter Huang" [MSFT])
- Date: Tue, 14 Jun 2005 06:12:36 GMT
Hi
Based on my research, all the System API on the WinCE is of Unicode
version, so it is common to handle all the string in the winCE of unicode
version.
I think it is better for you to convert your dll to handle Unicode version
string all the time.
Here is the WCHAR version P/Invoke for your reference.
[C++]
CPPDLL_API long MyAdapt( long g, WCHAR **strings, long numStrings)
{
for(int i=0;i<numStrings;i++)
{
printf("%S \n",strings[i]);
strings[i][2]='A'+i;
}
return 0;
}
extern "C" CPPDLL_API long MyAdapt( long g, WCHAR **strings, long
numStrings);
[C#]
[DllImport(@"..\..\..\CPPDLL\Debug\CPPDLL.dll",EntryPoint="MyAdapt",CharSet=
CharSet.Unicode,SetLastError=true)]
private static extern int MyAdapt(int g,[In,Out] string[] users, int
numUsers);
public static void InteropStringArray()
{
string[] strs = new string[]{"Hello","World"};
int rt = MyAdapt(2,strs,2);
foreach(string s in strs)
{
Console.WriteLine(s);
}
}
[STAThread]
static void Main(string[] args)
{
InteropStringArray();
}
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- RE: passing string array to C++
- From: Bruce Parker
- RE: passing string array to C++
- References:
- passing string array to C++
- From: Bruce Parker
- RE: passing string array to C++
- From: "Peter Huang" [MSFT]
- RE: passing string array to C++
- From: Bruce Parker
- passing string array to C++
- Prev by Date: Re: getting window handle..
- Next by Date: migration vb6 to vb.net
- Previous by thread: RE: passing string array to C++
- Next by thread: RE: passing string array to C++
- Index(es):
Relevant Pages
|