This is probably a novice question but I am not very good at C++ and still an early beginner. MY question is how do I strip bk any trailing backslashes from a char:
extern "C" UINT __stdcall DeleteTrailingBackslash(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
LPWSTR szValueBuf = NULL;
char szInstallPath[MAX_PATH];
hr = WcaInitialize(hInstall, "DeleteTrailingBackslash");
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
hr = WcaGetProperty(L"INSTALLLOCATION",&szValueBuf);
ExitOnFailure(hr, "failed to get Install Location");
wcstombs(szInstallPath, szValueBuf, 260);
// I would like to strip back the trailing backslashes
// and re add the property to my MSI
hr = MsiSetProperty(hInstall, "INSTALLLOCATION", szInstallPath);
ExitOnFailure(hr, "failed to set the install location");
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
szInstallPath
could have either none, one or two backslashes, I need to remove backslashes if there are any. Can anyone point me in the right direction please for good website tutorials or anything?
Thanks