BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

opening a Windows application

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
JB
Guest





PostPosted: Mon Jul 03, 2006 9:59 pm    Post subject: opening a Windows application Reply with 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. (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





PostPosted: Mon Jul 03, 2006 10:43 pm    Post subject: Re: opening a Windows application Reply with quote



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





PostPosted: Mon Jul 03, 2006 10:55 pm    Post subject: Re: opening a Windows application Reply with quote



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





PostPosted: Tue Jul 04, 2006 3:04 pm    Post subject: Re: opening a Windows application Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.