Another round of short answers to questions in the suggestion box.
- How does Windows choose the monitor a window maximizes to?
-
The window maximizes to the monitor selected by
MonitorFromWindow
. The algorithm theMonitorFromWindow
uses to select the monitor is documented in MSDN. - How do you make your Win32 application safe from keyloggers?
-
You can’t. In the battle between kernel mode and user mode, user mode loses. That’s why we have a distinction between kernel mode and user mode in the first place.
- Why should you ever call MessageBox from inside a message handler that is re-entrant? “I’m having a hard time explaining to people that it isn’t a blocking call.”
-
I don’t even understand the question. And it is a blocking call. The function doesn’t return until the user responds to the message box.
- What happens when you pass NULL to ShellExecute, like you did in one of your articles? “Is UI suppressed if I pass NULL?”
-
The window handle is used as the parent for any dialogs or messages that the
ShellExecute
function may need to display. If you passNULL
, then you get the same effect as if you had passedNULL
to, say,MessageBox
. In the article, the thread has no UI active, so any error messages displayed by theShellExecute
function will appear as top-level unowned windows. I discussed this issue in detail a few years ago. If you want to suppress UI, then pass theSEE_MASK_FLAG_NO_UI
flag toShellExecuteEx
. - Is there some way to use Explorer’s filename sort function?
-
It’s called
StrCmpLogical
. Michael Kaplan discussed this function two years ago with a follow-up last year. Of course, if you want to mimic Explorer exactly, you also need to respect theREST_NOSTRCMPLOGICAL
policy. - Is there a way to sleep for less than one millisecond?
-
I don’t know either. I’ve never needed to do that. (I try to get eight hours each night.)
- Why are notification icons limited to 16 colors in Windows 95 and 2000?
-
They were limited to 16 colors on Windows 95 to conserve memory. Windows 2000 inherited that code and by default, each version of Windows works the same as the previous one. There are millions of lines of code in the shell. It’s not like somebody goes through every single one of them and says, “Gosh, should we change this line in the next version of Windows?”
- Does Raymond use _alloca?
-
Nope. It wasn’t in K&R C, so it’s not part of my world view. And incautious use of
_alloca
can result in security vulnerabilities. - Windows can only handle 64 threads.
-
This statement is patently false. We’ve seen that even without taking any special precautions, we were able to pack about 2000 threads into a process before running out of address space. What the person probably meant to write is that 32-bit Windows supports a maximum of 32 processors. The reason is that the functions that manage sets of processors (such as
SetThreadAffinity
) use a 32-bit value to represent processor masks. Note that for 64-bit Windows, these masks were expanded to 64-bit integers, so 64-bit Windows supports up to 64 processors in principle. - How does that Temporary Internet Files thing work?
-
It’s a shell namespace extension junction point.
- Why are some count parameters declared as signed integers?
-
I don’t think there’s a profound reason for it. Each API designer is empowered to decide how their functions will work. After all, the original
strlen
function returned a signed integer, too. You might want to ask Brian Kernighan; he was doing it before Windows. (Signed integers do have the slight advantage of being resilient to integer underflow. Ifa
andb
are both non-negative integers, thena - b
will never underflow.) - Why does the desktop lose track of icons, so it has to refresh them?
-
I’m not sure what you mean by “lose track of icons”. Maybe you’re asking about lost change notifications (in which case redirected folders can cause problems with lost network notifications). Or maybe you’re talking about icon repositioning (maybe the previous icon locations weren’t saved).
- Questions about DLL imports, exports, and cross-module memory
-
I inadvertently answered this question in a rather long series of articles on DLL imports and exports, and a discussion of cross-module memory allocation.
- I want to see your blog stats.
-
I thought that too, until I saw them. When you get over a million hits a month, a list of all the referrals is just a giant pile of noise. I haven’t bothered analyzing the referrals because I have other things to do in my spare time that are more interesting.
- I’d love to see a series of things that are obvious to you but not obvious to everyone.
-
How do I know what is obvious to me and not obvious to everyone?
The next category is, of course, the people who ask questions on things that I listed as topics I am not inclined to cover.
- I have a problem (describes problem).
-
I don’t think your problem really is of general interest. But it’s clear that you’re not respecting the modality of the window.
- I’m trying to improve the performance of my specific scenario.
-
This doesn’t strike me as a topic of general interest.
- What are your thoughts on this research project? What are your thoughts on this Microsoft product?
-
I think you confused me with Robert Scoble.
- I have a problem (describes problem).
-
This doesn’t strike me as a topic of general interest.
- Why does Internet Explorer do X?
-
Internet Explorer is explicitly on the list of things I am unlikely to cover.
Or the people who ask questions I’ve already answered or questions I’ve chosen to answer elsewhere.
- Help me modify files that I didn’t write.
- What is the long pause after listing a directory the first time?
- Answered in A brief and incomplete history of FAT32.
And then there are the questions I can’t or choose not to answer.
- Why does the window manager force windows fully on-screen when the workstation is unlocked?
-
I don’t know either. It makes sense to force windows on-screen after a change in resolution, but if the resolution didn’t change between the lock and the unlock, there’s really no need to go around “fixing up” window positions.
- What did Apple copy from Microsoft and vice versa?
-
I’m not going to touch this one. I don’t see any upside to my answering it, only downside, and I don’t welcome the flamewar that will doubtless ensue.
- Do you know anything about this?
-
No.
- Something about defragmenting.
-
I have no special knowledge about defragmentation. Try The Filing Cabinet. They answered a few questions in one blog entry and even have a Defrag FAQ. Personally, I’ve been happy with Dave Whitney’s defragmenter to defragment specifically-targeted files. (I don’t defragment my entire drive because it seems like a waste of time.)
- A question about Aero glass
-
I have no special knowledge about Aero glass.
- How about an under-the-hood look at the Windows Vista Start menu?
-
I didn’t work on the Windows Vista Start menu, so I don’t know how it works.
- Do you have any insights into the evolution of WinHelp?
-
Sorry, I’m an outsider just like you when it comes to help technologies.
- Long rambling question about
ACCESS_DENIED
-
I quickly lost interest.
- Please explain the subtleties of the ScrollWindowEx function when scrolling child windows.
-
I don’t know the answer and I don’t feel like doing the research necessary to find out. Sorry. The fact that I left it unanswered from the previous suggestion box should have been a clue.
That’s all for this year.
0 comments