In Windows NT/2000/XP, it actually works the same way as Unix, that is, by looking for magic numbers in the file.

There are actually 3 parts of the system that work together -- the NT kernel, the Windows Shell (aka explorer.exe), and the Command Prompt (aka cmd.exe).

When you click on a file in the Shell or type its name into the Prompt, the API function ShellExecute() is called, which looks up the file association in the registry and starts the right program to open that file.

The NT kernel does not care about the file's name. The Kernel is accessed by the API call CreateProcess(), which starts the program by looking for magic numbers (.exe format files start with MZ, .com format files have no magic numbers in them). (The kernel function is actually called NtCreateProcess, but programs should only call CreateProcess because Windows 9x had a different Kernel than the NT family has.)

You can see this in action by renaming helloworld.exe to helloworld. You will not be able to run it from the Command Prompt, but Perl can still run it with system("helloworld"). If you rename it to helloworld.com, it will still work even though the extension is wrong, because the Kernel does not use the file's name.


In reply to Re^2: Perl Directive by bunnyman
in thread Perl Directive by Echo Kilo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.