Opening File using default viewer

Hello, how would I go about opening a file using the default viewer, so
for example, if the file is a txt file, then notepad would open it.  Or
if it is an XML file, then maybe firefox woulld open it.

I was hoping to use a CButton and if the user clicks on it, then it
would grab the path specified and open the file with the corresponding
viewer.  

thanks.

0
TheFakeJon (91)
5/10/2006 9:31:12 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
731 Views

Similar Articles

[PageSpeed] 57

Jon wrote:
> Hello, how would I go about opening a file using the default viewer, so
> for example, if the file is a txt file, then notepad would open it.  Or
> if it is an XML file, then maybe firefox woulld open it.
> 
> I was hoping to use a CButton and if the user clicks on it, then it
> would grab the path specified and open the file with the corresponding
> viewer.  
> 
> thanks.
> 

Typically, you ShellExecute it:

CString fully_qualified_filename = ...
ShellExecute(NULL, _T("open"), fully_qualified_filename, NULL, NULL, 
SW_SHOWNORMAL);
0
hg7946 (4)
5/10/2006 9:52:38 PM
Jon wrote:

> Hello, how would I go about opening a file using the default viewer, so
> for example, if the file is a txt file, then notepad would open it.  Or
> if it is an XML file, then maybe firefox woulld open it.
> 
> I was hoping to use a CButton and if the user clicks on it, then it
> would grab the path specified and open the file with the corresponding
> viewer.  
> 
> thanks.
> 

Jon:

Just use ShellExecute() or ShellExecuteEx() with the file name and 
"Open" operation/verb. The default (file association) application will 
be used to open the file.

David Wilkinson
0
no-reply8010 (1791)
5/10/2006 9:56:13 PM
Thanks for the help

0
TheFakeJon (91)
5/10/2006 10:23:03 PM
Reply:

Similar Artilces:

