Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Opening files with associated applications?

2 views
Skip to first unread message

mrabie

unread,
Feb 4, 2008, 6:37:38 PM2/4/08
to
Hi all,

I am writing a file explorer application for PocketPC, i use
Systems.Diagnostics Process to start application, but is there a way
to when i click on an image/doc/xls it automatically opens it with the
associated app (image viewer/pocket work/pocket excel,etc)?

I try to pass the file name as the parameter to the Process.Start but
it returns an error

Thanks for your help

Paul G. Tobey [eMVP]

unread,
Feb 4, 2008, 6:43:45 PM2/4/08
to
If nothing else, you could P/Invoke ShellExecuteEx(). That's what the
Explorer shell does (of course, it's native code, so there may be some
wrapper in managed code that I'm not thinking of), when you tap on a
non-executable file.

Paul T.

"mrabie" <mustaf...@gmail.com> wrote in message
news:bb4ae9e1-87b8-46ff...@v67g2000hse.googlegroups.com...

Arun

unread,
Feb 4, 2008, 7:04:13 PM2/4/08
to
You can very well do it using ProcessStartInfo class. Below is a
snippet

Process myProcess = new Process();
myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc";
myProcess.Start();

my.StartInfo.UseShellExecute is another property by default will be
true will start the document in the associated editor.
if it is set to false, the process is created directly from the
executable file.

Hope this helps,
Cheers,
Arun

<ctacke/>

unread,
Feb 4, 2008, 7:02:23 PM2/4/08
to
Set the Process's StartInfo.UseShellExecute property to true.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


"mrabie" <mustaf...@gmail.com> wrote in message
news:bb4ae9e1-87b8-46ff...@v67g2000hse.googlegroups.com...

Christopher Fairbairn

unread,
Feb 4, 2008, 7:03:17 PM2/4/08
to
Hi,

"mrabie" <mustaf...@gmail.com> wrote in message
news:bb4ae9e1-87b8-46ff...@v67g2000hse.googlegroups.com...

> I am writing a file explorer application for PocketPC, i use
> Systems.Diagnostics Process to start application, but is there a way
> to when i click on an image/doc/xls it automatically opens it with the
> associated app (image viewer/pocket work/pocket excel,etc)?

Try using the start info property:

Process p = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(@"\path\to\file.doc", "");
p.StartInfo = startInfo;
p.Start();

This will internally use the native ShellExecuteEx API mentioned by Paul in
another reply to your thread. Hence the file association registry enteries
will be utilised to find the application associated with these files.

Hope this helps,
Christopher Fairbairn

0 new messages