Showing tag results for Code

Jan 31, 2013
Post comments count0
Post likes count0

The somewhat misguided question of whether MapViewOfFile or WriteProcessMemory is faster

Raymond Chen
Raymond Chen

A customer asked, "Which is faster for copying data from one process to another; or ?" This is one of those "Huh?"-type questions, where the customer has solved half of a problem and is looking for help with the other half, the half that makes no sense. First of all, the question is malformed because does not copy any data at all. It takes e...

Code
Jan 30, 2013
Post comments count0
Post likes count0

Why doesn’t HeapValidate detect corruption in the managed heap?

Raymond Chen
Raymond Chen

A customer had a program that was corrupting the managed heap by p/invoking incorrectly. The problem didn't show up until the next garbage collection pass, at which point the CLR got all freaked-out-like. "According to Knowledge Base article 286470, the tool is supposed to catch heap corruption, but it doesn't catch squat." Depending on your po...

Code
Jan 28, 2013
Post comments count0
Post likes count0

Finding a printer, and then creating a shortcut to that printer

Raymond Chen
Raymond Chen

Today's "Little Program" does two things: It looks for a printer in the Printers folder, and then once it finds it, it creates a shortcut to that printer. As is common with "Little Programs", I don't bother with error checking. I'll leave you to do that. Second part first, since it is handy on its own: Creating a shortcut to an arbitrary item ...

Code
Jan 25, 2013
Post comments count0
Post likes count0

When you have a SAFEARRAY, you need to know what it is a SAFEARRAY *of*

Raymond Chen
Raymond Chen

A customer had a problem with SAFEARRAY, or more specifically, with CComSafeArray. CComSafeArray<VARIANT> sa; GetAwesomeArray(&sa); LONG lb = sa.GetLowerBound(); LONG ub = sa.GetUpperBound(); for (LONG i = lb; i <= ub; i++) { CComVariant item = sa.GetAt(i); ... use the item ... } The GetAt method returns a VARIANT&, and wh...

Code
Jan 24, 2013
Post comments count0
Post likes count0

STRICT_TYPED_ITEMIDS is the shell namespace version of the STRICT macro used by USER and GDI

Raymond Chen
Raymond Chen

Starting with the Windows Vista PlatformSDK, defining the symbol before including shell header files changes declarations that previously had simply used now use one of various types which are more clear about what type of ID list is being used. Think of it as the macro for the shell. The more precise names emphasize the form of the ID lis...

Code
Jan 18, 2013
Post comments count0
Post likes count0

What is this rogue version 1.0 of the HTML clipboard format?

Raymond Chen
Raymond Chen

At least as of the time this article was originally written, the HTML clipboard format is officially at version 0.9. A customer observed that sometimes they received HTML clipboard data that marked itself as version 1.0 and wanted to know where they could find documentation on that version. As far as I can tell, there is no official version 1.0...

Code
Jan 16, 2013
Post comments count0
Post likes count0

How do I create a TaskDialog with a progress bar but no cancel button?

Raymond Chen
Raymond Chen

A developer from another group within Microsoft wanted to create a with a progress bar, but they couldn't figure out how to get rid of the Cancel button. "Is there a way to remove all the buttons from a Task Dialog?" Um, users hate it when you give them a window that cannot be closed or cancelled. What should the user do if the reticulatio...

Code
Jan 14, 2013
Post comments count0
Post likes count0

How can I write a script that finds my top-rated photos?

Raymond Chen
Raymond Chen

I'm not sure if I'll be able to keep it up, but I'm going to see if I can make Monday "Little Programs" day, where I solve simple problems with little programs. Today's little program is a script that goes through your Pictures folder and picks out your top-rated photos. The key step here is extracting the rating, which goes by the name Syste...

Code
Jan 11, 2013
Post comments count0
Post likes count0

Understanding errors in classical linking: The delay-load catch-22

Raymond Chen
Raymond Chen

Wrapping up our week of understanding the classical model for linking, we'll put together all the little pieces we've learned this week to puzzle out a linker problem: The delay-load catch-22. You do some code cleanup, then rebuild your project, and you get LNK4199: /DELAYLOAD:SHLWAPI ignored; no imports found from SHLWAPI What does this er...

CodeLinker
Jan 10, 2013
Post comments count0
Post likes count0

Understanding the classical model for linking: Sometimes you don’t want a symbol to come along for a ride

Raymond Chen
Raymond Chen

Continuing our study of the classical model for linking, let's take another look at the trick of taking symbols along for the ride. The technique of taking symbols along for the ride is quite handy if that's what you want, but sometimes you don't actually want it. For example, a symbol taken along for the ride may create conflicts or create unw...

CodeLinker