[NETSHELL] Return error if disconnection failed

CORE-12307
This commit is contained in:
Hervé Poussineau 2022-09-26 23:33:16 +02:00
parent 2469ce2c31
commit 5eeeb1c235
1 changed files with 6 additions and 2 deletions

View File

@ -135,9 +135,10 @@ CNetConnection::Disconnect()
PropChangeParams.Scope = DICS_FLAG_CONFIGSPECIFIC;
PropChangeParams.HwProfile = 0;
if (SetupDiSetClassInstallParams(hInfo, &DevInfo, &PropChangeParams.ClassInstallHeader, sizeof(SP_PROPCHANGE_PARAMS)))
if (!SetupDiSetClassInstallParams(hInfo, &DevInfo, &PropChangeParams.ClassInstallHeader, sizeof(SP_PROPCHANGE_PARAMS)) ||
!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hInfo, &DevInfo))
{
SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hInfo, &DevInfo);
hr = HRESULT_FROM_WIN32(GetLastError());
}
}
SetupDiDestroyDeviceInfoList(hInfo);
@ -145,6 +146,9 @@ CNetConnection::Disconnect()
swprintf(szPath, L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", pDisplayName);
CoTaskMemFree(pDisplayName);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
return E_FAIL;