Showing tag results for Code

Mar 12, 2004
Post comments count0
Post likes count0

What is the default security descriptor?

Raymond Chen

All these functions have an optional LPSECURITY_ATTRIBUTES parameter, for which everybody just passes NULL, thereby obtaining the default security descriptor. But what is the default security descriptor? Of course, the place to start is MSDN, in the section titled Security Descriptors for New Objects. It says that the default DACL comes from ...

Code
Mar 9, 2004
Post comments count0
Post likes count0

Char.IsDigit() matches more than just "0" through "9"

Raymond Chen

Warning: .NET content ahead! Yesterday, Brad Abrams noted that Char.IsLetter() matches more than just "A" through "Z". What people might not realize is that Char.IsDigit() matches more than just "0" through "9". Valid digits are members of the following category in UnicodeCategory: DecimalDigitNumber. But what exactly is a DecimalDigitNumber? ...

Code
Feb 27, 2004
Post comments count0
Post likes count1

The correct order for disabling and enabling windows

Raymond Chen

If you want to display modal UI, you need to disable the owner and enable the modal child, and then reverse the procedure when the modal child is finished. And if you do it wrong, focus will get all messed up. If you are finished with a modal dialog, your temptation would be to clean up in the following order: But if you do that, you'll...

Code
Feb 24, 2004
Post comments count0
Post likes count0

What's so special about the desktop window?

Raymond Chen

The window returned by GetDesktopWindow() is very special, and I see people abusing it all over the place. For example, many functions in the shell accept a window handle parameter to be used in case UI is needed. IShellFolder::EnumObjects, for example. What happens if you pass GetDesktopWindow()? If UI does indeed need to be displaye...

Code
Feb 23, 2004
Post comments count0
Post likes count1

Invalid thread and process IDs

Raymond Chen

Perhaps you want a value to use as a sentinel, which you want to be guaranteed is never a valid thread ID or process ID. What values can you use? Nothing is explicitly written about this topic, but you can put on your logic cap and figure it out. If you need an invalid thread ID, you can use zero. How do you know that zero is an invalid thr...

Code
Feb 17, 2004
Post comments count0
Post likes count2

GetDialogBaseUnits is a crock

Raymond Chen

Each dialog can have different base units, so it's meaningless to have a global converter.

Code
Feb 10, 2004
Post comments count0
Post likes count1

Answer to exercise: Pointer to member function cast

Raymond Chen

Yesterday's exercise asked you to predict and explain the codegen for the following fragment: Well, the codegen might go something like this: Let's use one of our fancy pictures: Just for fun, I swapped the order of Base1 and Base2. There is no requirement in the standard about the order in which storage is allocated for base classes, so ...

Code