User Tools

Site Tools


associating_20an_20application_20with_20an_20extension_20_28lbb_29

Differences

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

Link to this comparison view

associating_20an_20application_20with_20an_20extension_20_28lbb_29 [2018/03/31 13:19]
127.0.0.1 external edit
associating_20an_20application_20with_20an_20extension_20_28lbb_29 [2018/04/17 15:10] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //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** and 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 for the LBB IDE or the compiled executable, depending on how it is run).\\ \\  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** and 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 for the LBB IDE or the compiled executable, depending on how it is run).\\ \\  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 lb>
       Extension$ = "​.xyz"​       Extension$ = "​.xyz"​
       ProgID$ = "​xyzfile"​       ProgID$ = "​xyzfile"​
Line 38: Line 39:
       CALLDLL #advapi32, "​RegCloseKey",​ key.handle.struct AS ULONG, _       CALLDLL #advapi32, "​RegCloseKey",​ key.handle.struct AS ULONG, _
         ret AS LONG          ret AS LONG 
 +</​code>​
associating_20an_20application_20with_20an_20extension_20_28lbb_29.txt ยท Last modified: 2018/04/17 15:10 by tbest3112