Link to home
Start Free TrialLog in
Avatar of ofirg
ofirg

asked on

assign my application to catch double-click on *.tcs file

i have my prog.exe built ov DevStudio C++
I want to have different script files named *.tcs that i can run with my prog.exe

when i double click a tcs file i want my prog.exe to read lines from the clicked tcs file


Avatar of pjknibbs
pjknibbs

Then add the appropriate entries to the Registry. In HKEY_CLASSES_ROOT you'll see dozens of examples of how extensions should be handled, but basically you need to add something like:

HKEY_CLASSES_ROOT\.tcs --Default key should contain something like TCSFile

HKEY_CLASSES_ROOT\TCSFile\shell\open\command --String value which should contain the full path to your executable followed by %1.

If you set it up like this and then double-click a TCS file, your program will be launched with the full pathname of the TCS file as its only command line parameter.

ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"When creating applications, it's often necessary to
store information as a file on the hard drive. You
may choose to create your own extension and then
associate that extension with your application
through Windows.

Basically, you need to add two keys to the registry
under HKEY_CLASSES_ROOT. Say your extension in
".ext", then the first key you add is the
extension itself:  
 
HKEY_CLASSES_ROOT\
    .ext\  

and set the "default" string value of this key to
an "internal name" for your file type - for example
MyApp.Document:  
 

HKEY_CLASSES_ROOT\  
  .ext\  
     Default = "MyApp.Document"  

You then create another key with this name:
 

HKEY_CLASSES_ROOT\  
  MyApp.Document\  

Create a sub-key of this called "shell", a sub-key
of *this* called "open" and a further sub-key of
"open" called "command". The default value uder this
key is the location and name of your your
application folled by "%1" which represents the
filename parameter that Windows will pass to
your executable:

HKEY_CLASSES_ROOT\  
  MyApp.Document\  
    shell\  
      open\  
        command\  
          Default = "C:\myapp\myapp.exe %1"  

"