Code

You are currently browsing the articles from MS Windows Articles, Reviews and Videos matching the category Code.

How did the invalid floating point operand exception get raised when I disabled it?

Last time, we learned about the dangers of uninitialized floating point variables but left with a puzzle: Why wasn't this caught during internal testing? I dropped a hint when I described how SNaN s work: You have to ask the processor to raise an exception Read More......(read more)

Written by The Old New Thing : Code on July 3rd, 2008 with no comments.
Read more articles on 1340 and 1354 and 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and 544 and Code and Contributors.

Uninitialized floating point variables can be deadly

A colleague of mine related to me this story about uninitialized floating point variables. He had a function that went something like this, simplified for expository purposes. The infoType parameter specified which piece of information you're requesting, Read More......(read more)

Written by The Old New Thing : Code on July 2nd, 2008 with no comments.
Read more articles on 1340 and 1354 and 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and 544 and Code and Contributors.

GUIDs are globally unique, but substrings of GUIDs aren’t

A customer needed to generate an 8-byte unique value, and their initial idea was to generate a GUID and throw away the second half, keeping the first eight bytes. They wanted to know if this was a good idea. No, it's not a good idea. The GUID generation Read More......(read more)

Written by The Old New Thing : Code on June 27th, 2008 with no comments.
Read more articles on 1340 and 1354 and 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and 544 and Code and Contributors.

Just because you’re using a smart pointer class doesn’t mean you can abdicate understanding what it does

It's great when you have a tool to make programming easier, but you still must understand what it does or you're just replacing one set of problems with another set of more subtle problems. For example, we discussed earlier the importance of knowing when Read More......(read more)

Written by The Old New Thing : Code on June 23rd, 2008 with no comments.
Read more articles on 1340 and 1354 and 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and 544 and Code and Contributors.

How do the common controls convert between ANSI and Unicode?

Commenter Chris Becke asks how the common controls convert ANSI parameters to Unicode , since the common controls are Unicode internally. Everything goes through CP_ACP , pretty much by definition. The ANSI code page is CP_ACP . That's what ACP stands Read More......(read more)

Written by The Old New Thing : Code on June 16th, 2008 with no comments.
Read more articles on 1340 and 1354 and 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and 544 and Code and Contributors.

If you say that you don’t care about something, you shouldn’t be upset that it contains garbage

There are many situations where you pass a structure to a function, and the function fills in the structure with information you request. In some cases, the function always fills in the entire structure (example: GlobalMemoryStatus ). In other cases, Read More......(read more)

Written by The Old New Thing : Code on June 11th, 2008 with no comments.
Read more articles on 1340 and 1354 and 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and 544 and Code and Contributors.

Why are DLLs uninitialized in the “wrong” order?

This is really just a corollary to Why are DLLs unloaded in the "wrong" order . Exactly the same logic that explains why DLLs are unloaded in the "wrong" order also explains why they are uninitialized in the "wrong" order. Once you understand the first Read More......(read more)

Written by The Old New Thing : Code on June 9th, 2008 with no comments.
Read more articles on 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and Code and Contributors.

Why does OpenProcess succeed even when I add three to the process ID?

A customer noticed that if you add three to a process ID and pass it to the OpenProcess function, it still succeeds. Why is that? Well, first of all, I need to say up front that the behavior you're seeing is an artifact of the implementation and is not Read More......(read more)

Written by The Old New Thing : Code on June 6th, 2008 with no comments.
Read more articles on 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and Code and Contributors.

Why are accelerators for hidden controls still active?

In the suggestion box, Serge Wautier asked why accelerators for hidden controls remain active . He's apparently rather insistent because he asked the question again a few months later . Asking the same question multiple times reduces the likelihood that Read More......(read more)

Written by The Old New Thing : Code on June 2nd, 2008 with no comments.
Read more articles on 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and Code and Contributors.

Reading a contract from the other side: SHSetInstanceExplorer and SHGetInstanceExplorer

Shell extensions that create worker threads need to call the SHGetInstanceExplorer function so that Explorer will not exit while the worker thread is still running. When your worker thread finishes, you release the IUnknown that you obtained to tell the Read More......(read more)

Written by The Old New Thing : Code on May 28th, 2008 with no comments.
Read more articles on 1426 and 1429 and 1673 and 169 and 2065 and 2157 and 401 and Code and Contributors.

« Older articles

No newer articles