RE: passing string array to C++
- From: v-phuang@xxxxxxxxxxxxxxxxxxxx ("Peter Huang" [MSFT])
- Date: Mon, 13 Jun 2005 07:56:17 GMT
Hi
The .NET P/Invoke Layer will help to pass the ansi version string to
unmanaged dll.
Here is a simple test. You may have a try and let me know the result.
[C++]
CPPDLL_API long MyAdapt( long g, char **strings, long numStrings)
{
for(int i=0;i<numStrings;i++)
{
printf("%s \n",strings[i]);
strings[i][2]='A'+i;//Change the string
}
return 0;
}
[C#]
[DllImport(@"..\..\..\CPPDLL\Debug\CPPDLL.dll",EntryPoint="MyAdapt",CharSet=
CharSet.Ansi,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();
}
BTW:
I am not very familar with Embeded develop very much, the code above should
work but I tested only on .NET framework.
For compactframework or evc issue, you may try to post in the newsgroup
below.
microsoft.public.dotnet.framework.compactframework
microsoft.public.pocketpc.developer
microsoft.public.windowsce.embedded.vc
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
- passing string array to C++
- Prev by Date: RE: Marshaling 2-Dim Arrays
- Next by Date: VB6.0 dll
- Previous by thread: passing string array to C++
- Next by thread: RE: passing string array to C++
- Index(es):
Relevant Pages
|