M
Marco Mariv via DotNetMonster.com
Hi group,
i have a problem.
I don't succeded to pass string from Unmanaged Code to managed code.
I have this situation:
Unmanaged Code:
------------------------
DRIVER_API int __stdcall
Read (LPWSTR data,int *len,int *lenwct)
{
..
...
....
char lpstr[255];
wchar_t szTmp[255];
..
...
....
*len = strlen(lpstr);
*lenwct = wcstombs(lpstr,szTmp,255);
..
...
....
return 1;
}
Managed Code (VB.NET):
------------------------
<DllImport("MyDriver.dll", EntryPoint:="Read", CallingConvention:=CallingConvention.Winapi, SetLastError:=True)> _
PublicFunction Read(ByVal data As StringBuilder, ByRef len As Int64,ByRef lenwct As Int64) As Integer
End Function
-------
When i (p)invoke this function i have this responce:
len = 120
lenwct = 6
data ="??????||||||"
why?
I dont' know how to convert a string (char *) to LPWSTR.
How can i pass a string from Unmenaged to menaged code.
I have use StringBuilder. Is it a correct solution?
Help me!
i have a problem.
I don't succeded to pass string from Unmanaged Code to managed code.
I have this situation:
Unmanaged Code:
------------------------
DRIVER_API int __stdcall
Read (LPWSTR data,int *len,int *lenwct)
{
..
...
....
char lpstr[255];
wchar_t szTmp[255];
..
...
....
*len = strlen(lpstr);
*lenwct = wcstombs(lpstr,szTmp,255);
..
...
....
return 1;
}
Managed Code (VB.NET):
------------------------
<DllImport("MyDriver.dll", EntryPoint:="Read", CallingConvention:=CallingConvention.Winapi, SetLastError:=True)> _
PublicFunction Read(ByVal data As StringBuilder, ByRef len As Int64,ByRef lenwct As Int64) As Integer
End Function
-------
When i (p)invoke this function i have this responce:
len = 120
lenwct = 6
data ="??????||||||"
why?
I dont' know how to convert a string (char *) to LPWSTR.
How can i pass a string from Unmenaged to menaged code.
I have use StringBuilder. Is it a correct solution?
Help me!