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.

113 lines
2.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1994 - 1999
  3. Module Name:
  4. Async.c
  5. Abstract:
  6. Some common routines for the Async tests.
  7. Author:
  8. Kamen Moutafov (kamenm) 20-Apr-1998
  9. Revision History:
  10. --*/
  11. #include <rpcperf.h>
  12. unsigned int RPC_ENTRY WindowProc(IN void * hWnd, IN unsigned int Message,
  13. IN unsigned int wParam, IN unsigned long lParam)
  14. {
  15. LRESULT Res = 0;
  16. if (Message == PERF_TEST_NOTIFY)
  17. {
  18. // no-op
  19. }
  20. else
  21. {
  22. Res = DefWindowProc((HWND)hWnd, Message, wParam, lParam);
  23. }
  24. return (unsigned int)Res;
  25. }
  26. void RunMessageLoop(HWND hWnd)
  27. {
  28. MSG msg;
  29. UINT nTimerID = 1;
  30. SetTimer(hWnd, nTimerID, 5000, NULL);
  31. // run the message loop
  32. while (GetMessage(&msg, 0, 0, 0))
  33. {
  34. TranslateMessage(&msg);
  35. DispatchMessage(&msg);
  36. }
  37. KillTimer(hWnd, nTimerID);
  38. }
  39. void PumpMessage(void)
  40. {
  41. MSG msg;
  42. GetMessage(&msg, NULL, 0, 0);
  43. TranslateMessage(&msg);
  44. DispatchMessage(&msg);
  45. }
  46. HWND CreateSTAWindow(char *lpszWinName)
  47. {
  48. HWND hWnd;
  49. WNDCLASSA wc;
  50. DWORD dwCurProcessId;
  51. char WNDCLASSNAME[100];
  52. dwCurProcessId = GetCurrentProcessId();
  53. wsprintfA(WNDCLASSNAME, "Windows WMSG BVT %lx", dwCurProcessId);
  54. if (GetClassInfoA(GetModuleHandle(NULL), WNDCLASSNAME, &wc) == FALSE)
  55. {
  56. DWORD dwError;
  57. dwError = GetLastError();
  58. wc.style = 0;
  59. wc.lpfnWndProc = (WNDPROC) WindowProc;
  60. wc.cbWndExtra = 4;
  61. wc.cbClsExtra = 0;
  62. wc.hInstance = GetModuleHandle(NULL);
  63. wc.hIcon = NULL;
  64. wc.hCursor = NULL;
  65. wc.hbrBackground = NULL;
  66. wc.lpszMenuName = NULL;
  67. wc.lpszClassName = WNDCLASSNAME;
  68. if (RegisterClassA(&wc) == 0)
  69. {
  70. return (NULL);
  71. }
  72. }
  73. // Create hidden window to receive RPC messages
  74. hWnd = CreateWindowExA(WS_EX_NOPARENTNOTIFY,
  75. WNDCLASSNAME,
  76. "temp",
  77. WS_OVERLAPPEDWINDOW | WS_CHILD | WS_POPUP,
  78. CW_USEDEFAULT,
  79. CW_USEDEFAULT,
  80. CW_USEDEFAULT,
  81. CW_USEDEFAULT,
  82. GetDesktopWindow(),
  83. (HMENU)NULL,
  84. GetModuleHandle(NULL),
  85. (LPVOID)0);
  86. SetWindowLongPtr(hWnd, GWLP_USERDATA, (long)GetCurrentThreadId());
  87. SetWindowTextA(hWnd, lpszWinName);
  88. return (hWnd);
  89. }