Click here to Skip to main content
15,910,872 members

Comments by Aschratt (Top 2 by date)

Aschratt 17-Apr-11 9:15am View    
Great one!

This solved my problem. I wrote a function to emulate _strdup() behavior with COM memory allocation:
static LPSTR _CoStrDup(LPCSTR lpszStr)
{
// Allocate memory for the string and the terminator.
SIZE_T nSize = strlen(lpszStr) + 1;
LPSTR lpszStrAlloc = (LPSTR)CoTaskMemAlloc(nSize);
strcpy_s(lpszStrAlloc, nSize, lpszStr);
return lpszStrAlloc;
}

Thanks again!
Aschratt 17-Apr-11 6:33am View    
I used BSTR's before, but they do not support 8-byte-charsets. I've build my library on top of a file format using ANSI strings and I hoped to change the charset of my library to ANSI, too, to get rid of validation code.