I'm trying to locate a list item contained within the Services window (Start->Run->Services.msc) on Windows. The list item is named "Arc Service" and is easily found using Inspect, but my code fails to locate it. This being a relatively simple case, I feel I must be doing something wrong.
The code in question is:
VARIANT arcServiceNameVariant;
VariantInit(&arcServiceNameVariant);
arcServiceNameVariant.vt = VT_BSTR;
arcServiceNameVariant.bstrVal = L"Arc Service";
CComPtr<IUIAutomationCondition> arcServiceNameCondition;
hr = g_pAutomation->CreatePropertyCondition(UIA_NamePropertyId, arcServiceNameVariant, &arcServiceNameCondition.p);
if(SUCCEEDED(hr)) {
CComPtr<IUIAutomationElement> arcServiceElement;
hr = rootElement->FindFirst(TreeScope_Descendants, arcServiceNameCondition, &arcServiceElement.p);
if(SUCCEEDED(hr)) {
if(arcServiceElement.p) {
logInfo(L"Arc Service element found!");
}
} else {
logInfo(L"FindFirst failed!");
}
} else {
logInfo(L"Failed to create property condition!");
}
The "Arc Service element found!" branch is never entered.
Here are the details from Inspect describing the element:
Any assistance would be greatly appreciated. Thanks!
Quizzically it turns out that running my UIA client as Administrator sees the component, but running as the logged in user does not. For now I can elevate my process, but I'll continue to research the issue for a more detailed explanation.