-1

Windows 7 - I can't associate the executable I'm programming to the file type it create.

I'm using (2 ways) to get the "Open with dialog":

1 -------------------

  • Control Panel - Default Programs - Associate a file type or protocol with a program
  • I select my file extension and then press "Change program"

2 -------------------

  • Double click my document file (which does not have any extension yet)
  • Select "Select a program from a list of installed programs"

In both cases, I get "Open With" dialog.

Problem description: I can browse for my .exe file but when I select it ("Open" in "Open With..." file selection dialog box)... nothing happen. No new file appears in the section of available executable of the "open With" dialog.

Why it does not work ???

Permissions ? Corrupted registry ? New rules ?

Eric Ouellet
  • 10,996
  • 11
  • 84
  • 119

1 Answers1

0

Here is what you should do :

  1. Make sure your application is handling the arguments correctly. When you open an associated file type with an application, It would be equivalent of executing this command in cmd

    YourApp.exe "C:\Path\fileName.ext"

    So C:\Path\fileName.ext would be passed as an argument to your application.

    Your main class should look something like this :

    static void Main(string[] args) { ... }
    

    Check for filePath in args and write the code to load the read the file.

  2. You need to associate file extension with the Application. You can either do it via Control Panel or by browsing the App in Open With window. (This you have already done)

Edit : Try using these registries to associate file type with your application :

[HKEY_CURRENT_USER\Software\Classes\<fileExt>]
@="<fileClass>"

[HKEY_CURRENT_USER\Software\Classes\<fileClass>]
[HKEY_CURRENT_USER\Software\Classes\<fileClass>\OpenWithList]
[HKEY_CURRENT_USER\Software\Classes\<fileClass>\OpenWithList\<appName>]

[HKEY_CURRENT_USER\Software\Classes\Applications\<appName>]
[HKEY_CURRENT_USER\Software\Classes\Applications\<appName>\shell]
[HKEY_CURRENT_USER\Software\Classes\Applications\<appName>\shell\open]
[HKEY_CURRENT_USER\Software\Classes\Applications\<appName>\shell\open\command]
@="\"C:\\Program Files\\appFolder\\<appName>\" \"%1\""
[HKEY_CURRENT_USER\Software\Classes\Applications\<appName>\SupportedTypes]
"<fileExt>"=""
Maverick
  • 791
  • 9
  • 23
  • Thanks. I have already try everything but my configuration has a bug. I'm looking for that thing that won't let met do association which I can't find. I do associated file on any others machines but on my development machine it just don't works. don't know why. – Eric Ouellet Mar 21 '14 at 15:04
  • Try associating the file extension with the application using registry. I've added a sample. – Maverick Mar 24 '14 at 04:10
  • Thank you Maverick. I works now. I removed every thing related to my extension. I Added two new command with a little tool. I did some Microsoft Fix-it. It finally let me do file association normally. I don't know exactly what exactly fixed my problem. But thanks for the information. – Eric Ouellet Mar 24 '14 at 13:45