[NETCFGX] Read a components bind value and implement the IsBoundTo method.

This commit is contained in:
Eric Kohl 2019-06-20 22:02:18 +02:00
parent 84c20018e6
commit 73ca084e96
3 changed files with 67 additions and 1 deletions

View file

@ -92,7 +92,35 @@ INetCfgComponentBindings_fnIsBoundTo(
INetCfgComponentBindings *iface,
INetCfgComponent *pnccItem)
{
return E_NOTIMPL;
INetCfgComponentImpl *pComponent;
PWSTR pszBindName, ptr;
INT len;
pComponent = impl_from_INetCfgComponentBindings(iface);
if (pComponent == NULL ||
pComponent->pItem == NULL ||
pComponent->pItem->pszBinding == NULL)
return E_POINTER;
if (pnccItem == NULL ||
((INetCfgComponentImpl*)pnccItem)->pItem == NULL ||
((INetCfgComponentImpl*)pnccItem)->pItem->szBindName == NULL)
return E_POINTER;
pszBindName = ((INetCfgComponentImpl*)pnccItem)->pItem->szBindName;
ptr = pComponent->pItem->pszBinding;
while (*ptr != UNICODE_NULL)
{
len = wcslen(ptr);
if (len > 8 && _wcsicmp(&ptr[8], pszBindName) == 0)
return S_OK;
ptr = ptr + len + 1;
}
return S_FALSE;
}
HRESULT

View file

@ -226,6 +226,41 @@ static const INetCfgPnpReconfigCallbackVtbl vt_NetCfgPnpReconfigCallback =
* INetCfg
*/
HRESULT
ReadBindingString(
NetCfgComponentItem *Item)
{
WCHAR szBuffer[200];
HKEY hKey;
DWORD dwType, dwSize;
if (Item == NULL || Item->szBindName == NULL)
return S_OK;
wcscpy(szBuffer, L"SYSTEM\\CurrentControlSet\\Services\\");
wcscat(szBuffer, Item->szBindName);
wcscat(szBuffer, L"\\Linkage");
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
dwSize = 0;
RegQueryValueExW(hKey, L"Bind", NULL, &dwType, NULL, &dwSize);
if (dwSize != 0)
{
Item->pszBinding = CoTaskMemAlloc(dwSize);
if (Item->pszBinding == NULL)
return E_OUTOFMEMORY;
RegQueryValueExW(hKey, L"Bind", NULL, &dwType, (LPBYTE)Item->pszBinding, &dwSize);
}
RegCloseKey(hKey);
}
return S_OK;
}
HRESULT
EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem ** pHead)
{
@ -324,6 +359,8 @@ EnumClientServiceProtocol(HKEY hKey, const GUID * pGuid, NetCfgComponentItem **
}
RegCloseKey(hSubKey);
ReadBindingString(pCurrent);
if (!pLast)
*pHead = pCurrent;
else

View file

@ -47,6 +47,7 @@ typedef struct tagNetCfgComponentItem
DWORD dwCharacteristics; //Y
ULONG Status; //Y
BOOL bChanged; //Y
LPWSTR pszBinding;
struct tagNetCfgComponentItem * pNext;
INetCfgComponentControl * pNCCC;
}NetCfgComponentItem;