Showing results for Code - The Old New Thing

Jul 23, 2004
0
0

Why do some process stay in Task Manager after they’ve been killed?

Raymond Chen
Raymond Chen

When a process ends (either of natural causes or due to something harsher like TerminateProcess), the user-mode part of the process is thrown away. But the kernel-mode part can't go away until all drivers are finished with the thread, too. For example, if a thread was in the middle of an I/O operation, the kernel signals to the driver res...

Code
Jul 20, 2004
0
1

Querying information from an Explorer window

Raymond Chen
Raymond Chen

Sometimes software development is inventing new stuff. But often, it's just putting together the stuff you already have. Today's puzzle is one of the latter type of problem. Given a window handle, you can you determine (1) whether it is an Explorer window, and if so (2) what folder it is viewing, and (3) what item is currently foc...

Code
Jul 19, 2004
0
0

Wrapper templates to make writing callback functions slightly easier

Raymond Chen
Raymond Chen

I previously discussed why callback functions must be static if they are member functions. Writing the correct prototype for the callback function is usually somewhat clumsy. It's not hard. Just clumsy. (If you read my previous article, you'd recognizing sticking a __stdcall in the declaration for RealThreadProc as a micro-optimization.) Every c...

Code
Jul 16, 2004
0
0

How to display a string without those ugly boxes

Raymond Chen
Raymond Chen

You've all seen those ugly boxes. When you try to display a string and the font you have doesn't support all of the characters in it, you get an ugly box for the characters that aren't available in the font. Start with our scratch program and add this to the function: That string contains the first three letters from three different alphab...

Code
Jul 15, 2004
0
1

Don't forget to #define UNICODE if you want Unicode

Raymond Chen
Raymond Chen

I answered this comment directly, but it deserves reiteration with wider visibility. If you don't #define UNICODE, you get ANSI by default. If you want to see characters beyond the boring 7-bit ASCII, make sure you are using a font that can display those characters. I am assuming a level of competence where issues like this go without s...

Code
Jul 15, 2004
0
1

Don’t forget to #define UNICODE if you want Unicode

Raymond Chen
Raymond Chen

I answered this comment directly, but it deserves reiteration with wider visibility. If you don't #define UNICODE, you get ANSI by default. If you want to see characters beyond the boring 7-bit ASCII, make sure you are using a font that can display those characters. I am assuming a level of competence where issues like this go without s...

Code
Jul 12, 2004
0
0

Positioned vs. non-positioned listview views

Raymond Chen
Raymond Chen

Occasionally, I'll see a question that betrays a lack of understanding of difference between the positioned and non-positioned listview views. The question usually goes along the lines of "I inserted an item with LVM_INSERTITEM but it went to the end of the list instead of in the location I inserted it." To understand what is going on, you ne...

Code
Jul 7, 2004
0
0

Obtaining a window's size and position while it is minimized

Raymond Chen
Raymond Chen

If you have a minimized window and want to know where it will go when you restore it, the GetWindowPlacement function will tell you. In particular, the tells you where the window would go if it were restored (as opposed to minimized or maximized). One perhaps-non-obvious flag is WPF_RESTORETOMAXIMIZED. This flag indicates that the window...

Code