Remove pathcch dependency (#13646)
This commit is contained in:
parent
a560a9cb51
commit
407e1ca136
2 changed files with 34 additions and 2 deletions
|
@ -31,7 +31,6 @@ target_link_libraries(Finalizer shell32.lib)
|
||||||
target_link_libraries(Finalizer advapi32.lib)
|
target_link_libraries(Finalizer advapi32.lib)
|
||||||
target_link_libraries(Finalizer version.lib)
|
target_link_libraries(Finalizer version.lib)
|
||||||
target_link_libraries(Finalizer msi.lib)
|
target_link_libraries(Finalizer msi.lib)
|
||||||
target_link_libraries(Finalizer pathcch.lib)
|
|
||||||
|
|
||||||
# Add WiX libraries
|
# Add WiX libraries
|
||||||
target_link_libraries(Finalizer wcautil.lib)
|
target_link_libraries(Finalizer wcautil.lib)
|
||||||
|
|
|
@ -38,6 +38,39 @@ LExit:
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" HRESULT StrTrimBackslash(LPWSTR* ppwz, LPCWSTR wzSource)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
LPWSTR sczResult = NULL;
|
||||||
|
|
||||||
|
int i = lstrlenW(wzSource);
|
||||||
|
|
||||||
|
if (0 < i)
|
||||||
|
{
|
||||||
|
for (i = i - 1; i > 0; --i)
|
||||||
|
{
|
||||||
|
if (L'\\' != wzSource[i])
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = StrAllocString(&sczResult, wzSource, i);
|
||||||
|
ExitOnFailure(hr, "Failed to copy result string");
|
||||||
|
|
||||||
|
// Output result
|
||||||
|
*ppwz = sczResult;
|
||||||
|
sczResult = NULL;
|
||||||
|
|
||||||
|
LExit:
|
||||||
|
ReleaseStr(sczResult);
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" HRESULT DeleteWorkloadRecords(LPWSTR sczSdkFeatureBandVersion, LPWSTR sczArchitecture)
|
extern "C" HRESULT DeleteWorkloadRecords(LPWSTR sczSdkFeatureBandVersion, LPWSTR sczArchitecture)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
@ -112,7 +145,7 @@ extern "C" HRESULT DeleteWorkloadRecords(LPWSTR sczSdkFeatureBandVersion, LPWSTR
|
||||||
ExitOnFailure(hr, "Failed to get size of key name.");
|
ExitOnFailure(hr, "Failed to get size of key name.");
|
||||||
|
|
||||||
// Need to remove trailing backslash otherwise PathFile returns an empty string.
|
// Need to remove trailing backslash otherwise PathFile returns an empty string.
|
||||||
hr = PathCchRemoveBackslash(sczKeyName, cbKeyName);
|
hr = StrTrimBackslash(&sczKeyName, sczKeyName);
|
||||||
ExitOnFailure(hr, "Failed to remove backslash.");
|
ExitOnFailure(hr, "Failed to remove backslash.");
|
||||||
|
|
||||||
hr = StrAllocString(&sczSubKey, PathFile(sczKeyName), 0);
|
hr = StrAllocString(&sczSubKey, PathFile(sczKeyName), 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue