GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Oct-2007, 21:48
DeadOverlord DeadOverlord is offline
New Member
 
Join Date: Oct 2007
Posts: 4
DeadOverlord is on a distinguished road

How to open files outside my program?


Hi to everyone! Excuse me if my english fail.

I`m using C++ Builder 5 to develop a program, i have a .CHF help file and my program need to open it when the user click on "Open help file". But i don`t know how to do that, i only found how to make my program open files for editing, the program need to open that file like if the user have double clicked the file. It need to trigger the same action that the "double click" trigger in the windows, it need to open the file with the default registered program for that file format.

Anyone know how to do something like that?
  #2  
Old 30-Oct-2007, 11:09
doom1992 doom1992 is offline
Junior Member
 
Join Date: Jul 2007
Posts: 98
doom1992 is on a distinguished road

Re: How to open files outside my program?


ive asked this question here before, and didnt get a very good response.
  #3  
Old 30-Oct-2007, 11:37
Kimmo Kimmo is offline
Regular Member
 
Join Date: Mar 2007
Location: Finland
Posts: 347
Kimmo is a jewel in the roughKimmo is a jewel in the roughKimmo is a jewel in the rough

Re: How to open files outside my program?


If I'm correct, the default double click action in Windows is "open." What actually happens with "open" depends on the file type.

If the extension is .exe, Windows knows "a'HA, an executable", if it's a .txt, it might know "notepad on the row for this one" or whatever. This is essentially the same as running the file from the command prompt. Thus, as a poor man's solution I offer this:

CPP / C++ / C Code:
#include <iostream>

using namespace std;

int main()
{
    cout << "Let's open a darn RAR file shall we?!" << endl;

    system("file.rar");

    return 0;
}

I would think there's a more.. Sophisticated method to achieve this. I assume you're developing a GUI application. You might want to consult your reference or ask around on a more specific forum to get the answers you want, since to my knowledge this is not part of C++ standard (I might be wrong, though, what do I know). Doesn't mean you can't ask here, but it means you're probably going to get a better answer elsewhere.
  #4  
Old 30-Oct-2007, 12:31
DeadOverlord DeadOverlord is offline
New Member
 
Join Date: Oct 2007
Posts: 4
DeadOverlord is on a distinguished road

Re: How to open files outside my program?


Thanks Kimmo, like you said i need a metod to do that in the windows GUI, becouse using system("file.rar"); im my GUI program will open the command prompt and then open the file. I need to open the file without the command prompt.
  #5  
Old 30-Oct-2007, 12:59
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 761
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: How to open files outside my program?


You may try ShellExecute( file_name ). I've never messed with it before but it sounds straight-forward.
See http://support.microsoft.com/kb/238245 for details.
  #6  
Old 30-Oct-2007, 20:27
DeadOverlord DeadOverlord is offline
New Member
 
Join Date: Oct 2007
Posts: 4
DeadOverlord is on a distinguished road

Re: How to open files outside my program?


Thanks fakepoo, it is what i wanted. Thanks for the microsoft link, it has lots of infos about that command, i`m using it in my program now, and everting is OK.

In the C++ Builder i`m using the falowing code in the OnClick event of my "Open help file" button:

CPP / C++ / C Code:
ShellExecute(Application->Handle, "open", "help.chm", NULL, NULL, SW_SHOWNORMAL);
 
 

Recent GIDBlogNot selected for officer school by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two-Tier data dissemination code installation problem nidhibansal1984 Computer Software Forum - Linux 6 16-Sep-2007 10:13
malloc/free usage, and general good programming behavior lavaka C Programming Language 7 14-Jun-2007 19:50
BOOKEEPING program, HELP!! yabud C Programming Language 10 17-Nov-2006 03:48
Bloodshed Dev C++ Project Options JdS C++ Forum 6 11-Nov-2005 17:23
Compiling/Linking roostercogburn C Programming Language 5 08-Nov-2005 14:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:13.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.