hi i am returning a LPTSTR type of object from unmanaged code which essentially points to a string . i am in managed code now and i m unable to read it in C# . the string being returned is just “YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY”..
Here is my managed code snippet.
[DllImport("TableConfig.dll", EntryPoint = "?getTableConfigDlg@@QAEPA_WXZ", CharSet = CharSet.Ansi)]
static extern String getColumnNamesFormat();
Is there anything wrong with this ???
How do i get meaningful data out of the string being returned from unmanaged code ?
Thanks
Native Code:-
for(int i=0; i<numCols; ++i)
{
const bet_TableConfigColumn *col_p = tc_p->getColumn(i);
const char* colName = tc_p->getKeyName(i);
const char* colFormat = col_p->getFormat();
str+=",";
str+=colName;
cout << "Col Name" << colName << "Format: " << colFormat;
} // end of for(i)
LPTSTR pString=str.GetBuffer(0);
str.ReleaseBuffer();
return pString;
Managed:
Native:
change method signature to return void, take in a LPTSTR for the managed buffer.