The Old New Thing

QueryPerformanceCounter is not a source for unique identifiers

This article happened to catch my eye: I needed to generate some unique number in my application. I could use GUID, but it was too large for me (I need to keep lots of unique identifiers). I found something like this: This code generates Int64 (long) unique number (at least I hope it is unique). The uniqueness is in the scope of ...

If the system says that an embedded string could not be converted from Unicode to ANSI, maybe it's trying to tell you something

It's probably trying to tell you that an embedded string could not be converted from Unicode to ANSI. One of our programs is throwing the exception "Type could not be marshaled because an embedded string could not be converted from Unicode to ANSI." It happens only if we use the Chinese version of the program. Why are we getting this ...

Don't forget to pass the current directory along with the command line to your single-instance program

If you make a single-instance program, and somebody runs a second copy of the program and passes a command line, the most common way of handling this is to hand the command line to the first copy of the program and let the first copy deal with it. When you do this, don't forget about the current directory. If somebody passes a relative path...

Why do DLGC_WANTALLKEYS and DLGC_WANTMESSAGE have the same value?

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 ...

Visual C++ 2005 will generate manifests for you

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 ...

The parameters to PostQueuedCompletionStatus are not interpreted

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 ...

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

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 ...

Session 0 isolation: Where backward compatibility loses to security

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 ...