How does Windows' 'Open with' work? [closed]
Asked Answered
T

2

14

I was under the impression that when you double click a file (or choose 'Open With' from the right click menu), Windows simply calls the application with the filename as the parameter. Something like this:

C:\> App.exe file.abc

However, I just double clicked an .xls file and then checked the PEB of the Excel instance that sprang up. To my surprise the commandline did not contain the filename as a parameter.

So that set me wondering. What exactly is the mechanism Windows uses to have a file opened by a relevant application? Is there a special API that each application that supports such facility must expose?

Tetraploid answered 14/3, 2010 at 14:11 Comment(16)
To those voting for closure, I wonder how a question about the internal (and that's the key word) workings of an OS is not-programming-related?Tetraploid
@Frederick: if you're not programming it, then it's not programming-related.Natant
But somebody is programming it, right?Tetraploid
I'm just trying to understand how a computer program -- in this case an OS -- works. Can that not be a justification enough?Tetraploid
@Frederick: somebody programmed everything. If you have a question about configuring SQL Server, ask on serverfault.com, even though Microsoft programmed it. If you have a question about advanced use of the chkdsk command, ask on superuser.com, even though Microsoft programmed it. Please read the FAQ (stackoverflow.com/faq). The link is at the top and bottom of every page, which is a hint.Natant
It's a question about an internal algorithm of Windows, not about an end-user feature. And programmers, not super users, can answer it.Tetraploid
@Frederick: have you read the FAQ yet? If you want more understanding of this, take it to meta.stackoverflow.comNatant
John, I've been here for more than a year and I know the rules, and I don't think I'm violating any in this case. Thank you very much for your suggestions, however.Tetraploid
@Frederick: if you feel you know the rules, but want community feedback on your feeling, then meta is exactly the right place. Even I have changed my mind based on feedback from meta.Natant
@Frederick You could make this programming-related, by asking how you could create a similar feature in your own project(s). You would then get many great answers, and very few (if any) close votes. Simply asking how somebody else did it in their program won't end well. None of know exactly how MSFT did it. But if you ask how you can do it, many of us can tell you how to achieve similar results.Jentoft
The answer to this question is only relevant in the context of programming. There's no point in knowing how the OS mechanism works unless you're interested in duplicating it in your own application.Kiely
I don't get this. How can the motive behind the question decide whether it's programming related or not? Shouldn't the content of the question alone dictate that? Secondly, my reason for asking this is nothing more than curiosity. As a kid I used to open up toys for the same reason. Nobody told me, "Before you ask a question about the toy, you've to promise to be a toy-manufaturer one day." I don't understand why people are insisting on something exactly like that here.Tetraploid
@Alan: any system administrator, and many power users, might wan to know how this works.Natant
@Frederick: is there some reason you don't want to bring this to meta? Also, you kind of just condemned the question. It's not a programming question, it's a "I'm curious" question.Natant
John, you make that sound as if the two are mutually exclusive. And no, I'm not taking this to meta. I'm in fact outta here.Tetraploid
@Frederick You'll be back in no time. :)Rawden
S
8

How Windows passes the file to the program varies from one application to another. This behavior is controlled by the registry.

In the case of Excel they use what is called DDE for the purpose. That's why you see nothing on the command line.

Shontashoo answered 14/3, 2010 at 14:17 Comment(0)
E
-1

the filename is not always passed as parameter in actual.

you have with yourself a list of programs associated with some specific file type in ur registry.the system checks for the file extension then starts a process associated with.but always passing it as parameter is not true. The operating system has its own architecture to call a program from its assembly.

Erg answered 14/3, 2010 at 14:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.