This site hosted by Free.ProHosting.com
Google

How can I open another application or file?

Applies To: C++Builder 1 or higher
Category: Knowledge Base

I have the path of an external application. How can I execute this file?
 
 
 1.
  Start a new project using File | New Application.
 
 2.
  Add an Edit. You'll enter there the path of the executable.
 
 3.
  Add a Button. Edit the OnClick event:
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    HINSTANCE res = ShellExecute(Handle, NULL,
        Edit1->Text.c_str(), NULL, NULL, SW_NORMAL);
    if((int)res <= 32)<= 32)
        ShowMessage("Failed");
}
 
 4.
  Insert #include <shellapi.h>.
 
I have the path of a Microsoft Word ® document. How can I open a file with its corresponding application?
 
 1.
  Start a new project using File | New Application.
 
 2.
  Add an Edit. You'll enter there the path of the document.
 
 3.
  Add a Button. Edit the OnClick event:
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    HINSTANCE res = ShellExecute(Handle, "open",
        Edit1->Text.c_str(), NULL, NULL, SW_NORMAL);
    if((int)res <= 32)<= 32)
        ShowMessage("Failed");
}
 
 4.
  Insert #include <shellapi.h>.

C++Builder Developer's Network
Copyright © Yoto Yotov