 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
JB Guest
|
Posted: Mon Jul 03, 2006 9:59 pm Post subject: opening a Windows application |
|
|
I have a file name stored in my application. I want to be able
to use this file name to open the file using the appropriate
Windows application. (ie the application opened by double
clicking on the file name in Windows Explorer for example.) I then want the opened application to run independently of my
application and be closed as normal by the user.
Is this possible and if so how can I do this?
Your help will be much appreciated.
Thanks, JB |
|
| Back to top |
|
 |
Ed Mulroy Guest
|
Posted: Mon Jul 03, 2006 10:43 pm Post subject: Re: opening a Windows application |
|
|
There are many functions with which you can do that.
Probably the simplest is WinExec. An example is:
WinExec("Notepad.exe", SW_SHOW);
Other functions that also can be used are CreateProcess, ShellExecute,
system and the exec* set of functions. WinExec, CreateProcess and
ShellExecute are documented in the help for Windows and the others are in
the help for C/C++.
.. Ed
| Quote: | JB wrote in message
news:44a94ce4$1 (AT) newsgroups (DOT) borland.com...
I have a file name stored in my application. I want to be able
to use this file name to open the file using the appropriate
Windows application. (ie the application opened by double
clicking on the file name in Windows Explorer for example.) I
then want the opened application to run independently of my
application and be closed as normal by the user.
Is this possible and if so how can I do this?
Your help will be much appreciated. |
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Mon Jul 03, 2006 10:55 pm Post subject: Re: opening a Windows application |
|
|
JB wrote:
| Quote: | I have a file name stored in my application. I want to be able
to use this file name to open the file using the appropriate
Windows application.
|
AnsiString FileName = ..........;
if ( ! FileExists ( FileName ) )
{
ShowMessage ( FileName + "\n\nnot found.");
return;
}
HINSTANCE hinstance = ShellExecute (
NULL
, "open"
, FileName.c_str()
, NULL
, NULL
, SW_SHOWNORMAL
);
if ( (int)hinstance < 32 )
ShowMessage ( FileName + "\n\ncould not be shellexecuted");
Hans. |
|
| Back to top |
|
 |
JB Guest
|
Posted: Tue Jul 04, 2006 3:04 pm Post subject: Re: opening a Windows application |
|
|
Thanks, ShellExecute solves my problem.
Do I assume that with the first parameter set to NULL the
executed application is independent of my application?
Thanks again.
JB
Hans Galema <notused (AT) notused (DOT) nl> wrote:
| Quote: |
AnsiString FileName = ..........;
if ( ! FileExists ( FileName ) )
{
ShowMessage ( FileName + "\n\nnot found.");
return;
}
HINSTANCE hinstance = ShellExecute (
NULL
, "open"
, FileName.c_str()
, NULL
, NULL
, SW_SHOWNORMAL
);
if ( (int)hinstance < 32 )
ShowMessage ( FileName + "\n\ncould not be shellexecuted");
JB wrote:
I have a file name stored in my application. I want to be >> able to use this file name to open the file using the
appropriate Windows application. |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|