Solved

Open App w/File

Posted on 2000-02-24
10
162 Views
Last Modified: 2013-11-20
My application needs to have the user click on a button and open a specific application with a selected file...So that when this application launches the file is opened inside of it..Does anyone know how to do this?

I attempted Shellexecute but all that got me was the application opened w/o the file.
0
Comment
Question by:sandlot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 2556123
How did you use 'ShellExecute()'?

ShellExecute ( NULL, "open", "c:\\mypath\\myfile.doc", NULL, NULL, SW_SHOWNORMAL);

should do it...
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2556232
That sounds like an answer, jkr
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2556239
That sounds like an answer, jkr
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:jkr
ID: 2556369
Well, the 'answer' still implies a question ;-)
0
 

Expert Comment

by:johnxi
ID: 2557202
maybe u can use "WinExec"
0
 
LVL 7

Expert Comment

by:tchalkov
ID: 2557489
ShellExecute searches for the verb you specified in the registry. So if the verb is not defined then you can't open teh document. The verb is nothing more then a command line option definition - if you now how you can run your program from the command line, specifying what document to open  then you can easy define such verb. You can do this through Windows Explorer - Run windows Explorer, choose View\options from the menu and there choos "File Types" or you can write directly to the registry
0
 

Author Comment

by:sandlot
ID: 2558038
I understand how shellexecutes work, I am a little  unfamiliar with registry commands. However in respose to jkr,

ShellExecute ( NULL, "open", "c:\\mypath\\myfile.doc", NULL, NULL, SW_SHOWNORMAL);

that will open myfile.doc with the default doc application, if I am not mistaken, and I need it to open up with a specific application...So here is exactly what I need to do

I have an IshellBrowser Window that navigates to a path on the local drive..where a bunch of image files exist...I have several image applications and the icon for each of these are displayed on different buttons.. when I select a file, and click on a button, I want the application that corresponds to that icon to open the selected file....is this possible, I know I have to go into the registry somehow, but am unsure of how to do this so that I can pass in the selected file..

Thanks for any further comments..  
0
 
LVL 86

Expert Comment

by:jkr
ID: 2558135
>>when I select a file, and click on a button, I want the
>>application that corresponds to that icon to open the
>>selected file

That's exactly how 'ShellExecute()' works - it searches the registry for the specified extension (see 'FindExecutable()') and then invokes the application that is registered for this file type...
0
 

Author Comment

by:sandlot
ID: 2558516
I'm sorry let me clarify again as that snippet that I wrote before is misinforming.... When I select an image file and click on a button( this button will have an icon representing an application)  I have already selected an image file from the ishellbrowser window..this image file when double clicked is viewed as default through explorer right now...and it should stay that way...but when I click on the button it should open this image file with the application corresponding to this button..I will have multiple buttons corresponding to multiple applicaitions and each application has to open this image file..

Can ShellExecute perform this, is this what you were talking about...

sorry for any confusion..
0
 
LVL 8

Accepted Solution

by:
gelbert earned 150 total points
ID: 2558575
You got two options to try:
1. If application which is attached to your button is COM server then try to create it as COM server and load your file using interface which is provided by application(possibly IPersistsFile)
2. If first step failed for any reason then you can try WinExec() (specify name of your application which you want to open file and file name in command line).

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question