Having 2 workbooks open simultaneously
I have a wide screen laptop that can accommodate 2 Excel workbooks side by side. I used that feature for a while until sometime about two weeks ago something happened (I don't know what) and now I a only able to keep one workbook open at a time. When I try to open a second one, the first one minimizes. Can anyone tell me how to get it back so that I can once again view 2 workbooks side by side? Many thanks for your help -- Royal Did yesterday's response work: "How about just window|Arrange|Tiled (or whatever you want)" Royal wrote: > > I have a wide screen l...

Default mail account in Outlook 2000
I use Outlook 2000 to send and receive email from several different POP accounts. Sometimes I want to send emails from one account, while other times I want to send them from a different account. I know that Outlook allows you to change which account a message is sent from via the "File | Send Using" menu option. My problem is that I often forget to use that option and just click the "Send" button on the toolbar. This sends out the message using the Default POP account. After it has been sent I remember that I didn't use the "Send Using" option. My quest...

Am I using the pop3 connector properly?
I currently host mail for udc.net on a machine running mailsite. I want to convert everyone over to exchange, but cannot do everyone at once. I believe that I need to use the pop3 connector. All MX records point to the current box running Mailsite. In exchange, I have created a pop3 connector for my own mailbox, and added the SMTP domain and email address for udc.net (so when I send mail, it will show me@udc.net as the from, and return address) I connector definately downloads mail from the pop3 mailbox. But it gets lost. The messages do not appear in my exchange mailbox. If I remove t...

using a UDF in place of a cond. format, b/c I need 4, not three
I know this is an age old topic here, and I'm really hoping that I don't just get referred to another web page [that type of help of course has its place and merits]. And if I had the time, I would have more fun going through docs and notes to find out how to do it, but time is not something I can barter. What I'm looking at is: I'm thinking along the lines of an example where I normally set the borders of my columns [except if it's the first row] in a cond. format via something like this: =AND((NOT(ISBLANK($A1))),(ROW()>1)) But, if I need that space for a Con...

Opening Draft E-mail Outlook 2000
Outlook 2000, Windows XP Pro Outlook hung when two e-mails were open, they are both sttill in Drafts folder. But they cannot be opened, an unknown error is returned when opening. Where are the temp files relating to these e-mails stored? If I open them in wordpad I can copy the contents out. Any ideas? Cheers, Richard Thorneycroft IT Systems Support Husky Group Ltd (01455) 555 340 They are stored in your PST. You can try to export them to another format (File | Import and Export) but those messages are possibly corrupt. "RichardThorneycroft" <richard-deletethis-@huskypr...

Using Rules to Respond to Messages
I'm setting up resource scheduling and like some others have noticed, if a user submits a calendar item to a resource but puts the resource in the required or optional field the calendar has to accept or decline the meeting. Well, your resource is setup to automatically accept resource scheduling and no one is going to read the requests submitted as email. I was thinking I could setup a rule that automatically resonds to the user to tell them that they have selected a resource as a person. Please resubmit this request and put the resource in the resource field. PROBLEM: I can'...

changing the delimiter while saving as txt file
Dear Experts, is there a way to change the delimiter to # instead of tab characters while saving the excel file to .txt file. Thanks in advance Hi see: http://www.cpearson.com/excel/imptext.htm -- Regards Frank Kabel Frankfurt, Germany "raj" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag news:845d01c48520$92fc1c20$a401280a@phx.gbl... > Dear Experts, > > is there a way to change the delimiter to # instead of tab > characters while saving the excel file to .txt file. > > Thanks in advance And some more links... Maybe you can steal some cod...

need to find the file that Outlook emails are stored in
there is one file that contains all the outlook email and information. i need help to find it. also, how can i view Hidden Files? thanks arthur Open Windows Explorer and select Tools | Folder Options. Select Show Hidden Files and Folders and uncheck the option to hide protected operating system files. OK out and open the search panel (f3). If you are using Windows XP, you need to configure the search to look for hidden items. If all goes right, you should find your *.pst file(s) under \documents and settings\<userid>\local settings\application data\microsoft\outlook. -- Neo [...

Graphics and attached file in e-mail activity / quick campaigns e-mails
Hi. We have migrated from Siebel to MS CRM 4.0. We are happy with the decision, but very disappointed by the default options on e-mails, especially e-mails in quick campaigns: - Graphics cannot be inserted, e.g. a company logo - A file, e.g. a PDF, cannot be attached Can anyone help with a workaround, or any tips on a third party add-on / tool that can expand the functionality in CRM? We have tried deferent workarounds: - Export the targets e-mail addresses to Excel. Design the e-mail in Word, and send the e-mails from Word via the Excel list merge. That solves the graphics issue, but...

Purge data based on another Excel file???
I am attempting to purge data from a large list based on data in another document. I have the files I want to remaove in on file and the file I want to remove them from. There should be simple way to do this no? ...

Can't open many XLS files at once
I have Excel 2000 and Win XP pro. I used to be able to highlight many XLS files in Explorer, right click, choose open and all the highlighted files would open in Excel with the different xls files on my task bar. I can still do this on my W98 computer, but I can only open one file at a time on my Win XP computer. If I double click on a 2nd XLS file the 2nd XLS file opens and the first file closes. I tried the run excel.exe /regserv fix but this did not solve the problem. Does anyone know how to fix this for Win XP? Thanks Dennis Hi maybe: Tools - Options - General and uncheck 'Ig...

Access corrupt files DBF?
Access corrupt files DBF? "Frank Dulk" <fdulk@bol.com.br> wrote: >Access corrupt files DBF? What is your question? I see you're from Brazil. Have you asked your question in the Portuguese Access newsgroup? microsoft.public.pt.access. Tony -- Tony Toews, Microsoft Access MVP Please respond only in the newsgroups so that others can read the entire thread of messages. Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ "Frank D...

What's the default for circular logging in Ex2003 on/off?
Thank you -Moises Disabled ie unchecked for lots-o-logs Circular logging was a soultion when storage was expensive. You can get larger drives cheaper now so it shouldn't be enabled if at all possible. -- Hope that helps, Dan Townsend This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send email to this address, post a reply to this newsgroup. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm "MG" <anonymous@discussions.microsoft.com> wrote in message news:1...

Can't change default print resulotion in Publisher 2003
In Publisher 2003, I tried to change the print quality via the "Printer Properties" dialog box, but that didn't change the print resolution. I clicked "Advanced Print Settings..." in the print dialog box, but the only drop-down choice next to "Resolution" is "Default," which doesn't say what the default is but seems to be set at Super-fine. How do I cange the print resolution to Normal or Draft? Thank you. Don Burgess <DonBurgess@discussions.microsoft.com> was very recently heard to utter: > In Publisher 2003, I tried to change...

Invoice Item Posting Account defaults to Cash account instead of Income, Sales account
Great Plains 7.00g12 Our VAR doesn't know the answer to this: Our Invoice Item Posting Account defaults to the 'Cash' account instead of the expected 'Income, Sales' account. We can override this manually for each item in the invoice. After entering an item on the invoice. (I've attached a screen shot) Looking at the distribution in the Sales Distribution Entry window: The Credit shows as type SALES but the Distribution Reference shows as Cash. We cannot figure out why this is happens. Selecting the Sales Item Detail Inquiry Zoom then selecting <Distributio...

Write a tool to generate a PST file with the same structure as old
I will migrate 1000+ users to Exchange 2010 and those users are using OL 2003 and OL2007. To help them migrate more smoothly, I will provide a tool for them to generate PST file with the same structure as an old PST file. Is it possible? How to begin this idea? Thanks, Sam Have you looked at ExMerge? If you are copying a PST file, why do you need to create a copy instead of just using the original PST file? -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "PST TOOL" <PST TOOL@discussions.microsoft....

Removing Campaign Templates and Template Activities from default v
I am trying to figure out how to prevent template activities and campaign templates from showing up in default views in the "Activities" section of CRM as well as the "Advanced Find" and "Regarding" views. ...

Official name of the File Selection Part of CFileDialog
I want to know the official name of the file selection portion of the CFileDialog. I also want to know how this is implemented, is there a special kind of ListBox that can do multiple columns? "Peter Olcott" <NoSpam@SeeScreen.com> wrote in message news:Kw%3h.10768$IC.9812@newsfe21.lga... >I want to know the official name of the file selection portion of the >CFileDialog. I also want to know how this is implemented, is there a >special kind of ListBox that can do multiple columns? List-View http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/list...

Office 2007 Professional: Help Files Issues
Gents, I cannot find a solution to this odd issue and before I submit a support ticket I thought I would ask the community. We have office 2007 professional (volume licensing) on a Window 2003 terminal server. We have a few users out of a bunch that get the "This page is unavailable" I have tried the Refresh and back. I've tried online and offline modes. In offline I get the table of contents to the left but same unavailable message when I click the links. I noticed on testing some other users, that apparently never used the help. That there are some prompts...

EXCEL 2007
I have a GIS application which uses .dbf files (not sure if they are actually Dbase files). When I need to append data (fields) to the files, I have a big problem in that excel 2007 no longer allows save as / export to .dbf files. If I try bring the data in MS Access and save as .dbf files, I have untold problems with the GIS application... The only way I have been successful with this is to find a user with an older version of excel, insert the data as database columns and then save as .dbf Any suggestions as to how I can get around this with out purchasing a converter? ...

RUS does not allow mail boxes to be opened
When creating new user/mail box in AD on our Exchange 2000 server, the RUS generates a smtp address, but when user logs on Outlook reports 'Unable to open your default e-mail folders, you do not have permission to logon'. We have checked ADSI and the setting 'msExchUsserAccountControl' has a value of 'not set'. If you change this to '0', then the mailbox can be opened. Why is RUS not setting this value? We have tried creating new RUS and recepient policy and this does not make any difference. The user has permission to open his own mailbox. We have tried ...

Can Money Deluxe 2006 Read Money Premium File
Can Money Deluxe 2006 read/write a Money Premium 2006 file? Thanks. Bob Mc. In microsoft.public.money, Bob Mc <Bob Mc@discussions.microsoft.com> wrote: >Can Money Deluxe 2006 read/write a Money Premium 2006 file? Yes. ...

How to playing AVI file....
Hi Could anybody please let me know how to play an "AVI" file in MFC Dialog base application. Thanks in advance.... Mujtaba Look at codeproject/codeguru for samples: http://www.codeproject.com/audio/mp3player.asp -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Mujtaba" <tomujtaba@hotmail.com> wrote in message news:8f4f92aa.0502112151.53cecfc9@posting.google.com... > Hi > > Could anybody please let me know how to play an "AVI" file in MFC > Dialog base application. > > Thanks in advance.... > > Mujtaba You can use a CAnimate...

HELP!! Publisher won't open
I have Publisher 2000. When I click on the icon on the desktop, the program opens to the catalog page. When I click on 'existing files'. the program closes down. I can open the existing file in Windows Explorer, but as soon as I click on something, it closes down. This is a relatively new computer running Windows XP Media Center. I have been able to access my existing file before on this system. Can someone please help? Can you open Publisher in Safe Mode? Do you have a default printer enabled? Insert your 2000 disk, select repair. -- Mary Sauer MSFT MVP http://office.micros...

auto number a word document each time it is opened
Hi there, I would like to know how to have a number update automatically each time the document is opened. I have tried all the avenues I know and still have had no luck. I am using word 2003 and have no experience with macros, however I am keen to learn. I am struggling to get the below advice to previous users " http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm. " to work for me. It keeps coming up with error messages after I have created the macro, the main one being "Compile Error: Expected Function or variable" for the "Order =" and then...