Showing tag results for Code

Jan 8, 2008
Post comments count0
Post likes count1

Taxes: Files larger than 4GB

Raymond Chen

Nowadays, a hard drive less than 20 gigabytes is laughably small, but it used to be that the capacity of a hard drive was measured in megabytes, not gigabytes. Today, video files and databases can run to multiple gigabytes in size, and your programs need be prepared for them. This means that you need to use 64-bit file offsets such as those used b...

Code
Jan 7, 2008
Post comments count0
Post likes count1

Clean-up functions can't fail because, well, how do you clean up from a failed clean-up?

Raymond Chen

Commenter Matt asks how you're supposed to handle failures in functions like or . Obviously, you can't. If a clean-up function fails, there's not much you can do because, well, how do you clean up from a failed clean-up? These clean-up functions fall into the category of "Must not fail for reasons beyond the program's control." If a program trie...

Code
Jan 4, 2008
Post comments count0
Post likes count1

What does it mean when a display change is temporary?

Raymond Chen

When you call the function, you can pass the flag to indicate that the change is temporary. But if you don't also save the changes in the registry, how can they be permanent? What does temporary mean? A temporary display change is one that your program has entered because it has gone into a fullscreen mode, a change which it will undo when it re...

Code
Jan 2, 2008
Post comments count0
Post likes count1

You know the answer: Window destruction

Raymond Chen

The following request for assistance came in from a customer, and given what you know about window destruction, you should eventually be able to figure it out yourself once all the pieces are in place, though it takes some time for all the clues to be revealed. We are hitting this exception in our program. This is urgent; please give it priorit...

Code
Dec 27, 2007
Post comments count0
Post likes count1

If you need anything other than natural alignment, you have to ask for it

Raymond Chen

If you need variables to be aligned a particular way, you need to ask for it. Let's say I have the following code: What would the alignment of the starting adresses of a,b,c and d be? What would the alignment be if the memory were allocated on heap? If this alignment varies for different data types within the same translation unit, is th...

Code
Dec 20, 2007
Post comments count0
Post likes count1

Consequences of the scheduling algorithm: Low priority threads can take 100% CPU

Raymond Chen

I see variations on this question occasionally. "Why is my low priority thread consuming 100% CPU?" Setting a thread to low priority doesn't mean that it won't consume lots of CPU. It just means that it doesn't get to run as long as there is a higher-priority thread ready to run. But if there is a CPU looking for something to do, and there is no h...

Code
Dec 19, 2007
Post comments count0
Post likes count1

How do I mark a shortcut file as requiring elevation?

Raymond Chen

Specifying whether elevation is required is typically something that is the responsibility of the program. This is done by adding a element to your manifest. (Bart De Smet shows you how. Calvin Hsia does the same for your Visual FoxPro programs.) But if the program you're running doesn't have such a manifest—maybe it's an old program that...

Code
Dec 13, 2007
Post comments count0
Post likes count1

AppInit_DLLs should be renamed Deadlock_Or_Crash_Randomly_DLLs

Raymond Chen

I have no idea why the window manager team added this feature to Windows NT. It basically says, "Hi, use this key to violate all the rules known to mankind about what can legitimately be done in a function. Oh, and be an attractive malware attack vector, too." I've debugged a few crashes that were traced back to the key. What makes them p...

Code
Dec 12, 2007
Post comments count0
Post likes count1

When selecting system colors, match but don't mix

Raymond Chen

Here's a question that came in from a customer: Is there a way to view all the Windows color schemes at once? We want to display text in the color against a background of , and we want to check that this looks good in all of the themes. A mistake I see from some programs is mixing system colors that are not meant to be mixed. The colors I'm tal...

Code
Nov 30, 2007
Post comments count0
Post likes count1

Hotkeys involving the Windows logo key are reserved by the system

Raymond Chen

Hotkeys involving the Windows logo key are reserved by the system. New ones are added over time. For example, Windows 98 added Win+D to show the desktop. Windows 2000 added Win+U to call up the Utility Manager. Windows XP added Win+B to move keyboard focus to the taskbar notification area. And a whole bunch of new hotkeys w...

Code