If you hunt around the Internet you’ll find lots of people† who hard-code the string "open"
as the second parameter to the ShellExecute
function, indicating that they want to open the document specified as the third parameter. While that’s a nice thing to want to do, it might not be the right thing.
When the user double-clicks a document, the shell executes the default verb, which is not necessarily “open”. For example, for audio files, the default verb is often “play”, and for pictures, it’s often “view”. If you want to launch the document as if the user had double-clicked it, then you need to pass NULL
as the lpOperation
.
Commenter brad asked how the default verb is determined. This is explained in MSDN in the section titled, not surprisingly, Verbs and File Associations:
The primary verb is specified by the default value of the shell key, or the open key if the shell key has no default value. … The primary verb is also referred to as the default verb.
Nitpicker’s corner
†The phrase “lots of people” means “lots of people”. It doesn’t mean “lots of people not including Microsoft.”
0 comments