Question

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 ?

Was it helpful?

Solution

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>"=""
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top