Execute external file

This is a discussion on Execute external file within the C Programming forums, part of the General Programming Boards category; How can i execute an external file without know program location? Example, i will execute a document but i don't ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    7

    Exclamation Execute external file

    How can i execute an external file without know program location?
    Example, i will execute a document but i don't know if ms word is installed.
    Thanks and excuse me for my bad english.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    You shouldn't have to worry about that. Operating Systems like Windows have default applications to open specific file types so you don't have to look for them. You only have to pass the file to the shell and let it do the rest. I'd say look into ShellExecute() in <windows.h> as I think that's C. It might be C++, though. Actually, I guess it has to be C because <windows.h> is all C.

    I also don't know about Linux. They might not have defaults, in which case I have no current answer for you.
    Last edited by SlyMaelstrom; 07-03-2006 at 09:21 AM.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    7
    I tried with ShellExecute like following

    ShellExecute(0,"open","C:\\temp.doc","","",SW_SHOW MAXIMIZED);

    ..and works!!
    Thank you

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 04:53 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 04:44 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21