Trying to delete registry keys and having a problem with the code I have been working with. The address on MSDN below has an example and I've modified it to work except for one part.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724235(v=vs.85).aspx

// Check for an ending slash and add one if it is missing. lpEnd = lpSubKey + lstrlen(lpSubKey); if (*(lpEnd - 1) != TEXT('\\')) { *lpEnd = TEXT('\\'); // This line crashes the app lpEnd++; *lpEnd = TEXT('\0'); // This one crashes too }

I'm not sure how to start debugging, but I also don't understand why this is failing.