Hi,
I am really stuck with this.
I want to return to my vb client a String (BSTR) from a function in my (normal) dll. Thing is im converting from a TCHAR and am getting funny results.
Heres the code :
in VB this returns H...E...L...L...O... (where . = 0)
(or 'H' if you print it)
I also tried :
in VB this one returns H E L L O
Something strange is going on, im just not sure what !
Rich.
I am really stuck with this.
I want to return to my vb client a String (BSTR) from a function in my (normal) dll. Thing is im converting from a TCHAR and am getting funny results.
Heres the code :
Code:
TCHAR cValue[MAXBUFFER];
..
BSTR __stdcall GetValue()
{
CComBSTR bstr = cValue;
return bstr;
}
in VB this returns H...E...L...L...O... (where . = 0)
(or 'H' if you print it)
I also tried :
Code:
BSTR __stdcall GetValue()
{
int iLen = _tcslen(StringList[Index].Value);
CComBSTR bstr = StringList[Index].Value;
char cBuffer[MAXBUFFER];
WideCharToMultiByte(CP_ACP,0,bstr,iLen,cBuffer,MAXBUFFER,NULL,NULL);
cBuffer[iLen] = 0;
bstr = cBuffer;
return bstr;
}
in VB this one returns H E L L O
Something strange is going on, im just not sure what !
Rich.