Take the tour ×  I am attempting to convert a LPTSTR variable to
tstring(ie, wstring in a unicode application and string in
ANSI).  How do I perform this conversion?  My code attempts to
perform the conversion but it causes the error: "Debug Assertion
Failed! Expression: invalid null pointer":  #ifdef UNICODE
#define tstring std::wstring   #define tstring std::string
tstring TVManager::getDevicePropertyTEST(HDEVINFO hDevInfo,
SP_DEVINFO_DATA deviceInfoData, DWORD flag)     DWORD dataT
= 0;     DWORD buffersize = 0;     LPTSTR buffer    = NULL;
while (!SetupDiGetDeviceRegistryProperty(hDevInfo,
&deviceInfoData, flag, &dataT,
(PBYTE)buffer, buffersize, &buffersize))         if
(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {             //
Change the buffer size.             if (buffer)
buffer = (LPTSTR)LocalAlloc(LPTR, buffersize);         else {
// Insert error handling here.             debug_print_ex("Else
happened:", buffe