Showing tag results for Code

Dec 4, 2014
Post comments count0
Post likes count1

If my WM_TIMER handler takes longer than the timer period, will my queue fill up with WM_TIMER messages?

Raymond Chen

A customer was worried that they may have a problem with their message queue filling with messages. "If my handler takes longer than the timer period, will my queue fill up with messages?" As we should know by now, timer messages are generated on demand: The WM_TIMER message is a low-priority message. The Get­Message and Peek­Message ...

Code
Dec 3, 2014
Post comments count0
Post likes count1

What happens if I don't paint when I get a WM_PAINT message?

Raymond Chen

Suppose your window procedure doesn't paint when it gets a message. What happens? It depends on how you don't paint. If you have an explicit handler for the message that does nothing but return without painting, then the window manager will turn around and put a new message in your queue. "And try harder this time." Remember that the rules ...

Code
Dec 1, 2014
Post comments count0
Post likes count2

Counting array elements which are below a particular limit value using SSE

Raymond Chen

Some time ago, we looked at how doing something can be faster than not doing it. That is, we observed the non-classical effect of the branch predictor. I took the branch out of the inner loop, but let's see how much further I can push it. The trick I'll employ today is using SIMD in order to operate on multiple pieces of data simultaneously. Ta...

Code
Nov 28, 2014
Post comments count0
Post likes count2

A user's SID can change, so make sure to check the SID history

Raymond Chen

It doesn't happen often, but a user's SID can change. For example, when I started at Microsoft, my account was in the SYS-WIN4 domain, which is where all the people on the Windows 95 team were placed. At some point, that domain was retired, and my account moved to the REDMOND domain. We saw some time ago that the format of a user SID is T...

Code
Nov 27, 2014
Post comments count0
Post likes count1

Some light reading on lock-free programming

Raymond Chen

Today is a holiday in the United States, so I'm going to celebrate by referring you to other things to read. I'm going to start with a presentation by Bruce Dawson at GDC 2009, which is basically multiple instances of the question "Is this code correct?", and the answer is always "No!" Although the title of the talk is Lockless Programming in Game...

Code
Nov 24, 2014
Post comments count0
Post likes count1

The crazy world of stripping diacritics

Raymond Chen

Today's Little Program strips diacritics from a Unicode string. Why? Hey, I said that Little Programs require little to no motivation. It might come in handy in a spam filter, since it was popular, at least for a time, to put random accent marks on spam subject lines in order to sneak past keyword filters. (It doesn't seem to be popular any more.)...

Code
Nov 21, 2014
Post comments count0
Post likes count2

Is it wrong to call SHFileOperation from a service? Revised

Raymond Chen

My initial reaction to this question was to say, "I don't know if I'd call it wrong, but I'd call it highly inadvisable." I'd like to revise my guidance. It's flat-out wrong, at least in the case where you call it while impersonating. The registry key is bound to the current user at the time the key is first accessed by a process: The mapping...

Code
Nov 20, 2014
Post comments count0
Post likes count1

A library loaded via LOAD_LIBRARY_AS_DATAFILE (or similar flags) doesn't get to play in any reindeer module games

Raymond Chen

If you load a library with the flag, then it isn't really loaded in any normal sense. In fact, it's kept completely off the books. If you load a library with the , , or flag (or any similar flag added in the future), then the library gets mapped into the process address space, but it is not a true module. Functions like , , and will not see th...

Code
Nov 17, 2014
Post comments count0
Post likes count1

How do I enumerate drives the same way that the NET USE command does?

Raymond Chen

If you use the Remote Desktop Connection client to connect to another computer, you have the option of making your local drives available to the remote computer. A customer wanted to know how to enumerate all the drives on the local machine. The were able to get the volumes mapped to drive letters, but they also wanted to get the redirected dri...

Code
Nov 13, 2014
Post comments count0
Post likes count1

When does GetTickCount consider the system to have started?

Raymond Chen

The and functions return "the number of milliseconds that have elapsed since the system was started." (The 32-bit version wraps around after around 50 days.) But when exactly is the system considered to have started? Is it when power is applied to the computer? When the BIOS completes POST? When the user picks the operating system from the boot m...

Code