Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Open App w/File

Posted on 2000-02-24
10
Medium Priority
?
174 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 600 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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Screencast - Getting to Know the Pipeline
Suggested Courses

610 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