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.

72 lines
1.9 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. int _cdecl main()
  15. {
  16. HRESULT hr;
  17. hr = CoInitialize(NULL);
  18. if (SUCCEEDED(hr))
  19. {
  20. IChannelMgr* pIChannelMgr;
  21. hr = CoCreateInstance(CLSID_ChannelMgr, NULL, CLSCTX_INPROC_SERVER,
  22. IID_IChannelMgr, (void**)&pIChannelMgr);
  23. if (SUCCEEDED(hr))
  24. {
  25. ASSERT(pIChannelMgr);
  26. IEnumChannels* pIEnumChannels;
  27. hr = pIChannelMgr->EnumChannels(CHANENUM_ALL, NULL, &pIEnumChannels);
  28. if (SUCCEEDED(hr))
  29. {
  30. ASSERT(pIEnumChannels);
  31. CHANNELENUMINFO ci;
  32. while (S_OK == pIEnumChannels->Next(1, &ci, NULL))
  33. {
  34. printf("Channel : %S\n"
  35. "Url : %S\n"
  36. "Path : %S\n"
  37. "Subscription : %s\n\n",
  38. ci.pszTitle, ci.pszURL, ci.pszPath,
  39. ci.stSubscriptionState == SUBSTATE_NOTSUBSCRIBED ?
  40. "Not Subscribed" :
  41. (ci.stSubscriptionState == SUBSTATE_FULLSUBSCRIPTION ?
  42. "Full Subscription" :
  43. "Partial Subscription")
  44. );
  45. CoTaskMemFree(ci.pszTitle);
  46. CoTaskMemFree(ci.pszURL);
  47. CoTaskMemFree(ci.pszPath);
  48. }
  49. pIEnumChannels->Release();
  50. }
  51. pIChannelMgr->Release();
  52. }
  53. }
  54. CoUninitialize();
  55. return 0;
  56. }