Thread: Execute external file

  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,079
    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 08: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,057
    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, 03:53 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04: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, 08:39 AM