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.

160 lines
3.7 KiB

  1. #include <windows.h>
  2. #include <port1632.h>
  3. #include <ddeml.h>
  4. #include <string.h>
  5. #include "wrapper.h"
  6. #include "ddestrs.h"
  7. extern INT iAvailFormats[];
  8. extern BOOL UpdateCount(HWND,INT,INT);
  9. extern HANDLE hmemNet;
  10. void CALLBACK TimerFunc( HWND hwnd, UINT msg, UINT id, DWORD dwTime)
  11. {
  12. HCONV hConv;
  13. HCONVLIST hConvList;
  14. LONG lflags;
  15. switch (id%2) {
  16. case 1:
  17. hConv = 0;
  18. hConvList=(HCONVLIST)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HCONVLIST);
  19. while (hConv = DdeQueryNextServer(hConvList, hConv)) {
  20. // POKE CHANGES
  21. #if 0
  22. idI=GetThreadLong(GETCURRENTTHREADID(),OFFSET_IDINST);
  23. if(DdeClientTransaction("Poke Transaction",
  24. strlen("Poke Transaction")+1,
  25. hConv,
  26. DdeCreateStringHandle(idI,"TestItem",CP_WINANSI),
  27. CF_TEXT,
  28. XTYP_POKE,
  29. TIMEOUT_ASYNC,
  30. NULL)==0){
  31. DDEMLERROR("DdeStrs.Exe -- DdeClientTransaction failed:XTYP_POKE\r\n");
  32. }
  33. #endif
  34. // END OF POKE CHANGES
  35. // Allow 'Pause' functionality -p on command line.
  36. lflags=GetWindowLong(hwndMain,OFFSET_FLAGS);
  37. if((lflags&FLAG_PAUSE)!=FLAG_PAUSE)
  38. {
  39. if(DdeClientTransaction(szExecRefresh,
  40. strlen(szExecRefresh) + 1,
  41. hConv,
  42. 0,
  43. 0,
  44. XTYP_EXECUTE,
  45. TIMEOUT_ASYNC,
  46. NULL)==0){
  47. DDEMLERROR("DdeStrs.Exe -- DdeClientTransaction failed:XTYP_EXECUTE\r\n");
  48. }
  49. }
  50. }
  51. }
  52. return;
  53. }
  54. BOOL InitClient()
  55. {
  56. UINT uid;
  57. ReconnectList();
  58. uid = SetTimer( hwndMain,
  59. (UINT)GetThreadLong(GETCURRENTTHREADID(),OFFSET_CLIENTTIMER),
  60. (UINT)(GetWindowLong(hwndMain,OFFSET_DELAY)),
  61. TimerFunc);
  62. // This starts the test immidiatly. No delay waiting for the first
  63. // WM_TIMER call.
  64. TimerFunc(hwndMain,WM_TIMER,uid,0);
  65. return(TRUE);
  66. }
  67. VOID CloseClient()
  68. {
  69. HCONVLIST hConvList;
  70. hConvList=(HCONVLIST)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HCONVLIST);
  71. KillTimer(hwndMain,(UINT)GetThreadLong(GETCURRENTTHREADID(),OFFSET_CLIENTTIMER));
  72. if (!DdeDisconnectList(hConvList)) {
  73. DDEMLERROR("DdeStrs.Exe -- DdeDisconnectList failed\r\n");
  74. }
  75. }
  76. VOID ReconnectList()
  77. {
  78. HCONV hConv;
  79. HCONVLIST hConvList=0;
  80. LONG cClienthConvs;
  81. INT i;
  82. DWORD dwid;
  83. dwid=GetThreadLong(GETCURRENTTHREADID(),OFFSET_IDINST);
  84. if(dwid==0) {
  85. DDEMLERROR("DdeStrs.Exe -- Null IdInst, aborting Connect!\r\n");
  86. return;
  87. }
  88. hConvList = DdeConnectList(dwid,
  89. ServiceInfoTable[0].hszService,
  90. Topics[0].hszTopic,
  91. GetThreadLong(GETCURRENTTHREADID(),OFFSET_HCONVLIST),
  92. NULL);
  93. if (hConvList == 0) {
  94. // This call is expected to fail in the case of a client
  95. // starting when there is no available server. Just return
  96. // from the routine and continue.
  97. return;
  98. }
  99. SetThreadLong(GETCURRENTTHREADID(),OFFSET_HCONVLIST,hConvList);
  100. hConv = 0;
  101. cClienthConvs = 0L;
  102. while (hConv = DdeQueryNextServer(hConvList, hConv)) {
  103. for (i=0; i<(int)Items[0].cFormats; i++) {
  104. if (iAvailFormats[i]) {
  105. if (!DdeClientTransaction( NULL,
  106. 0,
  107. hConv,
  108. Items[0].hszItem,
  109. TestItemFormats[i].wFmt,
  110. XTYP_ADVSTART|XTYPF_ACKREQ,
  111. TIMEOUT_ASYNC,
  112. NULL)){
  113. DDEMLERROR("DdeStrs.Exe -- Error DdeClientTransaction failed\r\n");
  114. return;
  115. } // if
  116. } // if
  117. } // for
  118. cClienthConvs++;
  119. } // while
  120. // Update the client count for the current thread.
  121. dwid=GETCURRENTTHREADID();
  122. SetThreadLong(dwid,OFFSET_CCLIENTCONVS,cClienthConvs);
  123. UpdateCount(hwndMain,OFFSET_CLIENT_CONNECT,PNT);
  124. }
  125.