Click here to Skip to main content
15,905,682 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone know the code to get the filename that is associated with a particular extension

ie: How do I get the file name that the user is using to open a pdf file.

ie: Acrord32.exe.......but it could be CutePdf.exe

Just an example........

I am trying to research vbshell........

Thanks in advance.
Posted
Comments
Smithers-Jones 15-Oct-10 12:51pm    
Do you mean something like this: System.Diagnostics.Process.Start(yourFileName)

1 solution

I got this info from here as an FYI:
http://www.codeproject.com/KB/vb/VBFileAssociation.aspx[^]

So, access the registry and open up the HKEY_CLASSES_ROOT section.

Then, find the key for .pdf

The default value lists the type of file that it is.

Then, open up the key for that type of file in the same section.

This key will have a subkey of shell which has a subkey of open which has a subkey of command.

This command lists the default program used to open the file (in my case, it lists "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" "%1").

And you didn't specify which version of VB (VB6 or .Net) but here's an article that explains accessing the registry using both: Accessing the Registry with VB6 and VB.NET[^]
 
Share this answer
 
v3
Comments
Bryan Holmstrom 15-Oct-10 12:55pm    
Thank you, but I dont want to add or change keys, just find out the filename associated with an extension
William Winner 15-Oct-10 12:57pm    
which is what I explained how to do... so what's your problem?
Marc A. Brown 15-Oct-10 13:27pm    
I wondered what his problem was too, until I followed your first link. That link talks about creating associations. I bet you linked to that to demonstrate the appropriate registry path. I can understand his confusion.
The second link, near bottom of each page, has what he needs to get at HKEY_CLASSES_ROOT from VB6 or VB6.NET (as you said in your original answer).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900