Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

758 lines
22 KiB

  1. //////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // ApplicationManagerAdmin.cpp
  4. //
  5. // Copyright (C) 1998, 1999 Microsoft Corporation. All rights reserved.
  6. //
  7. // Abstract :
  8. //
  9. // This is the implementation of IApplicationManagerAdmin
  10. //
  11. // History :
  12. //
  13. // 05/06/1999 luish Created
  14. //
  15. //////////////////////////////////////////////////////////////////////////////////////////////
  16. #include <assert.h>
  17. #include "AppMan.h"
  18. #include "AppManAdmin.h"
  19. #include "ApplicationManager.h"
  20. #include "AppManDebug.h"
  21. #include "ExceptionHandler.h"
  22. #include "RegistryKey.h"
  23. //To flag as DBG_APPMANADMIN
  24. #ifdef DBG_MODULE
  25. #undef DBG_MODULE
  26. #endif
  27. #define DBG_MODULE DBG_APPMANADMIN
  28. //////////////////////////////////////////////////////////////////////////////////////////////
  29. //
  30. //////////////////////////////////////////////////////////////////////////////////////////////
  31. CApplicationManagerAdmin::CApplicationManagerAdmin(void)
  32. {
  33. FUNCTION("CApplicationManagerAdmin::CApplicationManagerAdmin (void)");
  34. }
  35. //////////////////////////////////////////////////////////////////////////////////////////////
  36. //
  37. //////////////////////////////////////////////////////////////////////////////////////////////
  38. CApplicationManagerAdmin::CApplicationManagerAdmin(CApplicationManagerRoot * lpParent)
  39. {
  40. FUNCTION("CApplicationManagerAdmin::CApplicationManagerAdmin (CApplicationManagerRoot *pParent)");
  41. assert(NULL != lpParent);
  42. m_pParentObject = lpParent;
  43. m_InformationManager.Initialize();
  44. }
  45. //////////////////////////////////////////////////////////////////////////////////////////////
  46. //
  47. //////////////////////////////////////////////////////////////////////////////////////////////
  48. CApplicationManagerAdmin::~CApplicationManagerAdmin(void)
  49. {
  50. FUNCTION("CApplicationManagerAdmin::~CApplicationManagerAdmin (void)");
  51. }
  52. //////////////////////////////////////////////////////////////////////////////////////////////
  53. //
  54. //////////////////////////////////////////////////////////////////////////////////////////////
  55. STDMETHODIMP CApplicationManagerAdmin::QueryInterface(REFIID RefIID, LPVOID * lppVoidObject)
  56. {
  57. FUNCTION("CApplicationManagerAdmin::QueryInterface ()");
  58. if (NULL == m_pParentObject)
  59. {
  60. return E_NOINTERFACE;
  61. }
  62. return m_pParentObject->QueryInterface(RefIID, lppVoidObject);
  63. }
  64. //////////////////////////////////////////////////////////////////////////////////////////////
  65. //
  66. //////////////////////////////////////////////////////////////////////////////////////////////
  67. STDMETHODIMP_(ULONG) CApplicationManagerAdmin::AddRef(void)
  68. {
  69. FUNCTION("CApplicationManagerAdmin::AddRef ()");
  70. if (NULL != m_pParentObject)
  71. {
  72. return m_pParentObject->AddRef();
  73. }
  74. return 0;
  75. }
  76. //////////////////////////////////////////////////////////////////////////////////////////////
  77. //
  78. //////////////////////////////////////////////////////////////////////////////////////////////
  79. STDMETHODIMP_(ULONG) CApplicationManagerAdmin::Release(void)
  80. {
  81. FUNCTION("CApplicationManagerAdmin::Release ()");
  82. if (NULL != m_pParentObject)
  83. {
  84. return m_pParentObject->Release();
  85. }
  86. return 0;
  87. }
  88. //////////////////////////////////////////////////////////////////////////////////////////////
  89. //
  90. //////////////////////////////////////////////////////////////////////////////////////////////
  91. STDMETHODIMP CApplicationManagerAdmin::EnumerateDevices(const DWORD dwIndex, GUID * lpGuid)
  92. {
  93. FUNCTION("CApplicationManagerAdmin::EnumerateDevices ()");
  94. HRESULT hResult = E_FAIL;
  95. DEVICE_RECORD sDeviceRecord;
  96. ///////////////////////////////////////////////////////////////////////////////////////
  97. try
  98. {
  99. //
  100. // Enumerate devices. Get the device GUID for device record at dwIndex
  101. //
  102. if (S_OK == m_InformationManager.CheckDeviceExistance(dwIndex))
  103. {
  104. hResult = m_InformationManager.GetDeviceInfoWithIndex(dwIndex, &sDeviceRecord);
  105. if (SUCCEEDED(hResult))
  106. {
  107. memcpy(lpGuid, &(sDeviceRecord.sDeviceGuid), sizeof(GUID));
  108. }
  109. }
  110. }
  111. ///////////////////////////////////////////////////////////////////////////////////////
  112. catch(CAppManExceptionHandler * pException)
  113. {
  114. hResult = pException->GetResultCode();
  115. delete pException;
  116. }
  117. catch(...)
  118. {
  119. hResult = E_UNEXPECTED;
  120. }
  121. return hResult;
  122. }
  123. //////////////////////////////////////////////////////////////////////////////////////////////
  124. //
  125. //////////////////////////////////////////////////////////////////////////////////////////////
  126. STDMETHODIMP CApplicationManagerAdmin::GetDeviceProperty(const DWORD dwProperty, const GUID * lpGuid, LPVOID lpData, const DWORD /*dwDataLen*/) // Get rid of /W4 warning.
  127. {
  128. FUNCTION("CApplicationManagerAdmin::GetDeviceProperty ()");
  129. HRESULT hResult = S_OK;
  130. ///////////////////////////////////////////////////////////////////////////////////////
  131. try
  132. {
  133. DEVICE_RECORD sDeviceRecord = {0};
  134. DEVICE_SPACE_INFO sDeviceSpaceInfo = {0};
  135. //
  136. // Prefetch the device information
  137. //
  138. ZeroMemory(&sDeviceRecord, sizeof(sDeviceRecord));
  139. memcpy(&(sDeviceRecord.sDeviceGuid), lpGuid, sizeof(GUID));
  140. hResult = m_InformationManager.GetDeviceInfo(&sDeviceRecord);
  141. if (SUCCEEDED(hResult))
  142. {
  143. hResult = m_InformationManager.GetDeviceSpaceInfoWithIndex(sDeviceRecord.sDeviceInfo.dwDeviceIndex, &sDeviceSpaceInfo);
  144. if (SUCCEEDED(hResult))
  145. {
  146. hResult = m_InformationManager.GetDeviceInfo(&sDeviceRecord);
  147. }
  148. }
  149. if (SUCCEEDED(hResult))
  150. {
  151. switch(dwProperty)
  152. {
  153. case DEVICE_PROPERTY_TOTALKILOBYTES
  154. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwTotalKilobytes;
  155. break;
  156. case DEVICE_PROPERTY_TOTALFREEKILOBYTES
  157. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwTotalFreeKilobytes;
  158. break;
  159. case DEVICE_PROPERTY_TOTALAVAILABLEKILOBYTES
  160. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwMaximumUsableKilobytes;
  161. break;
  162. case DEVICE_PROPERTY_OPTIMALAVAILABLEKILOBYTES
  163. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwOptimalUsableKilobytes;
  164. break;
  165. case DEVICE_PROPERTY_REMOVABLEKILOBYTES
  166. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwTotalRemovableKilobytes;
  167. break;
  168. case DEVICE_PROPERTY_NONREMOVABLEKILOBYTES
  169. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwTotalNonRemovableKilobytes;
  170. break;
  171. case DEVICE_PROPERTY_RESERVEDKILOBYTES
  172. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwTotalReservedKilobytes;
  173. break;
  174. case DEVICE_PROPERTY_TOTALTEMPORARYKILOBYTES
  175. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwTotalReservedTemporaryKilobytes;
  176. break;
  177. case DEVICE_PROPERTY_USEDTEMPORARYKILOBYTES
  178. : *(LPDWORD)lpData = sDeviceSpaceInfo.dwTotalUsedTemporaryKilobytes;
  179. break;
  180. case DEVICE_PROPERTY_PERCENTCACHESIZE
  181. : *(LPDWORD)lpData = sDeviceRecord.sDeviceInfo.dwPercentCacheSize;
  182. break;
  183. case DEVICE_PROPERTY_PERCENTMINIMUMFREESIZE
  184. : *(LPDWORD)lpData = sDeviceRecord.sDeviceInfo.dwPercentMinimumFreeSize;
  185. break;
  186. case DEVICE_PROPERTY_EXCLUSIONMASK
  187. : *(LPDWORD)lpData = sDeviceRecord.sDeviceInfo.dwApplicationCategoryExclusionMask;
  188. break;
  189. default
  190. : THROW(APPMANADMIN_E_INVALIDPROPERTY);
  191. break;
  192. }
  193. }
  194. }
  195. ///////////////////////////////////////////////////////////////////////////////////////
  196. catch(CAppManExceptionHandler * pException)
  197. {
  198. hResult = pException->GetResultCode();
  199. delete pException;
  200. }
  201. catch(...)
  202. {
  203. hResult = E_UNEXPECTED;
  204. }
  205. return hResult;
  206. }
  207. //////////////////////////////////////////////////////////////////////////////////////////////
  208. //
  209. //////////////////////////////////////////////////////////////////////////////////////////////
  210. STDMETHODIMP CApplicationManagerAdmin::SetDeviceProperty(const DWORD dwProperty, const GUID * lpGuid, LPVOID lpData, const DWORD /*dwDataLen*/) // Get rid of /W4 warning.
  211. {
  212. FUNCTION("CApplicationManagerAdmin::SetDeviceProperty ()");
  213. HRESULT hResult = S_OK;
  214. ///////////////////////////////////////////////////////////////////////////////////////
  215. try
  216. {
  217. DEVICE_RECORD sDeviceRecord;
  218. ZeroMemory(&sDeviceRecord, sizeof(sDeviceRecord));
  219. memcpy(&(sDeviceRecord.sDeviceGuid), lpGuid, sizeof(GUID));
  220. hResult = m_InformationManager.GetDeviceInfo(&sDeviceRecord);
  221. if (SUCCEEDED(hResult))
  222. {
  223. switch(dwProperty)
  224. {
  225. case DEVICE_PROPERTY_TOTALKILOBYTES:
  226. case DEVICE_PROPERTY_TOTALFREEKILOBYTES:
  227. case DEVICE_PROPERTY_TOTALAVAILABLEKILOBYTES:
  228. case DEVICE_PROPERTY_OPTIMALAVAILABLEKILOBYTES:
  229. case DEVICE_PROPERTY_REMOVABLEKILOBYTES:
  230. case DEVICE_PROPERTY_NONREMOVABLEKILOBYTES:
  231. case DEVICE_PROPERTY_RESERVEDKILOBYTES:
  232. case DEVICE_PROPERTY_TOTALTEMPORARYKILOBYTES:
  233. case DEVICE_PROPERTY_USEDTEMPORARYKILOBYTES
  234. : THROW(APPMANADMIN_E_READONLYPROPERTY);
  235. break;
  236. case DEVICE_PROPERTY_PERCENTCACHESIZE
  237. : sDeviceRecord.sDeviceInfo.dwPercentCacheSize = (DWORD) *((LPDWORD) lpData);
  238. if (100 < sDeviceRecord.sDeviceInfo.dwPercentCacheSize)
  239. {
  240. if (0xffffffff == sDeviceRecord.sDeviceInfo.dwPercentCacheSize)
  241. {
  242. CRegistryKey sRegistryKey;
  243. DWORD dwType, dwSize;
  244. sRegistryKey.OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppMan", KEY_ALL_ACCESS);
  245. sDeviceRecord.sDeviceInfo.dwPercentCacheSize = DEFAULT_PERCENT_CACHE_SIZE;
  246. if (S_OK == sRegistryKey.CheckForExistingValue("DefaultPercentCacheSize"))
  247. {
  248. dwSize = sizeof(sDeviceRecord.sDeviceInfo.dwPercentCacheSize);
  249. sRegistryKey.GetValue("DefaultPercentCacheSize", &dwType, (LPBYTE) &sDeviceRecord.sDeviceInfo.dwPercentCacheSize, &dwSize);
  250. }
  251. //
  252. // Is the registry value corrupt
  253. //
  254. if (100 < sDeviceRecord.sDeviceInfo.dwPercentCacheSize)
  255. {
  256. sDeviceRecord.sDeviceInfo.dwPercentCacheSize = DEFAULT_PERCENT_CACHE_SIZE;
  257. sRegistryKey.SetValue("DefaultPercentCacheSize", REG_DWORD, (const BYTE *) &sDeviceRecord.sDeviceInfo.dwPercentCacheSize, sizeof(sDeviceRecord.sDeviceInfo.dwPercentCacheSize));
  258. }
  259. }
  260. else
  261. {
  262. THROW(APPMAN_E_INVALIDPROPERTYVALUE);
  263. }
  264. }
  265. hResult = m_InformationManager.SetDeviceInfoWithIndex(sDeviceRecord.sDeviceInfo.dwDeviceIndex, &sDeviceRecord);
  266. break;
  267. case DEVICE_PROPERTY_PERCENTMINIMUMFREESIZE
  268. : sDeviceRecord.sDeviceInfo.dwPercentMinimumFreeSize = (DWORD) *((LPDWORD) lpData);
  269. if (100 < sDeviceRecord.sDeviceInfo.dwPercentMinimumFreeSize)
  270. {
  271. THROW(APPMAN_E_INVALIDPROPERTYVALUE);
  272. }
  273. hResult = m_InformationManager.SetDeviceInfoWithIndex(sDeviceRecord.sDeviceInfo.dwDeviceIndex, &sDeviceRecord);
  274. break;
  275. case DEVICE_PROPERTY_EXCLUSIONMASK
  276. : sDeviceRecord.sDeviceInfo.dwApplicationCategoryExclusionMask &= ~DEVICE_EXCLUSION_MASK;
  277. sDeviceRecord.sDeviceInfo.dwApplicationCategoryExclusionMask |= (DWORD) *((LPDWORD) lpData);
  278. hResult = m_InformationManager.SetDeviceInfoWithIndex(sDeviceRecord.sDeviceInfo.dwDeviceIndex, &sDeviceRecord);
  279. break;
  280. default
  281. : THROW(APPMANADMIN_E_INVALIDPROPERTY);
  282. break;
  283. }
  284. }
  285. }
  286. ///////////////////////////////////////////////////////////////////////////////////////
  287. catch(CAppManExceptionHandler * pException)
  288. {
  289. hResult = pException->GetResultCode();
  290. delete pException;
  291. }
  292. catch(...)
  293. {
  294. hResult = E_UNEXPECTED;
  295. }
  296. return hResult;
  297. }
  298. //////////////////////////////////////////////////////////////////////////////////////////////
  299. //
  300. //////////////////////////////////////////////////////////////////////////////////////////////
  301. STDMETHODIMP CApplicationManagerAdmin::GetAppManProperty(const DWORD dwProperty, LPVOID lpData, const DWORD /*dwDataLen*/)
  302. {
  303. FUNCTION("CApplicationManagerAdmin::GetAppManProperty ()");
  304. HRESULT hResult = S_OK;
  305. ///////////////////////////////////////////////////////////////////////////////////////
  306. try
  307. {
  308. DWORD dwMaxKilobytes = 0, dwOptimalKilobytes = 0, dwAdvancedMode = 0;
  309. //
  310. // Prefetch some of the global information
  311. //
  312. hResult = m_InformationManager.GetMaximumAvailableSpace(APP_CATEGORY_ENTERTAINMENT, &dwMaxKilobytes);
  313. if (SUCCEEDED(hResult))
  314. {
  315. hResult = m_InformationManager.GetOptimalAvailableSpace(APP_CATEGORY_ENTERTAINMENT, &dwOptimalKilobytes);
  316. if (SUCCEEDED(hResult))
  317. {
  318. hResult = m_InformationManager.GetAdvancedMode(&dwAdvancedMode);
  319. }
  320. }
  321. if (SUCCEEDED(hResult))
  322. {
  323. switch(dwProperty)
  324. {
  325. case APPMAN_PROPERTY_TOTALKILOBYTES
  326. : *(LPDWORD)lpData = dwMaxKilobytes;
  327. break;
  328. case APPMAN_PROPERTY_OPTIMALKILOBYTES
  329. : *(LPDWORD)lpData = dwOptimalKilobytes;
  330. break;
  331. case APPMAN_PROPERTY_ADVANCEDMODE
  332. : *(LPDWORD)lpData = dwAdvancedMode;
  333. break;
  334. default
  335. : THROW(APPMANADMIN_E_INVALIDPROPERTY);
  336. break;
  337. }
  338. }
  339. }
  340. ///////////////////////////////////////////////////////////////////////////////////////
  341. catch(CAppManExceptionHandler * pException)
  342. {
  343. hResult = pException->GetResultCode();
  344. delete pException;
  345. }
  346. catch(...)
  347. {
  348. hResult = E_UNEXPECTED;
  349. }
  350. return hResult;
  351. }
  352. //////////////////////////////////////////////////////////////////////////////////////////////
  353. //
  354. //////////////////////////////////////////////////////////////////////////////////////////////
  355. STDMETHODIMP CApplicationManagerAdmin::SetAppManProperty(const DWORD dwProperty, LPCVOID lpData, const DWORD /*dwDataLen*/)
  356. {
  357. FUNCTION("CApplicationManagerAdmin::SetAppManProperty()");
  358. HRESULT hResult = S_OK;
  359. ///////////////////////////////////////////////////////////////////////////////////////
  360. try
  361. {
  362. if (APPMAN_PROPERTY_ADVANCEDMODE == dwProperty)
  363. {
  364. hResult = m_InformationManager.SetAdvancedMode((DWORD) *((LPDWORD) lpData));
  365. }
  366. }
  367. ///////////////////////////////////////////////////////////////////////////////////////
  368. catch(CAppManExceptionHandler * pException)
  369. {
  370. hResult = pException->GetResultCode();
  371. delete pException;
  372. }
  373. catch(...)
  374. {
  375. hResult = E_UNEXPECTED;
  376. }
  377. return hResult;
  378. }
  379. //////////////////////////////////////////////////////////////////////////////////////////////
  380. //
  381. //////////////////////////////////////////////////////////////////////////////////////////////
  382. STDMETHODIMP CApplicationManagerAdmin::CreateApplicationEntry(IApplicationEntry ** ppObject)
  383. {
  384. FUNCTION("CApplicationManagerAdmin::CreateApplicationEntry ()");
  385. HRESULT hResult = S_OK;
  386. ///////////////////////////////////////////////////////////////////////////////////////
  387. try
  388. {
  389. *ppObject = (IApplicationEntry *) new CApplicationEntry;
  390. hResult = ((CApplicationEntry *) *ppObject)->Initialize();
  391. }
  392. ///////////////////////////////////////////////////////////////////////////////////////
  393. catch(CAppManExceptionHandler * pException)
  394. {
  395. //
  396. // Get Result code
  397. //
  398. hResult = pException->GetResultCode();
  399. //
  400. // Make sure we clean up and delete the CApplicationEntry object
  401. //
  402. delete ((CApplicationEntry *) *ppObject);
  403. *ppObject = NULL;
  404. //
  405. // Delete exception handler
  406. //
  407. delete pException;
  408. }
  409. catch(...)
  410. {
  411. //
  412. // Make sure we clean up and delete the CApplicationEntry object
  413. //
  414. delete ((CApplicationEntry *) *ppObject);
  415. *ppObject = NULL;
  416. //
  417. // If we failed to handle an exception, we default to APPMAN_E_CRITICALERROR
  418. //
  419. hResult = E_UNEXPECTED;
  420. }
  421. ///////////////////////////////////////////////////////////////////////////////////////
  422. return hResult;
  423. }
  424. //////////////////////////////////////////////////////////////////////////////////////////////
  425. //
  426. //////////////////////////////////////////////////////////////////////////////////////////////
  427. STDMETHODIMP CApplicationManagerAdmin::GetApplicationInfo(IApplicationEntry * lpObject)
  428. {
  429. FUNCTION("CApplicationManagerAdmin::GetApplicationInfo ()");
  430. HRESULT hResult = S_OK;
  431. ///////////////////////////////////////////////////////////////////////////////////////
  432. try
  433. {
  434. //
  435. // Check to make sure the pointer we receive is good
  436. //
  437. if ((NULL == lpObject)||(IsBadReadPtr(lpObject, sizeof(CApplicationEntry))))
  438. {
  439. THROW(E_INVALIDARG);
  440. }
  441. hResult = m_InformationManager.GetApplicationData(((CApplicationEntry *) lpObject)->GetApplicationDataPtr());
  442. if (SUCCEEDED(hResult))
  443. {
  444. ((CApplicationEntry *) lpObject)->SetInitializationLevel(INIT_LEVEL_TOTAL);
  445. }
  446. }
  447. ///////////////////////////////////////////////////////////////////////////////////////
  448. catch(CAppManExceptionHandler * pException)
  449. {
  450. //
  451. // Get Result code
  452. //
  453. hResult = pException->GetResultCode();
  454. //
  455. // Delete exception handler
  456. //
  457. delete pException;
  458. }
  459. catch(...)
  460. {
  461. //
  462. // If we failed to handle an exception, we default to APPMAN_E_CRITICALERROR
  463. //
  464. hResult = E_UNEXPECTED;
  465. }
  466. ///////////////////////////////////////////////////////////////////////////////////////
  467. return hResult;
  468. }
  469. //////////////////////////////////////////////////////////////////////////////////////////////
  470. //
  471. //////////////////////////////////////////////////////////////////////////////////////////////
  472. STDMETHODIMP CApplicationManagerAdmin::EnumApplications(const DWORD dwApplicationIndex, IApplicationEntry * lpObject)
  473. {
  474. FUNCTION("CApplicationManagerAdmin::EnumApplications ()");
  475. HRESULT hResult = S_OK;
  476. ///////////////////////////////////////////////////////////////////////////////////////
  477. try
  478. {
  479. //
  480. // Check to make sure the pointer we receive is good
  481. //
  482. if ((NULL == lpObject)||(IsBadReadPtr(lpObject, sizeof(CApplicationEntry))))
  483. {
  484. THROW(E_INVALIDARG);
  485. }
  486. hResult = m_InformationManager.GetApplicationDataWithIndex(dwApplicationIndex, ((CApplicationEntry *) lpObject)->GetApplicationDataPtr());
  487. if (SUCCEEDED(hResult))
  488. {
  489. ((CApplicationEntry *) lpObject)->SetInitializationLevel(INIT_LEVEL_TOTAL);
  490. }
  491. }
  492. ///////////////////////////////////////////////////////////////////////////////////////
  493. catch(CAppManExceptionHandler * pException)
  494. {
  495. //
  496. // Get Result code
  497. //
  498. hResult = pException->GetResultCode();
  499. //
  500. // Delete exception handler
  501. //
  502. delete pException;
  503. }
  504. catch(...)
  505. {
  506. //
  507. // If we failed to handle an exception, we default to APPMAN_E_CRITICALERROR
  508. //
  509. hResult = E_UNEXPECTED;
  510. }
  511. ///////////////////////////////////////////////////////////////////////////////////////
  512. return hResult;
  513. }
  514. //////////////////////////////////////////////////////////////////////////////////////////////
  515. //
  516. //////////////////////////////////////////////////////////////////////////////////////////////
  517. STDMETHODIMP CApplicationManagerAdmin::DoApplicationAction(const DWORD dwAction, const GUID * lpGuid, const DWORD dwStringProperty, LPVOID lpData, const DWORD dwDataLen)
  518. {
  519. FUNCTION("CApplicationManagerAdmin::DoApplicationAction ()");
  520. HRESULT hResult = S_OK;
  521. ///////////////////////////////////////////////////////////////////////////////////////
  522. try
  523. {
  524. APPLICATION_DATA sApplicationData;
  525. DWORD dwVariable;
  526. ZeroMemory(&sApplicationData, sizeof(sApplicationData));
  527. memcpy(&(sApplicationData.sBaseInfo.sApplicationGuid), lpGuid, sizeof(GUID));
  528. m_InformationManager.ValidateApplicationPropertyWithIndex(IDX_PROPERTY_GUID, &sApplicationData);
  529. hResult = m_InformationManager.GetApplicationData(&sApplicationData);
  530. if (SUCCEEDED(hResult))
  531. {
  532. //
  533. // Handle the GetProperty() request
  534. //
  535. switch(dwAction)
  536. {
  537. case ACTION_APP_DOWNSIZE
  538. : //
  539. // Make sure the required parameters are proper
  540. //
  541. if ((NULL == lpData)||(sizeof(DWORD) != dwDataLen))
  542. {
  543. THROW(APPMANADMIN_E_INVALIDPARAMETERS);
  544. }
  545. hResult = m_InformationManager.DownsizeApplication((DWORD) *((LPDWORD) lpData), &sApplicationData);
  546. break;
  547. case ACTION_APP_REINSTALL
  548. : hResult = m_InformationManager.ReInstallApplication(&sApplicationData);
  549. break;
  550. case ACTION_APP_UNINSTALL
  551. : hResult = m_InformationManager.UnInstallApplication(&sApplicationData);
  552. break;
  553. case ACTION_APP_UNINSTALLBLOCK
  554. : hResult = m_InformationManager.UnInstallApplicationWait(&sApplicationData);
  555. break;
  556. case ACTION_APP_SELFTEST
  557. : hResult = m_InformationManager.SelfTestApplication(&sApplicationData);
  558. break;
  559. case ACTION_APP_RUN_BLOCK
  560. : hResult = m_InformationManager.RunApplication(&sApplicationData, APP_RUN_BLOCK, dwStringProperty, (LPWSTR) lpData, dwDataLen);
  561. break;
  562. case ACTION_APP_RUN_NOBLOCK
  563. : hResult = m_InformationManager.RunApplication(&sApplicationData, APP_RUN_NOBLOCK, dwStringProperty, (LPWSTR) lpData, dwDataLen);
  564. break;
  565. case ACTION_APP_PIN
  566. : if (FALSE == sApplicationData.sBaseInfo.dwPinState)
  567. {
  568. dwVariable = TRUE;
  569. }
  570. else
  571. {
  572. dwVariable = FALSE;
  573. }
  574. hResult = m_InformationManager.PinApplication(&sApplicationData, (BOOL *) &dwVariable);
  575. break;
  576. }
  577. }
  578. }
  579. ///////////////////////////////////////////////////////////////////////////////////////
  580. catch(CAppManExceptionHandler * pException)
  581. {
  582. hResult = pException->GetResultCode();
  583. delete pException;
  584. }
  585. catch(...)
  586. {
  587. hResult = E_UNEXPECTED;
  588. }
  589. return hResult;
  590. }