Showing tag results for Code

Jun 26, 2007
Post comments count0
Post likes count0

Why do DLGC_WANTALLKEYS and DLGC_WANTMESSAGE have the same value?

Raymond Chen
Raymond Chen

From a purely theoretical point of view, there is only one "want" code you really need: . All the others are just conveniences. For example, returning means "I want this message if it is an arrow key; otherwise, I don't care." It lets you write instead of the more cumbersome (but equivalent) Similarly, is equivalent to returning if the me...

Code
May 31, 2007
Post comments count0
Post likes count0

Visual C++ 2005 will generate manifests for you

Raymond Chen
Raymond Chen

New in Visual C++ 2005 is the ability to specify a manifest dependency via a directive. This greatly simplifies using version 6 of the shell common controls. You just have to drop the line into your program and the linker will do the rest. Note that the processor architecture is hard-coded into the above directive, which means that if ...

Code
May 29, 2007
Post comments count0
Post likes count0

Psychic debugging: Why does FormatMessage say the resource couldn't be found?

Raymond Chen
Raymond Chen

Solving this next problem should be a snap with your nascent psychic powers: I'm trying use to load a resource string with one insertion in it, and this doesn't work for some reason. The string is "Blah blah blah %1. Blah blah blah." The call to fails, and returns . What am I doing wrong? Hint: Take a closer look at the parameter . Hint&...

Code
May 25, 2007
Post comments count0
Post likes count0

The parameters to PostQueuedCompletionStatus are not interpreted

Raymond Chen
Raymond Chen

Larry Osterman mentioned this almost in passing quite a while ago, that the parameters to are not interpreted by the operating system. Well, obviously the first parameter, the handle to the completion port, is interpreted as the handle to the completion port. But the other parameters, , , and are not interpreted at all. Even though they have na...

Code
May 21, 2007
Post comments count0
Post likes count0

Don't be helpless: I don't know anything about MFC modal loops, but unlike some people, I'm not afraid to find out

Raymond Chen
Raymond Chen

Commenter Tom Grelinger asks via the Suggestion Box: If I have a modal CDialog that is visible and usable to the user. Let's say I receive an event somewhere else in the program and I call DestroyWindow on the modal CDialog from within the event. I notice that the OnDestroy is called on the CDialog, but DoModal never exits until a WM_QUIT is po...

Code
May 8, 2007
Post comments count0
Post likes count0

Session 0 isolation: Where backward compatibility loses to security

Raymond Chen
Raymond Chen

One of the major changes to services in Windows Vista is session 0 isolation. After reading the summary, you can follow that first supplementary link, Impact of Session 0 Isolation on Services and Drivers in Windows Vista, to dig deeper and receive guidance on how you need to modify your service. Then again, some of the questions I see regar...

Code
May 7, 2007
Post comments count0
Post likes count0

Drag and drop is a general purpose transfer model, not exclusive to Explorer directories

Raymond Chen
Raymond Chen

If you've designed your program so that it assumes that the the only thing a user can use drag/drop for is dropping your object into a file system directory, then you've already lost. piers wants to be able to determine the destination of a drag/drop operation. From the description, it appears that what piers really wants is the destination path,...

Code
May 4, 2007
Post comments count0
Post likes count1

How my lack of understanding of how processes exit on Windows XP forced a security patch to be recalled

Raymond Chen
Raymond Chen

Last year, a Windows security update got a lot of flack for causing some machines to hang, and it was my fault. (This makes messing up a demo at the Financial Analysts Meeting look like small potatoes.) The security fix addressed a category of attacks wherein people could construct shortcut files or other items which specified a CLSID that was neve...

Code
May 2, 2007
Post comments count0
Post likes count0

The old-fashioned theory on how processes exit

Raymond Chen
Raymond Chen

Life was simpler back in the old days. Back in the old days, processes were believed to be in control of their threads. You can see this in the "old fashioned" way of exiting a process, namely by exiting all the threads. This method works only if the process knows about all the threads running in it and can get each one to clean up when it's time ...

Code
Apr 30, 2007
Post comments count0
Post likes count0

The default verb is not necessarily "open"

Raymond Chen
Raymond Chen

If you hunt around the Internet you'll find lots of people† who hard-code the string as the second parameter to the function, indicating that they want to open the document specified as the third parameter. While that's a nice thing to want to do, it might not be the right thing. When the user double-clicks a document, the shell executes ...

Code