Solved

Open App w/File

Posted on 2000-02-24
10
154 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now