How to figure out the associated program for specific extension - Programmer

This is a discussion on How to figure out the associated program for specific extension - Programmer ; We have a program that sets environment based on some registry entries specific to our application, and than executes a program passed in as one of the arguments. Currently it uses CreateProcess to execute the program passed in. But the ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: How to figure out the associated program for specific extension

  1. How to figure out the associated program for specific extension

    We have a program that sets environment based on some registry entries
    specific to our application, and than executes a program passed in as
    one of the arguments.

    Currently it uses CreateProcess to execute the program passed in.

    But the CreateProcess function does not allow starting perl scripts.
    For example, if the program I need to start is: "axspmaid.pl", I would
    expect that CreateProcess launched associated program (ActiveState
    Perl) and run the script, but it does not.

    So, what I would like to do is get the associated program for the
    particular executable (based on extension). And than, using
    CreateProcess we can execute "$program $command ...".

    How is it possible to get associated program for a specific extension?

    Thank you for help.
    Alex


  2. Re: How to figure out the associated program for specific extension

    anywherenotes@gmail.com wrote:
    > We have a program that sets environment based on some registry entries
    > specific to our application, and than executes a program passed in as
    > one of the arguments.
    >
    > Currently it uses CreateProcess to execute the program passed in.
    >
    > But the CreateProcess function does not allow starting perl scripts.
    > For example, if the program I need to start is: "axspmaid.pl", I would
    > expect that CreateProcess launched associated program (ActiveState
    > Perl) and run the script, but it does not.
    >
    > So, what I would like to do is get the associated program for the
    > particular executable (based on extension). And than, using
    > CreateProcess we can execute "$program $command ...".
    >
    > How is it possible to get associated program for a specific extension?
    >
    > Thank you for help.
    > Alex
    >

    Double click on "My Computer"
    Tools->Folder Optons->File Types
    Find your extension and "Change" the "Open with" program.
    If there is not your extension there, press "New".

  3. Re: How to figure out the associated program for specific extension

    either I didn't explain the requirement correctly, or you
    misunderdstood, or you're making a joke.

    The program is started like so:

    startupprogram hello.pl

    The progrom "startupprogram" sets environment depending on
    configuration, and than has to envoke "hello.pl", which based on the
    extension is a perl program.

    So the program needs to figure out that .pl is associated with "perl",
    and run: "perl hello.pl".

    It is possible that next time someone runs the program, they pass in
    windows executable, or a shell script (we have MKS to handle KSH
    scripts).


  4. Re: How to figure out the associated program for specific extension

    On 3 May 2005 12:37:07 -0700, anywherenotes@gmail.com wrote:

    >We have a program that sets environment based on some registry entries
    >specific to our application, and than executes a program passed in as
    >one of the arguments.
    >
    >Currently it uses CreateProcess to execute the program passed in.
    >
    >But the CreateProcess function does not allow starting perl scripts.
    >For example, if the program I need to start is: "axspmaid.pl", I would
    >expect that CreateProcess launched associated program (ActiveState
    >Perl) and run the script, but it does not.
    >
    >So, what I would like to do is get the associated program for the
    >particular executable (based on extension). And than, using
    >CreateProcess we can execute "$program $command ...".


    I don't have a real answer for this question. I do know that it has
    been asked and answered before. I also know that ShellExecute is the
    function folks use to "start" a file without needing to look up the
    association. And I know ShellExecute looks in the registry. So I just
    used google (http://groups.google.com/advanced_group_search) to look
    up
    shellexecute registry
    and got 4000 hits. I took a quick look and am pretty sure you'll find
    useful info, but you may need to wade a bit. One of the first few hits
    had a lead to an article about setting up associations; I didn't check
    it but assume it will tell how to change the registry, which should
    give help you read the same section.


    >
    >How is it possible to get associated program for a specific extension?
    >
    >Thank you for help.
    >Alex


    -----------------------------------------
    To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

    Robert E. Zaret, eMVP
    PenFact, Inc.
    500 Harrison Ave., Suite 3R
    Boston, MA 02118
    www.penfact.com

  5. Re: How to figure out the associated program for specific extension

    In article <1115220201.002108.125500@f14g2000cwb.googlegroups. com>,
    anywherenotes@gmail.com writes
    >startupprogram hello.pl
    >
    >The progrom "startupprogram" sets environment depending on
    >configuration, and than has to envoke "hello.pl", which based on the
    >extension is a perl program.
    >
    >So the program needs to figure out that .pl is associated with "perl",
    >and run: "perl hello.pl".


    FindExecutable() will return that path to "perl" given "hello.pl"
    providing that "perl" is the associated program for "*.pl" files. In any
    case ShellExecute() should run the associated program, but if you need
    to use CreateProcess() then FindExecutable() might be just what you
    need.


  6. Re: How to figure out the associated program for specific extension

    WOW, so there is a way to do it.
    FindExecutable() seems to be working just as I needed it to. Only
    thing is I didn't plug it into the real program yet, but simple test
    program finds the executable associated perfectly.


+ Reply to Thread