How to resolve the compiler error "LPTSTR regSubKey expression must have a class type" in C++

  • Thread starter Thread starter bhavya internship
  • Start date Start date
B

bhavya internship

Guest
Hello All,

In the below function, I am trying to check the ending slash '\\' of the registry path. If it is not present adding the slash.

But I am getting the compiler error "LPTSTR regSubKey expression must have a class type" at the below line:


pathEnd = regSubKey.find_last_of("/\\");

I also tried like as shown below:

if(regSubKey.back() != "/\\")

could someone please help me on this?

Below is the code snippet:

LONG TestReg::DeleteRegistryRecurse(HKEY hKeyRoot, LPTSTR regSubKey)
{
LPTSTR pathEnd;
LONG lResult = 0;
HKEY hKey;
// see if we can delete the key without having to recurse.
lResult = RegDeleteKey(hKeyRoot, regSubKey);
if (lResult == ERROR_SUCCESS)
{
return 0;
}
lResult = RegOpenKeyEx(hKeyRoot, regSubKey, 0, KEY_READ, &hKey);

// Check for an ending slash and add one if it is missing.
pathEnd = regSubKey.find_last_of("/\\");

// if(regSubKey.back() != "/\\")

if (*(pathEnd - 1) != TEXT('\\'))
{
*pathEnd = TEXT('\\');
pathEnd++;
*pathEnd = TEXT('\0');
}
}

Continue reading...
 
Back
Top