Showing tag results for Code

Jan 8, 2014
Post comments count0
Post likes count1

The case of the missing context menu verbs

Raymond Chen
Raymond Chen

A customer reported that when they right-clicked a batch file, a bunch of commands were missing. For example, Open was gone! Okay, there really isn't much of a story here, because some direct debugging quickly identified the culprit. The customer had installed a third party shell extension which returned a huge value from its method. Explorer t...

Code
Jan 6, 2014
Post comments count0
Post likes count1

How do I obtain the computer manufacturer's name via C++?

Raymond Chen
Raymond Chen

The way to get the computer manufacturer and other information is to ask WMI. WMI is much easier to use via scripting, but maybe you want to do it from C++. Fortunately, MSDN takes you through it step by step and even puts it together into a sample program. But I'm going to write the code myself anyway. Today's Little Program extracts the c...

Code
Jan 2, 2014
Post comments count0
Post likes count1

If the cursor clip rectangle is a global resource, how come I can't change it with ClipCursor?

Raymond Chen
Raymond Chen

A customer reported that the function was not working. "The cursor clip rectangle is a shared global resource, so I should be able to change it any time I like. My app installs a global mouse hook and sets the clip cursor inside the hook function, but the change doesn't have any effect. Why can't I change the clip cursor inside a mouse hook?" Sur...

Code
Dec 30, 2013
Post comments count0
Post likes count2

How can I get the list of programs the same way that Programs and Features gets it?

Raymond Chen
Raymond Chen

A customer wanted to get the list of programs the same way that the Programs and Features folder gets it. Here, here's an idea: Instead of trying to mimic the Programs and Features folder, just ask the Programs and Features folder for its contents! That way, no matter what changes are made to how the Programs and Features folder obtains its cont...

Code
Dec 27, 2013
Post comments count0
Post likes count1

Brief Q&A on the HeapEnableTerminationOnCorruption heap information flag

Raymond Chen
Raymond Chen

Question: What type of heaps are controlled by the flag? Answer: Any user-mode heap created by the function. This includes the process heap () but not the managed heap. Some components use under the hood. If so, then those heaps would also be affected. Question: What versions of Windows support ? Answer: The flag was introduced in Windows Vi...

Code
Dec 26, 2013
Post comments count0
Post likes count1

Why is GetWindowLongPtr returning a garbage value on 64-bit Windows?

Raymond Chen
Raymond Chen

A customer was running into problems with their application on 64-bit Windows 8. They claimed that on Windows 8, the is returning a garbage pointer, which causes their program to crash. The same program works fine on 64-bit Windows 7. They asked the Windows team why they broke . An investigation of the customer's code quickly tur...

Code
Dec 23, 2013
Post comments count0
Post likes count1

Creating custom tasks on a jump list

Raymond Chen
Raymond Chen

Today's Little Program adds a custom task to the application's jump list. Take the scratch program and make the following changes. (Remember, Little Programs do very little error checking because that's how they roll.) This helper function creates an in-memory shell link object with the specified title, command line arguments, and icon. The u...

Code
Dec 19, 2013
Post comments count0
Post likes count1

How do I display an RTL string in a notification balloon on an LTR system?

Raymond Chen
Raymond Chen

Suppose you have a program that is written in Arabic or Hebrew and you want to render some text. No problem. You just call and pass the flag to say, "Please render this string in an RTL context." Many other text-rendering functions have a similar flag, such as for . But what if you don't control the call to or or whatever other function is ...

Code
Dec 16, 2013
Post comments count0
Post likes count1

Disabling the PrtSc key by blocking input

Raymond Chen
Raymond Chen

A customer asked how to disable the PrtSc key in the On-Screen Keyboard. There is no way to disable the PrtSc key in the On-Screen Keyboard. The On-Screen Keyboard shows a keyboard, and you can click any virtual key you like. There is no policy to remove specific keys from the On-Screen Keyboard. But this was a case of a customer breaking down...

Code
Dec 12, 2013
Post comments count0
Post likes count1

How do you intercept taskbar notification balloons?

Raymond Chen
Raymond Chen

A customer wanted to know how they could monitor and intercept taskbar notification balloons. In particular, they wanted to intercept the clicks on a particular balloon and take alternative action. There is no supported mechanism for intercepting taskbar notification balloons or redirecting clicks on them. Imagine if that were possible: Fabrikam ...

Code