User Tools

Site Tools


associating_20an_20application_20with_20a_20file_20type

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

associating_20an_20application_20with_20a_20file_20type [2018/03/31 13:19]
127.0.0.1 external edit
associating_20an_20application_20with_20a_20file_20type [2018/04/14 20:35] (current)
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Associating an application with a file type===== =====Associating an application with a file type=====
  
-//by Richard Russell, May 2015//\\ \\  The code below associates an application with a particular file type, as indicated by its extension. The extension is specified as **Extension$** (don't forget the dot) and the command used to open files with that extension is specified as **Command$**. The code assumes that the name of the file is passed to the application as a simple command-line parameter.\\ \\  The variable **ProgID$** must be unique to that particular application,​ and this can be most easily achieved by incorporating the extension as part of the name, as shown in the example code (i.e. the extension **.xyz** gives the ProgID **xyzfile**).\\ \\  The code writes to the HKEY_CLASSES_ROOT registry hive and will only run successfully if it has administrative privileges. On Windows Vista or later, with UAC (User Account Control) enabled, this can be most easily achieved by using **Run As Administrator** (either when running the BB4W IDE or the compiled executable, as appropriate).\\ \\  Use this code with care, especially as it can change the association of an existing file type - without prompting for confirmation or otherwise alerting the user.\\ \\ +//by Richard Russell, May 2015//\\ \\  The code below associates an application with a particular file type, as indicated by its extension. The extension is specified as **Extension$** (don't forget the dot) and the command used to open files with that extension is specified as **Command$**. The code assumes that the name of the file is passed to the application as a simple command-line parameter.\\ \\  The variable **ProgID$** must be unique to that particular application,​ and this can be most easily achieved by incorporating the extension as part of the name, as shown in the example code (i.e. the extension **.xyz** gives the ProgID **xyzfile**).\\ \\  The code writes to the HKEY_CLASSES_ROOT registry hive and will only run successfully if it has administrative privileges. On Windows Vista or later, with UAC (User Account Control) enabled, this can be most easily achieved by using **Run As Administrator** (either when running the BB4W IDE or the compiled executable, as appropriate).\\ \\  Use this code with care, especially as it can change the association of an existing file type - without prompting for confirmation or otherwise alerting the user. 
 + 
 +<code bb4w> ​
         REM!WC Windows Constants:         REM!WC Windows Constants:
         HKEY_CLASSES_ROOT=&​80000000         HKEY_CLASSES_ROOT=&​80000000
Line 28: Line 30:
  
         SYS "​RegCloseKey",​ key%         SYS "​RegCloseKey",​ key%
 +</​code>​
 +
associating_20an_20application_20with_20a_20file_20type.txt · Last modified: 2018/04/14 20:35 by richardrussell