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?

G S
  • 35,511
  • 22
  • 84
  • 118
  • 8
    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? – G S Mar 14 '10 at 14:20
  • 3
    @Frederick: if you're not programming it, then it's not programming-related. – John Saunders Mar 14 '10 at 14:32
  • 1
    But *somebody* is programming it, right? – G S Mar 14 '10 at 14:42
  • I'm just trying to understand how a computer program -- in this case an OS -- works. Can that not be a justification enough? – G S Mar 14 '10 at 14:44
  • 4
    @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 (http://stackoverflow.com/faq). The link is at the top and bottom of every page, which is a hint. – John Saunders Mar 14 '10 at 14:54
  • It's a question about an internal algorithm of Windows, not about an end-user feature. And programmers, not super users, can answer it. – G S Mar 14 '10 at 15:09
  • @Frederick: have you read the FAQ yet? If you want more understanding of this, take it to meta.stackoverflow.com – John Saunders Mar 14 '10 at 15:13
  • 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. – G S Mar 14 '10 at 15:18
  • 1
    @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. – John Saunders Mar 14 '10 at 15:22
  • 4
    @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. – Sampson Mar 14 '10 at 18:09
  • 3
    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. – Alan Mar 14 '10 at 19:06
  • 1
    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. – G S Mar 15 '10 at 03:48
  • @Alan: any system administrator, and many power users, might wan to know how this works. – John Saunders Mar 15 '10 at 03:48
  • @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. – John Saunders Mar 15 '10 at 03:49
  • 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. – G S Mar 15 '10 at 03:57
  • @Frederick You'll be back in no time. :) – bzlm Mar 15 '10 at 08:01

2 Answers2

7

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.

G S
  • 35,511
  • 22
  • 84
  • 118
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
-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.

perilbrain
  • 7,961
  • 2
  • 27
  • 35