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?
-
-
- Start a new project using File | New Application.
-
- Add an Edit. You'll enter there the path of the executable.
-
- 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");
- }
-
- Insert #include <shellapi.h>.
-
- I have the path of a Microsoft Word ® document. How can I open a file with its corresponding application?
-
- Start a new project using File | New Application.
-
- Add an Edit. You'll enter there the path of the document.
-
- 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");
- }
-
- Insert #include <shellapi.h>.
C++Builder Developer's Network
Copyright © Yoto Yotov