Microsoft KB Archive/249315: Difference between revisions
m (1 revision imported: importing part 2) |
m (Text replacement - """ to """) |
||
(One intermediate revision by the same user not shown) | |||
Line 53: | Line 53: | ||
while (1){ | while (1){ | ||
if (!WTSWaitSystemEvent(WTS_CURRENT_SERVER_HANDLE, WTS_EVENT_ALL, & | if (!WTSWaitSystemEvent(WTS_CURRENT_SERVER_HANDLE, WTS_EVENT_ALL, &dwEvent)) | ||
{ | { | ||
printf( | printf("WTSWaitSystemEvent failed with %u\n", GetLastError()); | ||
break; | break; | ||
} | } | ||
if (dwEvent & | if (dwEvent & WTS_EVENT_CONNECT) | ||
printf( | printf("WTS_EVENT_CONNECT "); | ||
if (dwEvent & | if (dwEvent & WTS_EVENT_CREATE) | ||
printf( | printf("WTS_EVENT_CREATE "); | ||
if (dwEvent & | if (dwEvent & WTS_EVENT_DELETE) | ||
printf( | printf("WTS_EVENT_DELETE "); | ||
if (dwEvent & | if (dwEvent & WTS_EVENT_DISCONNECT) | ||
printf( | printf("WTS_EVENT_DISCONNECT "); | ||
if (dwEvent & | if (dwEvent & WTS_EVENT_LOGOFF) | ||
printf( | printf("WTS_EVENT_LOGOFF "); | ||
if (dwEvent & | if (dwEvent & WTS_EVENT_LOGON) | ||
printf( | printf("WTS_EVENT_LOGON "); | ||
if (dwEvent & | if (dwEvent & WTS_EVENT_RENAME) | ||
printf( | printf("WTS_EVENT_RENAME "); | ||
if (dwEvent & | if (dwEvent & WTS_EVENT_STATECHANGE) | ||
printf( | printf("WTS_EVENT_STATECHANGE "); | ||
printf( | printf("\n"); | ||
} </pre> | } </pre> | ||
If you run the code on a terminal server computer, events are reported twice. For example, if a new session is started, WTS_EVENT_CREATE is reported twice, then WTS_EVENT_LOGON occurs twice, and so on. | If you run the code on a terminal server computer, events are reported twice. For example, if a new session is started, WTS_EVENT_CREATE is reported twice, then WTS_EVENT_LOGON occurs twice, and so on. |
Latest revision as of 13:51, 21 July 2020
BUG: WTSWaitSystemEvent Returns Terminal Services Event Twice |
Q249315
The information in this article applies to:
- Microsoft Win32 Application Programming Interface (API), used with:
- Microsoft Windows NT Server version 4.0
- Microsoft Windows NT Workstation version 4.0
- the operating system: Microsoft Windows 2000
SYMPTOMS
When using WTSWaitSystemEvent in a tight loop, events are reported twice for each actual event.
RESOLUTION
The application should expect the event twice, and filter out the second occurrence.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
MORE INFORMATION
Steps to Reproduce Behavior
Compile a program that executes the following code:
DWORD dwEvent; while (1){ if (!WTSWaitSystemEvent(WTS_CURRENT_SERVER_HANDLE, WTS_EVENT_ALL, &dwEvent)) { printf("WTSWaitSystemEvent failed with %u\n", GetLastError()); break; } if (dwEvent & WTS_EVENT_CONNECT) printf("WTS_EVENT_CONNECT "); if (dwEvent & WTS_EVENT_CREATE) printf("WTS_EVENT_CREATE "); if (dwEvent & WTS_EVENT_DELETE) printf("WTS_EVENT_DELETE "); if (dwEvent & WTS_EVENT_DISCONNECT) printf("WTS_EVENT_DISCONNECT "); if (dwEvent & WTS_EVENT_LOGOFF) printf("WTS_EVENT_LOGOFF "); if (dwEvent & WTS_EVENT_LOGON) printf("WTS_EVENT_LOGON "); if (dwEvent & WTS_EVENT_RENAME) printf("WTS_EVENT_RENAME "); if (dwEvent & WTS_EVENT_STATECHANGE) printf("WTS_EVENT_STATECHANGE "); printf("\n"); }
If you run the code on a terminal server computer, events are reported twice. For example, if a new session is started, WTS_EVENT_CREATE is reported twice, then WTS_EVENT_LOGON occurs twice, and so on.
Additional query words:
Keywords : kbAPI kbKernBase kbOSWinNT400bug kbOSWin2000bug kbDSupport kbGrpDSKernBase kbTermServ
Issue type : kbbug
Technology : kbAudDeveloper kbWin32sSearch kbWin32API
Last Reviewed: October 23, 2000 |