Get application associated with a file extension (registry?)

  • Thread starter Thread starter Adam Nowotny
  • Start date Start date
A

Adam Nowotny

We use this code to open files such as doc, pdf and html in it's
associated applications, "FileName" is something like
"C:\......\foo.pdf" or "C:\.......\foo.doc".

objProcess = New System.Diagnostics.Process
objProcess.StartInfo.FileName = FileName
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
objProcess.StartInfo.UseShellExecute = True
objProcess.Start()

It worked fine until we noticed that opening and closing some certain
form in our application and then lauching pdf or doc or whatever in
Microsoft apps (IE, Word) causes terrible lags (10-20 seconds!). I
really have no idea, why is that so (lauching through Adobe Acrobat,
Mozilla Firefox works fine, it seems to be a problem in some Microsoft
libraries).

Anyway, we figured out that giving the full path to an application and
the document filename as argument works well, the problem is _how to get
the path to app associated with an extension ?_
I looked a little how the registry is organised, but was hoping someone
has an already tested routine :)
 
* Adam Nowotny said:
We use this code to open files such as doc, pdf and html in it's
associated applications, "FileName" is something like
"C:\......\foo.pdf" or "C:\.......\foo.doc".
[...]
Anyway, we figured out that giving the full path to an application and
the document filename as argument works well, the problem is _how to
get the path to app associated with an extension ?_

PInvoke on 'FindExecutable':

\\\
Private Declare Auto Function FindExecutable Lib "shell32.dll" ( _
ByVal lpFile As String, _
ByVal lpDirectory As String, _
ByVal lpResult As System.Text.StringBuilder _
) As Int32
///
 
Back
Top