diff --git a/res/msi/CustomActions/CustomActions.cpp b/res/msi/CustomActions/CustomActions.cpp index f53a910a9..50ab020f0 100644 --- a/res/msi/CustomActions/CustomActions.cpp +++ b/res/msi/CustomActions/CustomActions.cpp @@ -1021,10 +1021,9 @@ UINT __stdcall InstallPrinter( DWORD er = ERROR_SUCCESS; int nResult = 0; - LPWSTR installFolder = NULL; - LPWSTR appName = NULL; - LPWSTR pwz = NULL; LPWSTR pwzData = NULL; + std::wstring appNameValue; + std::wstring installFolderValue; hr = WcaInitialize(hInstall, "InstallPrinter"); ExitOnFailure(hr, "Failed to initialize"); @@ -1032,25 +1031,30 @@ UINT __stdcall InstallPrinter( hr = WcaGetProperty(L"CustomActionData", &pwzData); ExitOnFailure(hr, "failed to get CustomActionData"); - pwz = pwzData; - hr = WcaReadStringFromCaData(&pwz, &installFolder); - ExitOnFailure(hr, "failed to read database key from custom action data: %ls", pwz); - - // Names the printer. Optional, so that a package built before this was passed in - // still installs, keeping the stock printer name. - if (FAILED(WcaReadStringFromCaData(&pwz, &appName))) + // "|". Split here rather than through + // WcaReadStringFromCaData, whose delimiter is a literal wide char 128 that a + // Formatted property value cannot carry. { - ReleaseNullStr(appName); + std::wstring data(pwzData); + size_t separator = data.find(L'|'); + if (separator == std::wstring::npos) + { + // A package built before the name was passed in; keep the stock name. + appNameValue.clear(); + installFolderValue = data; + } + else + { + appNameValue = data.substr(0, separator); + installFolderValue = data.substr(separator + 1); + } } - WcaLog(LOGMSG_STANDARD, "Try to install RD printer in : %ls", installFolder); - RemotePrinter::installUpdatePrinter(installFolder, appName ? appName : L""); + WcaLog(LOGMSG_STANDARD, "Try to install RD printer in : %ls", installFolderValue.c_str()); + RemotePrinter::installUpdatePrinter(installFolderValue, appNameValue); WcaLog(LOGMSG_STANDARD, "Install RD printer done"); LExit: - if (appName) { - ReleaseStr(appName); - } if (pwzData) { ReleaseStr(pwzData); } @@ -1065,32 +1069,24 @@ UINT __stdcall UninstallPrinter( HRESULT hr = S_OK; DWORD er = ERROR_SUCCESS; - LPWSTR appName = NULL; - LPWSTR pwz = NULL; LPWSTR pwzData = NULL; + std::wstring appNameValue; hr = WcaInitialize(hInstall, "UninstallPrinter"); ExitOnFailure(hr, "Failed to initialize"); // Must match the name install used, otherwise the printer is left behind. Absent // on packages built before this was passed in, where it was the stock name. - if (SUCCEEDED(WcaGetProperty(L"CustomActionData", &pwzData))) + if (SUCCEEDED(WcaGetProperty(L"CustomActionData", &pwzData)) && pwzData) { - pwz = pwzData; - if (FAILED(WcaReadStringFromCaData(&pwz, &appName))) - { - ReleaseNullStr(appName); - } + appNameValue = pwzData; } WcaLog(LOGMSG_STANDARD, "Try to uninstall RD printer"); - RemotePrinter::uninstallPrinter(appName ? appName : L""); + RemotePrinter::uninstallPrinter(appNameValue); WcaLog(LOGMSG_STANDARD, "Uninstall RD printer done"); LExit: - if (appName) { - ReleaseStr(appName); - } if (pwzData) { ReleaseStr(pwzData); } diff --git a/res/msi/Package/Components/RustDesk.wxs b/res/msi/Package/Components/RustDesk.wxs index 3e77e76d1..3041c6099 100644 --- a/res/msi/Package/Components/RustDesk.wxs +++ b/res/msi/Package/Components/RustDesk.wxs @@ -30,9 +30,13 @@ - - + +