Asger Ottar Alstrup wrote:
But the problem is that I can not make diffs for some reason. It just hangs and hangs. Does anybody else experience this problem? CVS is soo slow today.
What CVS client do you use? I've been using TortoiseCVS and it seems to work well.
Me too. It has been hanging for more than two hours. No progress, no errors, no diff.
In this nastiness below, I tried to convert a LPTSTR object to an LPCSTR one so that I could add it to a larger string.
However, I find that 1. I can't because the T2CA macro is an AFX thingie and I don't have that installed. 2. I don't need to anyway, because LPTSTR is already char-based.
When is LPTSTR wchar_t-based and what would I need to do were that the case?
LPTSTR is a long pointer to a _TCHAR based zero-terminated string. _TCHAR is 8-bit or 16-bit depending on which run-time library you link against. If you define _UNICODE, it will be 16-bit. If you define _MBCS, it will be 8-bit.
The AFX thing is MFC-related.
To do what you are trying to do, just use this, provided you are using the multi-byte runtime:
std::string getFormatErrorMessage() { LONG error = ::GetLastError(); HLOCAL lpMsgBuf = 0; bool ok = ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL ) != 0;
if ( ok ) { std::string retValue( (LPTSTR) lpMsgBuf ); // Free the buffer. ::LocalFree( lpMsgBuf ); return retValue; } else { std::stringstream s; s << "Unknown error: " << error << std::endl; return s.str(); } }
Regards, Asger