Showing tag results for Code

Sep 10, 2012
Post comments count0
Post likes count1

When you transfer control across stack frames, all the frames in between need to be in on the joke

Raymond Chen
Raymond Chen

Chris Hill suggests discussing the use of structured exception handling as it relates to the window manager, and specifically the implications for applications which raise exceptions from a callback. If you plan on raising an exception and handling it in a function higher up the stack, all the stack frames in between need to be be in on your li...

Code
Sep 6, 2012
Post comments count0
Post likes count1

You can't rule out a total breakdown of normal functioning, because a total breakdown of normal functioning could manifest itself as anything

Raymond Chen
Raymond Chen

A customer was attempting to study a problem that their analysis traced back to the function returning . Is it a valid conclusion that there is no heap corruption? While heap corruption may not be the avenue of investigation you'd first pursue, you can't rule it out. In the presence of a total breakdown of normal functioning, anything can happ...

Code
Aug 31, 2012
Post comments count0
Post likes count1

Adventures in undefined behavior: The premature downcast

Raymond Chen
Raymond Chen

A customer encountered the following problem: The function converts the cookie back to a object, and then checks if the object is a object by calling . If so, then it does some more stuff to figure out what type of paint to buy. (Note to nitpickers: The actual scenario was not like this, but I presented it this way to illustrate the point....

Code
Aug 30, 2012
Post comments count0
Post likes count1

I'm not calling a virtual function from my constructor or destructor, but I'm still getting a __purecall error

Raymond Chen
Raymond Chen

Some time ago, I described what is for: It's to detect the cases where you call a virtual method with no implementation (a so-called pure virtual method). This can happen during object constructor or destruction, since those are times when you can validly have a partially-implemented object. Well, there's another case this can happen: If the obj...

Code
Aug 28, 2012
Post comments count0
Post likes count1

Command line tool to manage Windows 7 Libraries, with source code

Raymond Chen
Raymond Chen

A customer asked if there was a command-line tool for managing Windows 7 Libraries so that they could create and deploy libraries across their organization. Not only is there such a tool, it even comes with source code. The Shell Library Command Line Sample shows how to manage Windows 7 libraries programmatically via the interface....

CodeTips/Support
Aug 23, 2012
Post comments count0
Post likes count1

Wait, you never said that I had to initialize the object before I used it!

Raymond Chen
Raymond Chen

A customer reported that they were having trouble creating slim reader/writer locks at runtime. They simplified the issue to a short program: "What is the correct way of creating an via the operator?" It wasn't long before somebody noted that nowhere in the code is the function called. "Oh, yeah, thanks for catching that. It looks like ...

Code
Aug 20, 2012
Post comments count0
Post likes count1

How do I customize how my application windows are grouped in the Taskbar?

Raymond Chen
Raymond Chen

Benjamin Smedberg wants to know how to customize the icon used in the Taskbar for applications that are grouped, when the application is a runtime for multiple applications. (This is the other scenario I hinted at last time.) Actually, customizing the icon is only part of what you want to happen when your application is a runtime. In that case...

Code
Aug 17, 2012
Post comments count0
Post likes count1

What if my application is really two applications bundled into a single file, and I want them collected into two groups on the taskbar in Windows 7?

Raymond Chen
Raymond Chen

A customer wanted to prevent multiple copies of their program from being grouped on the taskbar. They didn't give an explanation why, but let's assume that they are doing this for honorable purposes rather than as a way to annoy the user. For example, maybe their program is really multiple applications bundled inside a single EXE file for convenie...

Code
Aug 3, 2012
Post comments count0
Post likes count1

FORFILES, for your fancier batch file enumeration needs

Raymond Chen
Raymond Chen

Crack open open the champagne: Batch File Week is finally over! Variations on the will let you repeat an operation on the contents of a directory, possibly even recursively if you add the option, with some basic attribute-level filtering if you add the or /a- flags. For your fancy recursive file operations, there's a tool called which iter...

Code
Aug 2, 2012
Post comments count0
Post likes count1

Exiting a batch file without exiting the command shell -and- batch file subroutines

Raymond Chen
Raymond Chen

Prepare your party hats: Batch File Week is almost over. In your batch file, you may want to exit batch file processing (say, you encountered an error and want to give up), but if you use the command, that will exit the entire command processor. Which is probably not what you intended. Batch file processing ends when execution reaches the end...

Code