the pointer returned by string::c_str() is
a. a const char*. if you need a LPSTR (char*), you need to copy (strcpy) it to an array of chars
b. usable as a LPCSTR (const char*) only as long as you have not modified the string. you need to make your own copy if you want to use it for ever.
also, in your code TCHAR can be either a char or a wchar_t. if it is a char, a TCHAR* is already an LPSTR. if it is a wchar_t, a TCHAR* would be an LPWSTR. you need to convert from wide to narrow characters to get an LPSTR