Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages
Started by JB
Mon, 03 Jul 2006 16:59
opening a Windows application
Author: JB
Date: Mon, 03 Jul 2006 16:59
Date: Mon, 03 Jul 2006 16:59
9 lines
1238 bytes
1238 bytes
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
Re: opening a Windows application
Author: Ed Mulroy
Date: Mon, 03 Jul 2006 17:43
Date: Mon, 03 Jul 2006 17:43
23 lines
1823 bytes
1823 bytes
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
> JB wrote in message
> news:44a94ce4$1@newsgroups.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.
Re: opening a Windows application
Author: Hans Galema
Date: Mon, 03 Jul 2006 17:55
Date: Mon, 03 Jul 2006 17:55
28 lines
1521 bytes
1521 bytes
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.
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.
Re: opening a Windows application
Author: JB
Date: Tue, 04 Jul 2006 10:04
Date: Tue, 04 Jul 2006 10:04
34 lines
1726 bytes
1726 bytes
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@notused.nl> wrote:
>
>
> 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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads