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.

895 lines
28 KiB

  1. //
  2. // Author: DebiM
  3. // Date: March 97
  4. // File: csdrtad.cxx
  5. //
  6. // Class Store DRTs
  7. //
  8. // This source file contains DRTs for
  9. // CClassContainer::IClassAdmin
  10. //
  11. //
  12. // It tests the following Class Store functionality
  13. //
  14. // Admin Interfaces
  15. //
  16. //
  17. //---------------------------------------------------------------------
  18. #include "csdrt.hxx"
  19. extern BOOL fVerbose;
  20. extern BOOL fMultiStore;
  21. extern IClassAdmin *pIClassAdmin;
  22. extern IClassAdmin *pIClassAdmin2;
  23. extern IClassAccess *pIClassAccess;
  24. Sname TestFileExt1, TestFileExt2, TestFileExt4, TestProgId1, TestClassDesc1;
  25. Sname TestOtherProgID1, TestOtherProgID2;
  26. Sname TestMimeType2, TestClassDesc2;
  27. Sname TestProgId3;
  28. Sname TestVendor;
  29. Sname TestPackName1, TestProduct1, TestPackagePath1;
  30. Sname TestPackName2, TestPackagePath2;
  31. Sname TestPackName4, TestPackagePath4, TestProduct4;
  32. Sname TestPackName5, TestPackName6, TestPackName7, TestProduct2;
  33. Sname RefreshPackName3;
  34. Sname TestFailFileExt1, TestFailMimeType1, TestFailProgId1;
  35. Sname TestHelpUrl1, TestHelpUrl2, TestHelpUrl3;
  36. Sname TestAppCat1, TestAppCat2;
  37. Sname RenTestPackName2;
  38. LPOLESTR ConstTestFileExt1 = L".ex1-";
  39. LPOLESTR ConstTestFileExt2 = L".ex2-";
  40. LPOLESTR ConstTestProgId1 = L"Really Long Long Long ProgId1-";
  41. LPOLESTR ConstTestMimeType2 = L"MimeType2-";
  42. LPOLESTR ConstTestProgId3 = L"ProgId3-";
  43. LPOLESTR ConstTestFileExt4 = L".ex4-";
  44. LPOLESTR ConstTestPackName1 = L"CSDRT Pkg1-DRW-PUBL-VIS-AUTO(CLSID1-Ext4-Cat1)-";
  45. LPOLESTR ConstTestProduct1 = L"CS DRT Product1-";
  46. LPOLESTR ConstTestPackagePath1 = L"p1-";
  47. LPOLESTR ConstTestPackName2 = L"Wrong Pkg2-DRW-PUBL-HIDDEN-AUTO(CLSID1-Cat2)-";
  48. LPOLESTR ConstRenTestPackName2 = L"CSDRT Pkg2-DRW-PUBL-HIDDEN-AUTO(CLSID1-Cat2)-";
  49. LPOLESTR ConstTestPackagePath2 = L"p2-";
  50. LPOLESTR ConstTestOtherProgID1 = L"Really Long Long Long OtherProgId1-";
  51. LPOLESTR ConstTestOtherProgID2 = L"OtherProgId2-";
  52. LPOLESTR ConstTestPackName4 = L"CSDRT Pkg3-DRW-ASSG-VIS-AUTO(Ext4-Cat2)-";
  53. LPOLESTR ConstTestPackagePath4 = L"p4-";
  54. LPOLESTR ConstTestProduct2 = L"CS DRT Product2-";
  55. LPOLESTR ConstTestProduct4 = L"CS DRT Product4-";
  56. LPOLESTR ConstTestPackName5 = L"CS DRT pkg 5(Tlb2)-";
  57. LPOLESTR ConstTestPackName6 = L"CS DRT pkg 6 Cls 3 4-";
  58. LPOLESTR ConstTestPackName7 = L"CS DRT Tlb 7(CLS4)-";
  59. LPOLESTR ConstRefreshPackName3 = L"CS DRT Refresh Package 3(Clsid3)-";
  60. LPOLESTR ConstTestFailFileExt1 = L"fai";
  61. LPOLESTR ConstTestFailMimeType1 = L"FailMimeType";
  62. LPOLESTR ConstTestFailProgId1 = L"Expected Failure Prog ID";
  63. LPOLESTR ConstTestHelpUrl = L"http://junk";
  64. LPOLESTR ConstTestAppCat1 = L"Test App Cat Id-1";
  65. LPOLESTR ConstTestAppCat2 = L"Test App Cat Id-2";
  66. //--------------
  67. // {Fa11ed00-c151-d000-0000-000000000000}
  68. GUID TestFailClsid1 =
  69. { 0xfa11ed00, 0xc151, 0xd000, { 0x00, 0x00, 0x0, 0x00, 0x00, 0x0, 0x00, 0x00 } };
  70. //---------------
  71. DWORD gData1 = 0;
  72. GUID TestClsid1;
  73. GUID TestClsid2;
  74. GUID TestClsid3;
  75. GUID TestClsid4;
  76. GUID TestClsid5;
  77. GUID TestClsid6;
  78. GUID TestIid1;
  79. GUID TestIid2;
  80. GUID TestTlbId1;
  81. GUID TestAppCatId1, TestAppCatId2;
  82. PACKAGEDISPINFO PackageDisp[3];
  83. void CreateGuid(GUID *pGuid)
  84. {
  85. CoCreateGuid(pGuid);
  86. pGuid->Data2 = 0xabcd;
  87. gData1 = pGuid->Data1;
  88. }
  89. void ReleaseObj(PACKAGEDISPINFO obj)
  90. {
  91. ReleasePackageInfo(&obj);
  92. }
  93. void CreateUnique (WCHAR *VName, WCHAR *ConstName)
  94. {
  95. swprintf (VName, L"%s%x", ConstName, gData1);
  96. }
  97. void InitTempNames()
  98. {
  99. //
  100. // Create all GUIDs
  101. //
  102. CreateGuid(&TestClsid1);
  103. CreateGuid(&TestClsid2);
  104. CreateGuid(&TestClsid3);
  105. CreateGuid(&TestIid1);
  106. CreateGuid(&TestIid2);
  107. CreateGuid(&TestTlbId1);
  108. CreateGuid(&TestAppCatId1);
  109. CreateGuid(&TestAppCatId2);
  110. if (fMultiStore)
  111. {
  112. CreateGuid(&TestClsid4);
  113. CreateGuid(&TestClsid5);
  114. CreateGuid(&TestClsid6);
  115. }
  116. //
  117. // Create Unique Package Names, File Ext, ProgID
  118. //
  119. CreateUnique (TestFileExt1, ConstTestFileExt1);
  120. CreateUnique (TestFileExt2, ConstTestFileExt2);
  121. CreateUnique (TestProgId1, ConstTestProgId1);
  122. CreateUnique (TestOtherProgID1, ConstTestOtherProgID1);
  123. CreateUnique (TestOtherProgID2, ConstTestOtherProgID2);
  124. CreateUnique (TestMimeType2, ConstTestMimeType2);
  125. CreateUnique (TestProgId3, ConstTestProgId3);
  126. CreateUnique (TestFileExt4, ConstTestFileExt4);
  127. CreateUnique (TestPackName1, ConstTestPackName1);
  128. CreateUnique (TestProduct1, ConstTestProduct1);
  129. CreateUnique (TestPackagePath1, ConstTestPackagePath1);
  130. CreateUnique (TestPackName2, ConstTestPackName2);
  131. CreateUnique (RenTestPackName2, ConstRenTestPackName2);
  132. CreateUnique (TestPackagePath2, ConstTestPackagePath2);
  133. CreateUnique (TestProduct2, ConstTestProduct2);
  134. CreateUnique (RefreshPackName3, ConstRefreshPackName3);
  135. CreateUnique (TestPackName4, ConstTestPackName4);
  136. CreateUnique (TestPackagePath4, ConstTestPackagePath4);
  137. CreateUnique (TestProduct4, ConstTestProduct4);
  138. CreateUnique (TestPackName5, ConstTestPackName5);
  139. CreateUnique (TestPackName6, ConstTestPackName6);
  140. CreateUnique (TestPackName7, ConstTestPackName7);
  141. CreateUnique (TestFailFileExt1, ConstTestFailFileExt1);
  142. CreateUnique (TestFailProgId1, ConstTestFailProgId1);
  143. CreateUnique(TestHelpUrl1, ConstTestHelpUrl);
  144. CreateUnique(TestHelpUrl2, ConstTestHelpUrl);
  145. CreateUnique(TestHelpUrl3, ConstTestHelpUrl);
  146. CreateUnique(TestAppCat1, ConstTestAppCat1);
  147. CreateUnique(TestAppCat2, ConstTestAppCat2);
  148. }
  149. HRESULT AddRandomPackage(PACKAGEDETAIL &PackageDetail, int i)
  150. {
  151. HRESULT hr = S_OK;
  152. WCHAR szPackageName[_MAX_PATH];
  153. // activation flag to be set outside.
  154. wsprintf(szPackageName, L"LogonTestPackage-%d", i);
  155. PackageDetail.pInstallInfo->PathType = DrwFilePath;
  156. PackageDetail.pActInfo->cShellFileExt = 2;
  157. PackageDetail.pActInfo->prgShellFileExt = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR)*2);
  158. PackageDetail.pActInfo->prgShellFileExt[0] = TestFileExt4;
  159. PackageDetail.pActInfo->prgShellFileExt[1] = TestFileExt1;
  160. PackageDetail.pActInfo->prgPriority = (UINT *)CoTaskMemAlloc(sizeof(UINT)*2);
  161. PackageDetail.pActInfo->prgPriority[0] = 1;
  162. PackageDetail.pActInfo->prgPriority[1] = 2;
  163. PackageDetail.pActInfo->cInterfaces = 1;
  164. PackageDetail.pActInfo->prgInterfaceId = (IID *)CoTaskMemAlloc(sizeof(IID));
  165. PackageDetail.pActInfo->prgInterfaceId[0] = TestIid2;
  166. PackageDetail.pActInfo->cTypeLib = 1;
  167. PackageDetail.pActInfo->prgTlbId = (GUID *)CoTaskMemAlloc(sizeof(GUID));
  168. PackageDetail.pActInfo->prgTlbId[0] = TestTlbId1;
  169. PackageDetail.pPlatformInfo->cPlatforms = 1;
  170. PackageDetail.pPlatformInfo->prgPlatform = (CSPLATFORM *)CoTaskMemAlloc(sizeof(CSPLATFORM));
  171. GetDefaultPlatform(&PackageDetail.pPlatformInfo->prgPlatform[0]);
  172. PackageDetail.pPlatformInfo->cLocales = 2;
  173. PackageDetail.pPlatformInfo->prgLocale = (LCID *)CoTaskMemAlloc(sizeof(LCID)*2);
  174. PackageDetail.pPlatformInfo->prgLocale[0] = 0x409;
  175. PackageDetail.pPlatformInfo->prgLocale[1] = 0x410;
  176. PackageDetail.pInstallInfo->pszScriptPath = TestPackagePath1;
  177. PackageDetail.pInstallInfo->pszSetupCommand = TestPackagePath1;
  178. PackageDetail.pInstallInfo->pszUrl = TestHelpUrl1;
  179. PackageDetail.cSources = 1;
  180. PackageDetail.pszSourceList = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR));
  181. PackageDetail.pszSourceList[0] = TestPackagePath1;
  182. PackageDetail.cCategories = 1;
  183. PackageDetail.rpCategory = (GUID *)CoTaskMemAlloc(sizeof(GUID));
  184. PackageDetail.rpCategory[0] = TestAppCatId1;
  185. #if 0
  186. PackageDetail.pInstallInfo->cScriptLen = 160 + (GetTickCount() % 11783);
  187. PackageDetail.pInstallInfo->pScript = (BYTE *) CoTaskMemAlloc (PackageDetail.pInstallInfo->cScriptLen);
  188. for (UINT i=0; i < PackageDetail.pInstallInfo->cScriptLen; i++)
  189. {
  190. PackageDetail.pInstallInfo->pScript[i] = i%128;
  191. }
  192. #endif
  193. hr = pIClassAdmin->AddPackage(szPackageName, &PackageDetail);
  194. if (!SUCCEEDED(hr))
  195. {
  196. printf ("ERROR! AddPackage() returned 0x%x.\n", hr);
  197. return hr;
  198. }
  199. return hr;
  200. }
  201. HRESULT AddPackage1(PACKAGEDETAIL &PackageDetail)
  202. {
  203. HRESULT hr = S_OK;
  204. PackageDetail.pActInfo->cShellFileExt = 2;
  205. PackageDetail.pActInfo->prgShellFileExt = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR)*2);
  206. PackageDetail.pActInfo->prgShellFileExt[0] = TestFileExt4;
  207. PackageDetail.pActInfo->prgShellFileExt[1] = TestFileExt1;
  208. PackageDetail.pActInfo->prgPriority = (UINT *)CoTaskMemAlloc(sizeof(UINT)*2);
  209. PackageDetail.pActInfo->prgPriority[0] = 1;
  210. PackageDetail.pActInfo->prgPriority[1] = 2;
  211. PackageDetail.pActInfo->cInterfaces = 1;
  212. PackageDetail.pActInfo->prgInterfaceId = (IID *)CoTaskMemAlloc(sizeof(IID));
  213. PackageDetail.pActInfo->prgInterfaceId[0] = TestIid2;
  214. PackageDetail.pActInfo->cTypeLib = 1;
  215. PackageDetail.pActInfo->prgTlbId = (GUID *)CoTaskMemAlloc(sizeof(GUID));
  216. PackageDetail.pActInfo->prgTlbId[0] = TestTlbId1;
  217. PackageDetail.pPlatformInfo->cPlatforms = 1;
  218. PackageDetail.pPlatformInfo->prgPlatform = (CSPLATFORM *)CoTaskMemAlloc(sizeof(CSPLATFORM));
  219. GetDefaultPlatform(&PackageDetail.pPlatformInfo->prgPlatform[0]);
  220. PackageDetail.pPlatformInfo->cLocales = 2;
  221. PackageDetail.pPlatformInfo->prgLocale = (LCID *)CoTaskMemAlloc(sizeof(LCID)*2);
  222. PackageDetail.pPlatformInfo->prgLocale[0] = 0x409;
  223. PackageDetail.pPlatformInfo->prgLocale[1] = 0x410;
  224. PackageDetail.pInstallInfo->dwActFlags =
  225. ACTFLG_Published + // Published
  226. ACTFLG_UserInstall + // Visible
  227. ACTFLG_OnDemandInstall + // AutoInstall
  228. 256; // Hack. Script Present
  229. PackageDetail.pInstallInfo->PathType = DrwFilePath;
  230. PackageDetail.pInstallInfo->pszScriptPath = TestPackagePath1;
  231. // PackageDetail.pInstallInfo->pszSetupCommand = TestPackagePath1;
  232. PackageDetail.pInstallInfo->Mvipc = TestClsid1;
  233. PackageDetail.pInstallInfo->ProductCode = TestClsid1;
  234. PackageDetail.pInstallInfo->pszUrl = TestHelpUrl1;
  235. PackageDetail.pInstallInfo->InstallUiLevel = 42;
  236. PackageDetail.pInstallInfo->cUpgrades = 1;
  237. PackageDetail.pInstallInfo->prgUpgradeScript = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR));
  238. PackageDetail.pInstallInfo->prgUpgradeScript[0] = TestPackagePath1;
  239. PackageDetail.pInstallInfo->prgUpgradeFlag = (DWORD *)CoTaskMemAlloc(sizeof(DWORD));
  240. PackageDetail.pInstallInfo->prgUpgradeFlag[0] = UPGFLG_NoUninstall;
  241. PackageDetail.pInstallInfo->cScriptLen = 0;
  242. //160 + (GetTickCount() % 11783);
  243. /*
  244. PackageDetail.pInstallInfo->pScript = (BYTE *) CoTaskMemAlloc (PackageDetail.pInstallInfo->cScriptLen);
  245. for (UINT i=0; i < PackageDetail.pInstallInfo->cScriptLen; i++)
  246. {
  247. PackageDetail.pInstallInfo->pScript[i] = i%128;
  248. }
  249. */
  250. PackageDetail.cSources = 1;
  251. PackageDetail.pszSourceList = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR));
  252. PackageDetail.pszSourceList[0] = TestPackagePath1;
  253. PackageDetail.cCategories = 1;
  254. PackageDetail.rpCategory = (GUID *)CoTaskMemAlloc(sizeof(GUID));
  255. PackageDetail.rpCategory[0] = TestAppCatId1;
  256. hr = pIClassAdmin->AddPackage(TestPackName1, &PackageDetail);
  257. if (!SUCCEEDED(hr))
  258. {
  259. printf ("ERROR! NewPackage() returned 0x%x.\n", hr);
  260. return hr;
  261. }
  262. //CoTaskMemFree(PackageDetail.pInstallInfo->pScript);
  263. //PackageDetail.pInstallInfo->pScript = NULL;
  264. return hr;
  265. }
  266. HRESULT AddPackage2(PACKAGEDETAIL &PackageDetail)
  267. {
  268. HRESULT hr = S_OK;
  269. PackageDetail.pInstallInfo->dwActFlags =
  270. ACTFLG_Published + // Published
  271. ACTFLG_UserInstall + // Visible
  272. ACTFLG_OnDemandInstall; // AutoInstall
  273. PackageDetail.pInstallInfo->PathType = DrwFilePath;
  274. PackageDetail.pActInfo->cInterfaces = 1;
  275. PackageDetail.pActInfo->prgInterfaceId = (IID *)CoTaskMemAlloc(sizeof(IID));
  276. PackageDetail.pActInfo->prgInterfaceId[0] = TestIid1;
  277. PackageDetail.pActInfo->cTypeLib = 1;
  278. PackageDetail.pActInfo->prgTlbId = (GUID *)CoTaskMemAlloc(sizeof(GUID));
  279. PackageDetail.pActInfo->prgTlbId[0] = TestTlbId1;
  280. PackageDetail.pPlatformInfo->cPlatforms = 1;
  281. PackageDetail.pPlatformInfo->prgPlatform = (CSPLATFORM *)CoTaskMemAlloc(sizeof(CSPLATFORM));
  282. GetDefaultPlatform(&PackageDetail.pPlatformInfo->prgPlatform[0]);
  283. PackageDetail.pPlatformInfo->cLocales = 2;
  284. PackageDetail.pPlatformInfo->prgLocale = (LCID *)CoTaskMemAlloc(sizeof(LCID)*2);
  285. PackageDetail.pPlatformInfo->prgLocale[0] = 0x409;
  286. PackageDetail.pPlatformInfo->prgLocale[1] = 0x410;
  287. PackageDetail.pInstallInfo->pszScriptPath = TestPackagePath2;
  288. PackageDetail.pInstallInfo->pszSetupCommand = TestPackagePath2;
  289. PackageDetail.pInstallInfo->pszUrl = TestHelpUrl2;
  290. PackageDetail.cSources = 1;
  291. PackageDetail.pszSourceList = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR));
  292. PackageDetail.pszSourceList[0] = TestPackagePath2;
  293. PackageDetail.cCategories = 1;
  294. PackageDetail.rpCategory = (GUID *)CoTaskMemAlloc(sizeof(GUID));
  295. PackageDetail.rpCategory[0] = TestAppCatId2;
  296. // smaller scripts for this package
  297. #if 0
  298. PackageDetail.pInstallInfo->cScriptLen = (GetTickCount() % 3423);
  299. PackageDetail.pInstallInfo->pScript = (BYTE *) CoTaskMemAlloc (PackageDetail.pInstallInfo->cScriptLen);
  300. for (UINT i=0; i < PackageDetail.pInstallInfo->cScriptLen; i++)
  301. {
  302. PackageDetail.pInstallInfo->pScript[i] = i%128;
  303. }
  304. #endif
  305. hr = pIClassAdmin->AddPackage(TestPackName2, &PackageDetail);
  306. if (!SUCCEEDED(hr))
  307. {
  308. printf ("ERROR! NewPackage() returned 0x%x.\n", hr);
  309. return hr;
  310. }
  311. return hr;
  312. }
  313. HRESULT AddPackage3(PACKAGEDETAIL &PackageDetail)
  314. {
  315. HRESULT hr = S_OK;
  316. PackageDetail.pInstallInfo->dwActFlags =
  317. ACTFLG_Assigned + // Assigned
  318. ACTFLG_UserInstall + // Visible
  319. ACTFLG_OnDemandInstall; // AutoInstall
  320. PackageDetail.pInstallInfo->PathType = DrwFilePath;
  321. PackageDetail.pActInfo->cShellFileExt = 1;
  322. PackageDetail.pActInfo->prgShellFileExt = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR)*1);
  323. PackageDetail.pActInfo->prgShellFileExt[0] = TestFileExt4;
  324. PackageDetail.pActInfo->prgPriority = (UINT *)CoTaskMemAlloc(sizeof(UINT));
  325. PackageDetail.pActInfo->prgPriority[0] = 1;
  326. PackageDetail.pActInfo->cInterfaces = 1;
  327. PackageDetail.pActInfo->prgInterfaceId = (IID *)CoTaskMemAlloc(sizeof(IID));
  328. PackageDetail.pActInfo->prgInterfaceId[0] = TestIid2;
  329. PackageDetail.pActInfo->cTypeLib = 1;
  330. PackageDetail.pActInfo->prgTlbId = (GUID *)CoTaskMemAlloc(sizeof(GUID));
  331. PackageDetail.pActInfo->prgTlbId[0] = TestTlbId1;
  332. PackageDetail.pPlatformInfo->cPlatforms = 1;
  333. PackageDetail.pPlatformInfo->prgPlatform = (CSPLATFORM *)CoTaskMemAlloc(sizeof(CSPLATFORM));
  334. GetDefaultPlatform(&PackageDetail.pPlatformInfo->prgPlatform[0]);
  335. PackageDetail.pPlatformInfo->cLocales = 2;
  336. PackageDetail.pPlatformInfo->prgLocale = (LCID *)CoTaskMemAlloc(sizeof(LCID)*2);
  337. PackageDetail.pPlatformInfo->prgLocale[0] = 0x409;
  338. PackageDetail.pPlatformInfo->prgLocale[1] = 0x410;
  339. PackageDetail.pInstallInfo->pszScriptPath = TestPackagePath4;
  340. PackageDetail.pInstallInfo->pszSetupCommand = TestPackagePath4;
  341. PackageDetail.pInstallInfo->pszUrl = TestHelpUrl3;
  342. PackageDetail.cSources = 1;
  343. PackageDetail.pszSourceList = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR));
  344. PackageDetail.pszSourceList[0] = TestPackagePath4;
  345. PackageDetail.cCategories = 1;
  346. PackageDetail.rpCategory = (GUID *)CoTaskMemAlloc(sizeof(GUID));
  347. PackageDetail.rpCategory[0] = TestAppCatId2;
  348. #if 0
  349. // smaller scripts for this package
  350. PackageDetail.pInstallInfo->cScriptLen = (GetTickCount() % 26423);
  351. PackageDetail.pInstallInfo->pScript = (BYTE *) CoTaskMemAlloc (PackageDetail.pInstallInfo->cScriptLen);
  352. for (UINT i=0; i < PackageDetail.pInstallInfo->cScriptLen; i++)
  353. {
  354. PackageDetail.pInstallInfo->pScript[i] = i%128;
  355. }
  356. #endif
  357. hr = pIClassAdmin->AddPackage(TestPackName4, &PackageDetail);
  358. if (!SUCCEEDED(hr))
  359. {
  360. printf ("ERROR! NewPackage() returned 0x%x.\n", hr);
  361. return hr;
  362. }
  363. return hr;
  364. }
  365. void VerbosePrintObj(PACKAGEDISPINFO If)
  366. {
  367. VerbosePrint("Package Name %S\n", If.pszPackageName);
  368. }
  369. HRESULT GetPackageStructures(LPOLESTR PackName, PACKAGEDETAIL PackageDetail)
  370. {
  371. PACKAGEDETAIL PackageDetailFetched;
  372. PLATFORMINFO PlatformInfo;
  373. HRESULT hr = S_OK;
  374. hr = pIClassAdmin->GetPackageDetails(PackName, &PackageDetailFetched);
  375. if (!SUCCEEDED(hr))
  376. {
  377. printf ("ERROR! GetPackageDetails() returned 0x%x.\n", hr);
  378. return hr;
  379. }
  380. if (!(Compare(PackageDetailFetched, PackageDetail)))
  381. {
  382. hr = E_FAIL;
  383. }
  384. ReleasePackageDetail(&PackageDetailFetched);
  385. return hr;
  386. }
  387. CLASSDETAIL ClassDetail[3];
  388. HRESULT
  389. InitPackages(ULONG *pcPkgCount, PACKAGEDETAIL &PackageDetail1,
  390. PACKAGEDETAIL &PackageDetail2,
  391. PACKAGEDETAIL &PackageDetail3)
  392. {
  393. HRESULT hr = S_OK;
  394. memset (&ClassDetail[0], NULL, sizeof (CLASSDETAIL));
  395. memcpy (&ClassDetail[0].Clsid, &TestClsid1, sizeof (GUID));
  396. ClassDetail[0].cProgId = 3;
  397. ClassDetail[0].prgProgId = (LPWSTR *) CoTaskMemAlloc(3 * sizeof (LPWSTR));
  398. ClassDetail[0].prgProgId[0] = TestProgId1;
  399. ClassDetail[0].prgProgId[1] = TestOtherProgID1;
  400. ClassDetail[0].prgProgId[2] = TestOtherProgID2;
  401. memset (&ClassDetail[1], NULL, sizeof (CLASSDETAIL));
  402. memcpy (&ClassDetail[1].Clsid, &TestClsid2, sizeof (GUID));
  403. memcpy (&ClassDetail[1].TreatAs, &TestClsid3, sizeof (GUID));
  404. memset (&ClassDetail[2], NULL, sizeof (CLASSDETAIL));
  405. memcpy (&ClassDetail[2].Clsid, &TestClsid3, sizeof (GUID));
  406. ClassDetail[2].cProgId = 1;
  407. ClassDetail[2].prgProgId = (LPWSTR *) CoTaskMemAlloc(1 * sizeof (LPWSTR));
  408. ClassDetail[2].prgProgId[0] = TestProgId3;
  409. //
  410. // Add Package 1
  411. //
  412. PackageDetail1.pActInfo->cClasses = 2;
  413. PackageDetail1.pActInfo->pClasses = (CLASSDETAIL *)CoTaskMemAlloc(sizeof(CLASSDETAIL)*2);
  414. PackageDetail1.pActInfo->pClasses[0] = ClassDetail[0];
  415. PackageDetail1.pActInfo->pClasses[1] = ClassDetail[1];
  416. hr = AddPackage1(PackageDetail1);
  417. if (SUCCEEDED(hr))
  418. {
  419. (*pcPkgCount)++;
  420. }
  421. //
  422. // Add Package 2
  423. //
  424. PackageDetail2.pActInfo->cClasses = 2;
  425. PackageDetail2.pActInfo->pClasses = (CLASSDETAIL *)CoTaskMemAlloc(sizeof(CLASSDETAIL)*2);
  426. PackageDetail2.pActInfo->pClasses[0] = ClassDetail[0];
  427. PackageDetail2.pActInfo->pClasses[1] = ClassDetail[2];
  428. hr = AddPackage2(PackageDetail2);
  429. if (SUCCEEDED(hr))
  430. {
  431. (*pcPkgCount)++;
  432. }
  433. //
  434. // Add Package 3
  435. //
  436. hr = AddPackage3(PackageDetail3);
  437. if (SUCCEEDED(hr))
  438. {
  439. (*pcPkgCount)++;
  440. }
  441. //
  442. // Test rename
  443. // Rename Pkg2
  444. //
  445. hr = pIClassAdmin->ChangePackageProperties(TestPackName2,
  446. RenTestPackName2, NULL, NULL, NULL, NULL);
  447. if (!SUCCEEDED(hr))
  448. {
  449. printf ("ERROR! ChangePackageProperties(rename) returned 0x%x.\n", hr);
  450. return hr;
  451. }
  452. //
  453. // Test changing properties - flags
  454. //
  455. DWORD dwActFlags = ACTFLG_Published + ACTFLG_OnDemandInstall; // Not visible
  456. hr = pIClassAdmin->ChangePackageProperties(RenTestPackName2,
  457. NULL, &dwActFlags, NULL, NULL, NULL);
  458. if (!SUCCEEDED(hr))
  459. {
  460. printf ("ERROR! ChangePackageProperties(flags) returned 0x%x.\n", hr);
  461. return hr;
  462. }
  463. PackageDetail2.pInstallInfo->dwActFlags = dwActFlags;
  464. //
  465. // Test changing properties - scriptpath
  466. //
  467. hr = pIClassAdmin->ChangePackageProperties(RenTestPackName2,
  468. NULL, NULL, NULL, L"foo.bar", NULL);
  469. if (!SUCCEEDED(hr))
  470. {
  471. printf ("ERROR! ChangePackageProperties(ScriptPath) returned 0x%x.\n", hr);
  472. return hr;
  473. }
  474. PackageDetail2.pInstallInfo->pszScriptPath = L"foo.bar";
  475. //
  476. // Test changing fileext priority
  477. //
  478. hr = pIClassAdmin->SetPriorityByFileExt(TestPackName1,
  479. TestFileExt4, 12);
  480. if (!SUCCEEDED(hr))
  481. {
  482. printf ("ERROR! SetPriorityByFileExt() returned 0x%x.\n", hr);
  483. return hr;
  484. }
  485. PackageDetail1.pActInfo->prgPriority[0] = 12; // we know that the corresp ext in in the first place.
  486. return hr;
  487. }
  488. HRESULT DoAdminEnumTests()
  489. {
  490. HRESULT hr;
  491. IEnumPackage *pEnum = NULL;
  492. VerbosePrint("Testing Enumerator with file ext %S\n", TestFileExt4);
  493. hr = pIClassAdmin->EnumPackages(TestFileExt4,
  494. NULL,
  495. 0,
  496. NULL,
  497. NULL,
  498. &pEnum);
  499. if (!SUCCEEDED(hr))
  500. {
  501. printf ("ERROR! EnumPackages() returned 0x%x.\n", hr);
  502. return hr;
  503. }
  504. EnumTests<IEnumPackage, PACKAGEDISPINFO>(pEnum, 2, NULL, PackageDisp, 3, TRUE);
  505. if (!SUCCEEDED(hr))
  506. {
  507. return hr;
  508. }
  509. hr = pIClassAdmin->EnumPackages(NULL,
  510. &TestAppCatId2,
  511. 0,
  512. NULL,
  513. NULL,
  514. &pEnum);
  515. if (!SUCCEEDED(hr))
  516. {
  517. printf ("ERROR! EnumPackages() returned 0x%x.\n", hr);
  518. return hr;
  519. }
  520. hr = EnumTests<IEnumPackage, PACKAGEDISPINFO>(pEnum, 2, NULL, PackageDisp, 3, TRUE);
  521. if (!SUCCEEDED(hr)) {
  522. return hr;
  523. }
  524. return hr;
  525. }
  526. PACKAGEDETAIL PackageDetail1, PackageDetail2,
  527. PackageDetail3, PackageDetail4;
  528. HRESULT DoAdminTest (ULONG *pcPkgCount)
  529. {
  530. HRESULT hr = S_OK;
  531. APPCATEGORYINFO AppCategory1, AppCategory2;
  532. APPCATEGORYINFOLIST RecdAppCategoryInfoList;
  533. memset(&PackageDetail1, NULL, sizeof(PACKAGEDETAIL));
  534. memset(&PackageDetail2, NULL, sizeof(PACKAGEDETAIL));
  535. memset(&PackageDetail3, NULL, sizeof(PACKAGEDETAIL));
  536. PackageDetail1.pInstallInfo = (INSTALLINFO *) CoTaskMemAlloc (sizeof(INSTALLINFO));
  537. memset (PackageDetail1.pInstallInfo, 0, sizeof(INSTALLINFO));
  538. PackageDetail1.pPlatformInfo = (PLATFORMINFO *) CoTaskMemAlloc (sizeof(PLATFORMINFO));
  539. memset (PackageDetail1.pPlatformInfo, 0, sizeof(PLATFORMINFO));
  540. PackageDetail1.pActInfo = (ACTIVATIONINFO *) CoTaskMemAlloc (sizeof(ACTIVATIONINFO));
  541. memset (PackageDetail1.pActInfo, 0, sizeof(ACTIVATIONINFO));
  542. PackageDetail2.pInstallInfo = (INSTALLINFO *) CoTaskMemAlloc (sizeof(INSTALLINFO));
  543. memset (PackageDetail2.pInstallInfo, 0, sizeof(INSTALLINFO));
  544. PackageDetail2.pPlatformInfo = (PLATFORMINFO *) CoTaskMemAlloc (sizeof(PLATFORMINFO));
  545. memset (PackageDetail2.pPlatformInfo, 0, sizeof(PLATFORMINFO));
  546. PackageDetail2.pActInfo = (ACTIVATIONINFO *) CoTaskMemAlloc (sizeof(ACTIVATIONINFO));
  547. memset (PackageDetail2.pActInfo, 0, sizeof(ACTIVATIONINFO));
  548. PackageDetail3.pInstallInfo = (INSTALLINFO *) CoTaskMemAlloc (sizeof(INSTALLINFO));
  549. memset (PackageDetail3.pInstallInfo, 0, sizeof(INSTALLINFO));
  550. PackageDetail3.pPlatformInfo = (PLATFORMINFO *) CoTaskMemAlloc (sizeof(PLATFORMINFO));
  551. memset (PackageDetail3.pPlatformInfo, 0, sizeof(PLATFORMINFO));
  552. PackageDetail3.pActInfo = (ACTIVATIONINFO *) CoTaskMemAlloc (sizeof(ACTIVATIONINFO));
  553. memset (PackageDetail3.pActInfo, 0, sizeof(ACTIVATIONINFO));
  554. *pcPkgCount = 0;
  555. memset((void *)PackageDisp, 0, sizeof(PACKAGEDISPINFO)*3);
  556. hr = InitPackages(pcPkgCount, PackageDetail1, PackageDetail2,
  557. PackageDetail3);
  558. if (FAILED(hr))
  559. return hr;
  560. if (pIClassAdmin2 != NULL)
  561. {
  562. //
  563. // If MultiStore tests in progress
  564. }
  565. hr = GetPackageStructures(TestPackName1, PackageDetail1);
  566. if (!SUCCEEDED(hr))
  567. {
  568. return hr;
  569. }
  570. hr = GetPackageStructures(RenTestPackName2, PackageDetail2);
  571. if (!SUCCEEDED(hr))
  572. {
  573. //
  574. // Properties in the package detail structure has been updated.
  575. return hr;
  576. }
  577. hr = GetPackageStructures(TestPackName4, PackageDetail3);
  578. if (!SUCCEEDED(hr)) {
  579. return hr;
  580. }
  581. PackageDisp[0].pszPackageName = TestPackName1;
  582. PackageDisp[0].dwActFlags = PackageDetail1.pInstallInfo->dwActFlags;
  583. PackageDisp[0].PathType = PackageDetail1.pInstallInfo->PathType;
  584. PackageDisp[0].pszScriptPath = PackageDetail1.pInstallInfo->pszScriptPath;
  585. PackageDisp[0].cScriptLen = PackageDetail1.pInstallInfo->cScriptLen;
  586. PackageDisp[0].Usn = PackageDetail1.pInstallInfo->Usn;
  587. PackageDisp[0].dwVersionHi = PackageDetail1.pInstallInfo->dwVersionHi;
  588. PackageDisp[0].dwVersionLo = PackageDetail1.pInstallInfo->dwVersionLo;
  589. PackageDisp[0].cUpgrades = PackageDetail1.pInstallInfo->cUpgrades;
  590. PackageDisp[0].prgUpgradeScript = PackageDetail1.pInstallInfo->prgUpgradeScript;
  591. PackageDisp[0].prgUpgradeFlag = PackageDetail1.pInstallInfo->prgUpgradeFlag;
  592. PackageDisp[1].pszPackageName = RenTestPackName2;
  593. PackageDisp[1].dwActFlags = PackageDetail2.pInstallInfo->dwActFlags;
  594. PackageDisp[1].PathType = PackageDetail2.pInstallInfo->PathType;
  595. PackageDisp[1].pszScriptPath = PackageDetail2.pInstallInfo->pszScriptPath;
  596. PackageDisp[1].cScriptLen = PackageDetail2.pInstallInfo->cScriptLen;
  597. PackageDisp[1].Usn = PackageDetail2.pInstallInfo->Usn;
  598. PackageDisp[1].dwVersionHi = PackageDetail2.pInstallInfo->dwVersionHi;
  599. PackageDisp[1].dwVersionLo = PackageDetail2.pInstallInfo->dwVersionLo;
  600. PackageDisp[1].cUpgrades = PackageDetail2.pInstallInfo->cUpgrades;
  601. PackageDisp[1].prgUpgradeScript = PackageDetail2.pInstallInfo->prgUpgradeScript;
  602. PackageDisp[1].prgUpgradeFlag = PackageDetail2.pInstallInfo->prgUpgradeFlag;
  603. PackageDisp[2].pszPackageName = TestPackName4;
  604. PackageDisp[2].dwActFlags = PackageDetail3.pInstallInfo->dwActFlags;
  605. PackageDisp[2].PathType = PackageDetail3.pInstallInfo->PathType;
  606. PackageDisp[2].pszScriptPath = PackageDetail3.pInstallInfo->pszScriptPath;
  607. PackageDisp[2].cScriptLen = PackageDetail3.pInstallInfo->cScriptLen;
  608. PackageDisp[2].Usn = PackageDetail3.pInstallInfo->Usn;
  609. PackageDisp[2].dwVersionHi = PackageDetail3.pInstallInfo->dwVersionHi;
  610. PackageDisp[2].dwVersionLo = PackageDetail3.pInstallInfo->dwVersionLo;
  611. PackageDisp[2].cUpgrades = PackageDetail3.pInstallInfo->cUpgrades;
  612. PackageDisp[2].prgUpgradeScript = PackageDetail3.pInstallInfo->prgUpgradeScript;
  613. PackageDisp[2].prgUpgradeFlag = PackageDetail3.pInstallInfo->prgUpgradeFlag;
  614. hr = DoAdminEnumTests();
  615. if (!SUCCEEDED(hr)) {
  616. return hr;
  617. }
  618. memset(&AppCategory1, 0, sizeof(APPCATEGORYINFO));
  619. memset(&AppCategory2, 0, sizeof(APPCATEGORYINFO));
  620. AppCategory1.Locale = AppCategory2.Locale = 0x409;
  621. AppCategory1.pszDescription = TestAppCat1;
  622. AppCategory2.pszDescription = TestAppCat2;
  623. AppCategory1.AppCategoryId = TestAppCatId1;
  624. AppCategory2.AppCategoryId = TestAppCatId2;
  625. hr = pIClassAdmin->RegisterAppCategory(&AppCategory1);
  626. if (!SUCCEEDED(hr))
  627. {
  628. printf("RegisterAppCategory 1 returned 0x%x\n", hr);
  629. return hr;
  630. }
  631. hr = pIClassAdmin->RegisterAppCategory(&AppCategory2);
  632. if (!SUCCEEDED(hr))
  633. {
  634. printf("RegisterAppCategory 2 returned 0x%x\n", hr);
  635. return hr;
  636. }
  637. //hr = pIClassAdmin->GetAppCategories (0x409, &RecdAppCategoryInfoList);
  638. hr = CsGetAppCategories (&RecdAppCategoryInfoList);
  639. if (SUCCEEDED(hr))
  640. {
  641. printf("CsGetAppCategories returned: %d items\n", RecdAppCategoryInfoList.cCategory);
  642. for (UINT k=0; k < RecdAppCategoryInfoList.cCategory; k++)
  643. printf (" Category: %S.\n", (RecdAppCategoryInfoList.pCategoryInfo[k]).pszDescription);
  644. }
  645. if ((hr != S_OK) || (RecdAppCategoryInfoList.cCategory < 2))
  646. {
  647. printf("CsGetAppCategories failed. 0x%x\n", hr);
  648. }
  649. ReleaseAppCategoryInfoList(&RecdAppCategoryInfoList);
  650. // ReleasePackageDetail(&PackageDetail1, TRUE);
  651. // ReleasePackageDetail(&PackageDetail2, TRUE);
  652. // ReleasePackageDetail(&PackageDetail3, TRUE);
  653. return S_OK;
  654. }
  655. HRESULT DoRemoveTest (ULONG *pcPkgCount)
  656. {
  657. HRESULT hr, hr1 = S_OK;
  658. *pcPkgCount = 0;
  659. VerbosePrint("Removing Packages %S\n", TestPackName1);
  660. hr = pIClassAdmin->RemovePackage(TestPackName1, 0);
  661. if (SUCCEEDED(hr))
  662. (*pcPkgCount)++;
  663. else
  664. {
  665. printf("Remove Package returned 0x%x\n", hr);
  666. hr1 = hr;
  667. }
  668. VerbosePrint("Removing Packages %S\n", TestPackName2);
  669. hr = pIClassAdmin->RemovePackage(TestPackName2, 0);
  670. if (SUCCEEDED(hr))
  671. (*pcPkgCount)++;
  672. else {
  673. printf("Remove Package returned 0x%x\n", hr);
  674. hr1 = hr;
  675. }
  676. VerbosePrint("Removing Packages %S\n", TestPackName4);
  677. hr = pIClassAdmin->RemovePackage(TestPackName4, 0);
  678. if (SUCCEEDED(hr))
  679. (*pcPkgCount)++;
  680. else {
  681. printf("Remove Package returned 0x%x\n", hr);
  682. hr1 = hr;
  683. }
  684. hr = pIClassAdmin->UnregisterAppCategory(&TestAppCatId1);
  685. if (!SUCCEEDED(hr)) {
  686. printf("RegisterAppCategory 1 returned 0x%x\n", hr);
  687. return hr;
  688. }
  689. hr = pIClassAdmin->UnregisterAppCategory(&TestAppCatId2);
  690. if (!SUCCEEDED(hr)) {
  691. printf("RegisterAppCategory 1 returned 0x%x\n", hr);
  692. return hr;
  693. }
  694. return hr;
  695. }
  696. HRESULT RefreshTest()
  697. {
  698. return S_OK;
  699. }