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.

152 lines
2.6 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: climain.cxx
  4. //
  5. // Contents: server test program to test OLE2 RPC
  6. //
  7. // Classes: None
  8. //
  9. // Functions:
  10. //
  11. // History: 23-Nov-92 Rickhi Created
  12. //
  13. //--------------------------------------------------------------------
  14. #include <windows.h>
  15. #include <ole2.h>
  16. #include <stdio.h>
  17. #include <rpctyp.h> // IRpcTypes interface
  18. SCODE TestGuids(IRpcTypes *pRpc);
  19. SCODE TestDwords(IRpcTypes *pRpc);
  20. #define DebugOut(x) printf x
  21. int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nCmdShow)
  22. {
  23. DebugOut (("Test: Starting\n"));
  24. // initialize with OLE2
  25. SCODE sc = OleInitialize(NULL);
  26. if (FAILED(sc))
  27. {
  28. DebugOut (("Test: OleInitialize = %x\n", sc));
  29. return sc;
  30. }
  31. // create an instance
  32. sc = CoGetClassObject(CLSID_RpcTypes,
  33. CLSCTX_LOCAL_SERVER,
  34. NULL,
  35. IID_IClassFactory,
  36. (void **)&pCF);
  37. if (FAILED(sc))
  38. {
  39. DebugOut (("Test: CoGetClassObject=%x\n", sc));
  40. return sc;
  41. }
  42. sc = pCF->CreateInstance(NULL, IID_IRpcTypes, (void **)&pRpc);
  43. sc = pCF->Release();
  44. if (FAILED(sc))
  45. {
  46. DebugOut(("Test: CreateInstance=%x\n", sc));
  47. return sc;
  48. }
  49. sc = TestVoid(pRpc);
  50. sc = TestGuids(pRpc);
  51. sc = TestDwords(pRpc)
  52. sc = TestWindows(pRpc);
  53. sc = TestOleData(pRpc);
  54. // finished with OLE2
  55. OleUninitialize();
  56. DebugOut (("Test: CoUninitialize called.\n"));
  57. return sc;
  58. }
  59. SCODE TestGuids(IRpcTypes *pRpc)
  60. {
  61. REFCLSID rclsid;
  62. CLSID clsid;
  63. REFIID riid;
  64. IID iid;
  65. GUID guid;
  66. // initialize the parameters
  67. SCODE sc = pRpc->GuidsIn(rclsid, clsid, riid, iid, guid);
  68. if (FAILED(sc))
  69. {
  70. DebugOut (("\n"));
  71. }
  72. sc = pRpc->GuidsOut(&clsid, &iid, &guid);
  73. if (FAILED(sc))
  74. {
  75. DebugOut (("\n"));
  76. }
  77. // check the return values
  78. return S_OK;
  79. }
  80. SCODE TestDwords(IRpcTypes *pRpc)
  81. {
  82. DWORD dw = 1;
  83. ULONG ul = 2;
  84. LONG lg = 3;
  85. LARGE_INTEGER li;
  86. ULARGE_INTEGER uli;
  87. // methods to test DWORD / LARGE_INTEGER parameter passing
  88. li.LowPart = 4;
  89. li.HighPart = 5;
  90. uli.LowPart = 6;
  91. uli.HighPart = 7;
  92. sc = pRpc->DwordIn(dw, ul, lg, li, uli);
  93. if (FAILED(sc))
  94. {
  95. DebugOut (("\n"));
  96. }
  97. sc = pRpc->DwordIn(&dw, &ul, &lg, &li, &uli);
  98. if (FAILED(sc))
  99. {
  100. DebugOut (("\n"));
  101. }
  102. // check the return values
  103. return S_OK;
  104. }