Showing archive results for 2013

Aug 14, 2013
Post comments count0
Post likes count1

What's the point of letting you change the GCL_CBCLSEXTRA if it has no effect?

Raymond Chen

The documentation for the function mentions GCL_CB­CLS­EXTRA: Sets the size, in bytes, of the extra memory associated with the class. Setting this value does not change the number of extra bytes already allocated. What's the point of letting the application change a value if it has no effect? The class long grants access to the v...

Code
Aug 13, 2013
Post comments count0
Post likes count1

Generally speaking, yanking the power plug unexpectedly should not be part of your business process

Raymond Chen

A customer had a complex process for setting up their computers, and the process recorded information in the registry so that applications could record their state across reboots. They then noticed that if they yanked the power cord instead of going through the normal Shutdown process, that the registry keys were not reliably updated. They were won...

Other
Aug 12, 2013
Post comments count0
Post likes count1

Please don't wade across the Strait of Juan de Fuca

Raymond Chen

I dreamed that I was visiting a scenic location near the Canadian border. A central large body of water had the mainland to the south and east. A river ran southeast, spanned by a footbridge. To the northwest was another land mass, which had gained the nickname "Alaska" even though we were nowhere near Alaska. There was a gift shop on "Alaska", and...

Non-ComputerDream
Aug 12, 2013
Post comments count0
Post likes count1

How do I convert a synchronous file handle into an asynchronous one?

Raymond Chen

Say you opened a file in synchronous mode, and then you realize that you want to issue asynchronous I/O on it, too. One way to do this is to call a second time with the , but this requires you to know the file name, and the file name may not be readily available to the function that wants to do the conversion, or it may not even be valid any long...

Code
Aug 9, 2013
Post comments count0
Post likes count0

Each time I move, my mailbox moves further away

Raymond Chen

When I was growing up, the mailman letter carrier came right to our front door. The mailbox was mounted on the front of the house right next to the front door. You could check the mail without even getting dressed; just open the door a crack and stick out your hand. Approximate distance from front door to mailbox: less than 1 foot. In the nex...

Non-Computer
Aug 9, 2013
Post comments count0
Post likes count1

Why does the CLR report a NullReferenceException even if the referenced access is not exactly the null pointer?

Raymond Chen

We saw some time ago that before invoking a method on an object, the CLR will generate a instruction to force a null reference exception to be raised if you are trying to invoke a method on a null reference. But why does the CLR raise a if the faulting address is almost but not quite zero? When run, this program raises a rather than an . ...

Code
Aug 8, 2013
Post comments count0
Post likes count1

On partially-constructed objects, additional remarks, not as interesting

Raymond Chen

Don't worry. Our long national nightmare of CLR week is almost over. I had originally planned to write an article about partially-constructed objects, but in the time since I queued up the topic (back in November 2005) to the time I got around to writing it up, I found that Joe Duffy had already written it for me! On partially-constructed ob...

Code
Aug 7, 2013
Post comments count0
Post likes count1

Weak references have no effect on object lifetime

Raymond Chen

The class lets you retain a reference to an object while still permitting the object to be garbage collected. When that happens, then the property is and the property is . (Related discussion.) Note, however, that weak references do not alter the decision of the garbage collector whether or not an object is garbage. It merely lets you observe ...

Code
Aug 6, 2013
Post comments count0
Post likes count0

Sometimes sports-rule lawyering comes true: The strikeout with only one thrown pitch

Raymond Chen

Some time ago, I engaged in some sports-rule lawyering to try to come up with a way the losing team could manage to salvage a win without any remaining at-bats. It involved invoking a lot of obscure rules, but astonishingly one of the rules that I called upon was actually put into effect a few days ago. The Crawfish Boxes provides an entertaini...

Non-Computer