TagFacts -> user kuchin / quiz
2 11 12 4

notes 1 - 1 of 1:

2005-09-13

Sample quiz questions


Consider the following code fragment:

ShowWindow(hwnd, SW_SHOWNORMAL);
assert(IsWindowVisible(hwnd));

We just showed the window, certainly it is visible, right? Yet the assertion can fire (even in the absence of multi-threading). Why?

Answer below - stop reading if you want to try to solve it yourself.

Take a look at the IsWindowVisible function.

If the specified window, its parent window, its parent's parent window, and so forth, have the WS_VISIBLE style, the return value is nonzero. Otherwise, the return value is zero.

The WS_VISIBLE style indicates that this window is visible in its parent. But the parent itself might not be visible, in which case IsWindowVisible returns FALSE.

⁄⁄ in process A
hEventA = CreateEvent(NULL, FALSE, TRUE, TEXT("MyNamedEvent"));

⁄⁄ in process B
hEventB = OpenEvent(EVENT_MODIFY_STATE, FALSE, TEXT("MyNamedEvent"));
WaitForSingleObject(hEventB, INFINITE);

In Process B, the OpenEvent succeeds, but the WaitForSingleObject returns immediately instead of waiting. Explain.

You need to request the SYNCHRONIZE standard access right to an object in order to be able to use WaitForXxx on it. This was not done with the OpenEvent() call -- the handle returned by OpenEvent here can only be used with SetEvent⁄PulseEvent⁄ResetEvent.


tags:


kuchin - tags

1
3
1
1
1
2
3
1
1
1
2
1
1
13
2
4
1
5
1
1
1
5
1
3
2
1
1
1
1
2
4
4
1
1
1
1
1
6
tag cloud
alphabetical

other projects

MyProgs
Reader²

send to friend

your name:
your e-mail:
friend 1 e-mail:
friend 2 e-mail:
© 2005-2006 Synergy Matters | Design: Inforedesign | HTML Coding: Glench | Powered by Synergy 1001 engine