Showing tag results for Code

Dec 13, 2007
Post comments count0
Post likes count1

AppInit_DLLs should be renamed Deadlock_Or_Crash_Randomly_DLLs

Raymond Chen
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
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
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
Nov 28, 2007
Post comments count0
Post likes count2

The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag

Raymond Chen
Raymond Chen

You can use the message with the flag to indicate that the message number you passed is an error code and that the message should be looked up in the system message table. This is a specific case of the more general case where you are not in control of the message, and when you are not in control of the message, you had better pass the flag. ...

Code
Nov 23, 2007
Post comments count0
Post likes count1

The forgotten common controls: The GetEffectiveClientRect function

Raymond Chen
Raymond Chen

The function is another one in the category of functions that everybody tries to pretend doesn't exist. It's not as bad as , but it's still pretty awful. The idea behind the function is that you have a frame window with a bunch of optional gadgets, such as a status bar or toolbar. The important thing is that these optional gadgets all reside at...

Code
Nov 19, 2007
Post comments count0
Post likes count1

If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Raymond Chen
Raymond Chen

Commenter praful asks what to me is a rather confused question, but I'll try to guess what the real question is. If you drag My Computer to the Start button in XP, you get an expanding menu that lets you see all files and folders as submenus. Is this menu available to applications via an API, or do you have to build it yourself? For example, c...

Code
Nov 12, 2007
Post comments count0
Post likes count1

I don't know what the Lotus internal clipboard formats are either

Raymond Chen
Raymond Chen

Apparently some people think my psychic powers extend to being able to steal trade secrets by sheer force of concentration. I've been trying to write an application which allows to drag and drop documents from lotus notes. If I just drag and drop a document from lotus notes to Windows explorer, it creates a .shb file (regular windows document li...

Code
Nov 9, 2007
Post comments count0
Post likes count1

You just have to accept that the file system can change

Raymond Chen
Raymond Chen

A customer who is writing some sort of code library wants to know how they should implement a function that determines whether a file exists. The usual way of doing this is by calling , but what they've found is that sometimes will report that a file exists, but when they get around to accessing the file, they get the error . The lesser questi...

CodeThings I've written that have amused other people
Nov 6, 2007
Post comments count0
Post likes count0

VirtualLock only locks your memory into the working set

Raymond Chen
Raymond Chen

When you lock memory with it locks the memory into your process's working set. It doesn't mean that the memory will never be paged out. It just means that the memory won't be paged out as long as there is a thread executing in your process, because a process's working set need be present in memory only when the process is actually executing. (Ear...

Code
Nov 5, 2007
Post comments count0
Post likes count2

Why do we even have the DefWindowProc function?

Raymond Chen
Raymond Chen

Some time ago, I looked at two ways of reimplementing the dialog procedure (method 1, method 2). Commenter "8" wondered why we have a function at all. Couldn't window procedures have followed the dialog box model, where they simply return to indicate that they want default processing to occur? Then there would be no need to export th...

Code