Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2007

Tip: Looking for answers? Try searching our database.

How does 'Open With...' work?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Oliphant - 01 Oct 2007 17:04 GMT
If I use 'Open With...' to open a file (menu option) and choose a program I
wrote, how do I write a MS C++ 2005 Express application to respond to this?

I tried doing this with a program of mine and I got a system error message
(crash). I would assume the filename would be one of the main( ) arguments,
but I'm just guessing. And not sure why it crashed. My program runs fine
ordinarily, and I would have thought trying to open a file with this way
should only run the program since it has no logic to deal with the argument
list. That is, why does it crash when doing this and not ignore the file and
just run?

Thanks in advance for any info!

[==P==]
David Wilkinson - 01 Oct 2007 18:49 GMT
> If I use 'Open With...' to open a file (menu option) and choose a program I
> wrote, how do I write a MS C++ 2005 Express application to respond to this?
[quoted text clipped - 6 lines]
> list. That is, why does it crash when doing this and not ignore the file and
> just run?

Peter:

Open With works by placing entries in the HKCU registry. These entries
override any entries placed in HKCR. However the mechanism for passing
the document filename to the indicated application is the same.

What is happening to you exactly?

Signature

David Wilkinson
Visual C++ MVP

Peter Oliphant - 01 Oct 2007 19:40 GMT
Haven't really put much work into this. But I just tried the experiment of
using an application I created (which is totally unaware of 'Open With') to
try to open a graphic file, and it returned a system error (i.e., the
program crashed).

I'm not in any need or hurry to use this feature, but in the future it might
be somewhat convenient. I'm creating an application that creates pixel data
based on an an image obtained from a file, so opening such a file with the
application directly would save a step (but certainly isn't necessary for my
application)...

[==P==]

>> If I use 'Open With...' to open a file (menu option) and choose a program
>> I wrote, how do I write a MS C++ 2005 Express application to respond to
[quoted text clipped - 15 lines]
>
> What is happening to you exactly?
David Wilkinson - 01 Oct 2007 21:43 GMT
> Haven't really put much work into this. But I just tried the experiment of
> using an application I created (which is totally unaware of 'Open With') to
> try to open a graphic file, and it returned a system error (i.e., the
> program crashed).

Peter:

Well, your application must be prepared to open a file of the desired
type. If it is an MFC doc-view application it should be all set up so
that if your app can open a file using File->Open, it will also open it
from the shell (though perhaps using a new instance, if you have not
taken steps to avoid this).

Signature

David Wilkinson
Visual C++ MVP

Ben Voigt [C++ MVP] - 02 Oct 2007 21:51 GMT
> If I use 'Open With...' to open a file (menu option) and choose a program
> I wrote, how do I write a MS C++ 2005 Express application to respond to
[quoted text clipped - 7 lines]
> the argument list. That is, why does it crash when doing this and not
> ignore the file and just run?

You are correct that it should be provided as a command line argument.

As for why the app crashes, could it because the working directory is
different?  If the program uses private DLLs or loads any files from the
"current" directory it might not find them when run using Open With.

> Thanks in advance for any info!
>
> [==P==]
Peter Oliphant - 04 Oct 2007 21:34 GMT
"As for why the app crashes, could it because the working directory is
different?  If the program uses private DLLs or loads any files from the
"current" directory it might not find them when run using Open With."

Bingo! THAT's why it didn't work! Thanx! :)

[==Peter==]

>> If I use 'Open With...' to open a file (menu option) and choose a program
>> I wrote, how do I write a MS C++ 2005 Express application to respond to
[quoted text clipped - 17 lines]
>>
>> [==P==]

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.