Showing tag results for Code

Dec 27, 2013
Post comments count0
Post likes count1

Brief Q&A on the HeapEnableTerminationOnCorruption heap information flag

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

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

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

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

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

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
Dec 9, 2013
Post comments count0
Post likes count1

Destroying all child processes (and grandchildren) when the parent exits

Raymond Chen

Today's Little Program launches a child process and then just hangs around. If you terminate the parent process, then all the children (and grandchildren and great-grandchildren, you get the idea) are also terminated. The tool for this is the Job Object. Specifically, we mark the job as "kill on job close" which causes all processes in the job ...

Code
Dec 6, 2013
Post comments count0
Post likes count1

Is it wrong to call SHFileOperation from a service?

Raymond Chen

A customer had a simple question: "Is it wrong to call from a service?" I don't know if I'd call it wrong, but I'd call it highly inadvisable. Update: See Is it wrong to call SHFileOperation from a service? Revised.

Code
Dec 4, 2013
Post comments count0
Post likes count1

What's the difference between the wParam of the WM_NOTIFY message and the idFrom in the NMHDR structure?

Raymond Chen

The message takes the following parameters: Notice that the identifier of the control sending the message appears in two places, once in the and again in the . What's the difference? There is no difference. It's just a convenience. The same value is passed in both places, and you can check whichever one is easier for you. You might use the ...

Code