Showing tag results for Code

Oct 4, 2012
Post comments count0
Post likes count1

Why does RegOpenKey sometimes (but not always) fail if I use two backslashes instead of one?

Raymond Chen
Raymond Chen

A customer reported that on Windows XP, they observed that their program would very rarely get the error when they passed two backslashes instead of one to the function: After removing C++ escapes, the resulting string passed to is The failure was very sporadic and not reproducible under controlled conditions. Well, first of all, d...

Code
Oct 3, 2012
Post comments count0
Post likes count1

How do I suppress the default animation that occurs when I hide or show a window?

Raymond Chen
Raymond Chen

A customer wanted to know how they can disable the default fade-in/fade-out animation that occurs when a window is hidden or shown. "I don't want to use because that causes my window to disappear from the taskbar. I tried but that affects the entire desktop and is too jarring. We want to suppress the effect because our program replaces one windo...

Code
Sep 27, 2012
Post comments count0
Post likes count1

Why aren't environment variables being expanded in my RGS file?

Raymond Chen
Raymond Chen

A customer was having trouble with their RGS file. I want to include the below line in a .rgs file: When I do this, registering of the dll fails with 80002009. Any help? If I change it to then the registration succeeds (but of course now contains a hard-coded path). A common problem people have when asking a question is assuming that th...

Code
Sep 26, 2012
Post comments count0
Post likes count1

Sabotaging yourself: Closing a handle and then using it

Raymond Chen
Raymond Chen

A customer reported a problem with the function: I have a DLL with an function and an function. The code goes like this: Under certain conditions, the function is called twice, and the function is correspondingly called twice. Under these conditions, if I run the code on a single-processor system with hyperthreading disabled, then every...

Code
Sep 21, 2012
Post comments count0
Post likes count1

How can I implement SAFEARRAY.ToString() without going insane?

Raymond Chen
Raymond Chen

A colleague needed some help with manipulating s. I have some generic code to execute WMI queries and store the result as strings. Normally, does the work, but doesn't know how to convert arrays (e.g. ). And there doesn't seem to be an easy way to convert the array element-by-element because expects a pointer to an object of the underlying ty...

Code
Sep 20, 2012
Post comments count0
Post likes count1

How do I invoke a verb on an IShellItemArray?

Raymond Chen
Raymond Chen

A customer wanted to invoke a command on multiple items at once. I have an , and I want to invoke a verb with that array as the parameter. I know that I can invoke a verb on a single by the code below, but how do I pass an entire array? The function invokes the command by extracting the pidl, then asking to invoke the command on the pidl...

Code
Sep 17, 2012
Post comments count0
Post likes count1

How do you deal with an input stream that may or may not contain Unicode data?

Raymond Chen
Raymond Chen

Dewi Morgan reinterpreted a question from a Suggestion Box of times past as "How do you deal with an input stream that may or may not contain Unicode data?" A related question from Dave wondered how applications that use to store data could ensure that the data is interpreted in the same code page by the recipient. "If I send a .txt file to a per...

Code
Sep 14, 2012
Post comments count0
Post likes count1

IShellFolder::BindToObject is a high-traffic method; don't do any heavy lifting

Raymond Chen
Raymond Chen

A customer observed that once the user visited their shell extension, Explorer ran really slowly. (Actually, it took a while just to get to this point, but I'll skip the early investigations because they aren't relevant to the story.) Some investigation showed that Explorer's tree view was calling into the shell extension, which was in turn hanging...

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