| 191 | unsigned long hash_setting(unsigned char *str); |
| 192 | |
| 193 | BOOL LoadWindowPositionFromXML(WINDOWPLACEMENT *pwndpl) |
| 194 | { |
| 195 | wil::com_ptr<IXMLDOMDocument> pXMLDom; |
| 196 | pXMLDom.attach(NXMLSettings::DomFromCOM()); |
| 197 | |
| 198 | if (!pXMLDom) |
| 199 | { |
| 200 | return FALSE; |
| 201 | } |
| 202 | |
| 203 | TCHAR szConfigFile[MAX_PATH]; |
| 204 | GetProcessImageName(GetCurrentProcessId(),szConfigFile, SIZEOF_ARRAY(szConfigFile)); |
| 205 | PathRemoveFileSpec(szConfigFile); |
| 206 | PathAppend(szConfigFile, NExplorerplusplus::XML_FILENAME); |
| 207 | |
| 208 | wil::unique_variant var(NXMLSettings::VariantString(szConfigFile)); |
| 209 | VARIANT_BOOL status; |
| 210 | pXMLDom->load(var, &status); |
| 211 | |
| 212 | if (status != VARIANT_TRUE) |
| 213 | { |
| 214 | return FALSE; |
| 215 | } |
| 216 | |
| 217 | wil::com_ptr<IXMLDOMNodeList> pNodes; |
| 218 | auto bstr = wil::make_bstr(L"//WindowPosition/*"); |
| 219 | pXMLDom->selectNodes(bstr.get(), &pNodes); |
| 220 | |
| 221 | if(!pNodes) |
| 222 | { |
| 223 | return FALSE; |
| 224 | } |
| 225 | |
| 226 | pwndpl->length = sizeof(WINDOWPLACEMENT); |
| 227 | |
| 228 | long length; |
| 229 | pNodes->get_length(&length); |
| 230 | |
| 231 | /* There should only be one node |
| 232 | under 'WindowPosition'. */ |
| 233 | if (length != 1) |
| 234 | { |
| 235 | return FALSE; |
| 236 | } |
| 237 | |
| 238 | wil::com_ptr<IXMLDOMNode> pNode; |
| 239 | pNodes->get_item(0, &pNode); |
| 240 | |
| 241 | wil::com_ptr<IXMLDOMNamedNodeMap> am; |
| 242 | HRESULT hr = pNode->get_attributes(&am); |
| 243 | |
| 244 | if(SUCCEEDED(hr)) |
| 245 | { |
| 246 | long nChildNodes; |
| 247 | am->get_length(&nChildNodes); |
| 248 | |
| 249 | for(long i = 1; i < nChildNodes; i++) |
| 250 | { |
no test coverage detected