这可能是一个新手问题,但我不太擅长 C++,而且还是一个早期初学者。我的问题是如何从字符中删除 bk 任何尾随反斜杠:
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
可能没有,一个或两个反斜杠,如果有的话,我需要删除反斜杠。任何人都可以为我指出正确的方向,以获得好的网站教程或任何东西吗?
谢谢