Leaked source code of windows server 2003
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.

141 lines
5.1 KiB

  1. //
  2. // test code for chanmgr
  3. //
  4. #include <windows.h>
  5. #include <windowsx.h>
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <ole2.h>
  9. #include <chanmgr.h>
  10. //
  11. // Macros
  12. //
  13. #define ASSERT(x) if(!(x)) printf("ASSERT:line %d: %s", __line__, ##x);
  14. #define CHECK(x) printf("%s %s\n", #x, (SUCCEEDED((x)) || (x) == S_FALSE) ? "SUCCEEDED" : "FAILED" );
  15. int _cdecl main()
  16. {
  17. HRESULT hr;
  18. hr = CoInitialize(NULL);
  19. IChannelMgr *pChannelMgr = NULL;
  20. hr = CoCreateInstance(CLSID_ChannelMgr, NULL, CLSCTX_INPROC_SERVER,
  21. IID_IChannelMgr, (void**)&pChannelMgr);
  22. if (SUCCEEDED(hr))
  23. {
  24. {
  25. //
  26. // Add the sports category
  27. //
  28. CHANNELCATEGORYINFO cci = {0};
  29. cci.cbSize = sizeof(cci);
  30. cci.pszURL = L"http://www.jiggins.com";
  31. cci.pszTitle = L"Sports";
  32. cci.pszLogo = L"\\\\ohserv\\users\\julianj\\sports.gif";
  33. cci.pszIcon = L"\\\\ohserv\\users\\julianj\\sports.ico";
  34. CHANNELSHORTCUTINFO csi = {0};
  35. csi.cbSize = sizeof(csi);
  36. csi.pszURL = L"http://www.espn.com";
  37. csi.pszTitle = L"Sports\\Espn";
  38. csi.pszLogo = L"\\\\ohserv\\users\\julianj\\news.gif";
  39. csi.pszIcon = L"\\\\ohserv\\users\\julianj\\news.ico";
  40. CHECK(pChannelMgr->DeleteChannelShortcut(csi.pszTitle));
  41. CHECK(pChannelMgr->DeleteCategory(cci.pszTitle));
  42. CHECK(pChannelMgr->AddCategory(&cci));
  43. CHECK(pChannelMgr->AddChannelShortcut(&csi));
  44. }
  45. {
  46. //
  47. // Add the News category
  48. //
  49. CHANNELCATEGORYINFO cci = {0};
  50. cci.cbSize = sizeof(cci);
  51. cci.pszURL = L"http://www.jiggins.com";
  52. cci.pszTitle = L"Recent News";
  53. cci.pszLogo = L"\\\\ohserv\\users\\julianj\\sports.gif";
  54. cci.pszIcon = L"\\\\ohserv\\users\\julianj\\sports.ico";
  55. CHANNELSHORTCUTINFO csi = {0};
  56. csi.cbSize = sizeof(csi);
  57. csi.pszURL = L"http://www.espn.com";
  58. csi.pszTitle = L"Recent News\\New York Times";
  59. csi.pszLogo = L"\\\\ohserv\\users\\julianj\\news.gif";
  60. csi.pszIcon = L"\\\\ohserv\\users\\julianj\\news.ico";
  61. CHANNELSHORTCUTINFO csi2 = {0};
  62. csi2.cbSize = sizeof(csi2);
  63. csi2.pszURL = L"http://www.espn.com";
  64. csi2.pszTitle = L"Recent News\\Seattle Times";
  65. csi2.pszLogo = L"\\\\ohserv\\users\\julianj\\news.gif";
  66. csi2.pszIcon = L"\\\\ohserv\\users\\julianj\\news.ico";
  67. CHECK(pChannelMgr->DeleteChannelShortcut(csi.pszTitle));
  68. CHECK(pChannelMgr->DeleteChannelShortcut(csi2.pszTitle));
  69. CHECK(pChannelMgr->DeleteCategory(cci.pszTitle));
  70. CHECK(pChannelMgr->AddCategory(&cci));
  71. CHECK(pChannelMgr->AddChannelShortcut(&csi));
  72. CHECK(pChannelMgr->AddChannelShortcut(&csi2));
  73. }
  74. {
  75. // Add the test category
  76. CHANNELCATEGORYINFO cci = {0};
  77. cci.cbSize = sizeof(cci);
  78. cci.pszURL = L"http://www.jiggins.com";
  79. cci.pszTitle = L"Test Category -/:*?\"<>|";
  80. cci.pszLogo = L"\\\\ohserv\\users\\julianj\\sports.gif";
  81. cci.pszIcon = L"\\\\ohserv\\users\\julianj\\sports.ico";
  82. CHANNELSHORTCUTINFO csi = {0};
  83. csi.cbSize = sizeof(csi);
  84. csi.pszURL = L"http://www.espn.com";
  85. csi.pszTitle = L"Test Category -/:*?\"<>|\\Test Shortcut 1 -/:*?\"<>|";
  86. csi.pszLogo = L"\\\\ohserv\\users\\julianj\\news.gif";
  87. csi.pszIcon = L"\\\\ohserv\\users\\julianj\\news.ico";
  88. CHECK(pChannelMgr->DeleteChannelShortcut(csi.pszTitle));
  89. CHECK(pChannelMgr->DeleteCategory(cci.pszTitle));
  90. CHECK(pChannelMgr->AddCategory(&cci));
  91. CHECK(pChannelMgr->AddChannelShortcut(&csi));
  92. }
  93. {
  94. // Add another test category
  95. CHANNELCATEGORYINFO cci = {0};
  96. cci.cbSize = sizeof(cci);
  97. cci.pszURL = L"http://www.jiggins.com";
  98. cci.pszTitle = L"Test Category -/:*?\"<>|\\Tests";
  99. cci.pszLogo = L"\\\\ohserv\\users\\julianj\\sports.gif";
  100. cci.pszIcon = L"\\\\ohserv\\users\\julianj\\sports.ico";
  101. CHANNELSHORTCUTINFO csi = {0};
  102. csi.cbSize = sizeof(csi);
  103. csi.pszURL = L"http://www.espn.com";
  104. csi.pszTitle = L"Test Category -/:*?\"<>|\\Tests\\Test Shortcut 2 -/:*?\"<>|";
  105. csi.pszLogo = L"\\\\ohserv\\users\\julianj\\news.gif";
  106. csi.pszIcon = L"\\\\ohserv\\users\\julianj\\news.ico";
  107. CHECK(pChannelMgr->DeleteChannelShortcut(csi.pszTitle));
  108. CHECK(pChannelMgr->DeleteCategory(cci.pszTitle));
  109. CHECK(pChannelMgr->AddCategory(&cci));
  110. CHECK(pChannelMgr->AddChannelShortcut(&csi));
  111. }
  112. pChannelMgr->Release();
  113. }
  114. CoUninitialize();
  115. return 0;
  116. }