none
Associate text file to open with my application RRS feed

  • Question

  • I am trying to associate the text files to open with my application but when I click on a text file then it give  me this error.

    error

    This is the code i use

    Public Sub ChecAssocation()
        Try
            My.Computer.Registry.ClassesRoot.CreateSubKey(".txt").SetValue("", "Mdlabs_Text_editor", Microsoft.Win32.RegistryValueKind.String)
            My.Computer.Registry.ClassesRoot.CreateSubKey("Mdlabs_Text_editor\shell\open\comand").SetValue("", "C:\Program Files\mdlabs_text_editor\editor_de_texto.exe" & " ""%1"" ", Microsoft.Win32.RegistryValueKind.String)
            My.Computer.Registry.ClassesRoot.CreateSubKey("Mdlabs_Text_editorDefaultIcon").SetValue("", "C:\Program Files\mdlabs_text_editor\" & "\my new icon for apps.ico")
        Catch ex As Exception
    
        End Try
    End Sub

    Tuesday, October 30, 2018 5:11 PM

All replies

  • Delete the keys you added to the registry.

    Right Click on any text file and choose "Open With", then "Choose another app", find your prog, and assign   it. Make sure it works every time.

    Look in the registry to see what changes were made, and use those in your code.

    This is my registry for ".txt"
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\.txt]
    @="txtfile"
    "Content Type"="text/plain"
    "PerceivedType"="text"
    
    [HKEY_CLASSES_ROOT\.txt\PersistentHandler]
    @="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
    
    [HKEY_CLASSES_ROOT\.txt\ShellNew]
    "ItemName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,\
      6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,\
      00,6e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,2c,00,\
      2d,00,34,00,37,00,30,00,00,00
    "NullFile"=""
    
    The Item Name part is HEX Unicode for:
    @%SystemRoot%\system32\notepad.exe,-470
    

    • Edited by Devon_Nullman Tuesday, October 30, 2018 5:23 PM addition
    Tuesday, October 30, 2018 5:18 PM
  • Tank you for replay i have try like you have say, and i have export the key user choice but it give me an error wen i try to apply it.

    Tuesday, October 30, 2018 5:25 PM
  • How can i change this line to  open with my app

    @%SystemRoot%\system32\notepad.exe,-470

    this will bee the full path for my app

    C:\Program Files\mdlabs_text_editor\editor_de_texto.exe

    Tuesday, October 30, 2018 5:47 PM