Re: how can convert char* to LPTSTR in VS 2005?
- From: "Elhanan" <emaayan@xxxxxxxxxxx>
- Date: 16 Mar 2006 12:55:59 -0800
thanks, but i tried this:
__declspec(dllexport) int testFuncString(LPTSTR i, LPTSTR o,int size)
{
int l=0;
char *temp;
temp=malloc(size*sizeof(char));
memset(temp,0,size);
WideCharToMultiByte(CP_ACP,0,i,-1,temp,size,NULL,NULL);
printf("%s\n",temp);
MultiByteToWideChar(CP_ACP,0,temp,-1,o,size);
return 0;
}
i'm trying to call it dotnet 2.0 with this signature:
[DllImport("TestJNI.dll",CharSet=CharSet.Auto)]
static extern int testFuncString(string
i,[Out,MarshalAs(UnmanagedType.LPTStr)] StringBuilder o, int size);
StringBuilder s = new StringBuilder();
s.Length = 10;
string i = "Testing";
testFuncString(i,s,i.Length);
but in the printf i see some gibbirsh after the original string, like i
doesn't stop there.
.
- Follow-Ups:
- Re: how can convert char* to LPTSTR in VS 2005?
- From: addicted2rpg@xxxxxxxxx
- Re: how can convert char* to LPTSTR in VS 2005?
- References:
- how can convert char* to LPTSTR in VS 2005?
- From: Elhanan
- Re: how can convert char* to LPTSTR in VS 2005?
- From: William DePalo [MVP VC++]
- how can convert char* to LPTSTR in VS 2005?
- Prev by Date: Re: Catching exceptions
- Next by Date: Watchdog Timer, what is the best approach
- Previous by thread: Re: how can convert char* to LPTSTR in VS 2005?
- Next by thread: Re: how can convert char* to LPTSTR in VS 2005?
- Index(es):
Relevant Pages
|