0

Getting straight to the point, I am basically creating a clone of notepad in java and I want to implement this functionality:

Assume I have a file like this with the .txt exention

I procede to right click and select the open with option, where notepad and vscode are also present

What I want is for my application to be here, and I know that I have to edit the registry and add the main executable of my app for every text file associations and I'm pretty confident I can do it with by running the reg command in batch (correct me if I'm wrong).

The part where my personal research was not good enough is actually how to physically implement the open with behavior in my java code, meaning I don't have any "entry points". If only I had the path of the selected file I could call my open() function with that path and the job would be done. However, I don't understand what's going on in the background.

Note: I am still learning batch and windows related topics so I apologize if this is a stupid question

Davide _-
  • 63
  • 1
  • 5
  • Your registration includes a command line. The `%1` placeholder in the command line is where the file name goes. – Raymond Chen Jan 13 '22 at 19:35
  • Could you provide more details please? I don't know what to do practically, where to go etc. Thank you so much – Davide _- Jan 13 '22 at 20:06
  • As I said I'm completely new to this kind of things, maybe some resources to study from could help but I really don't know where to get started – Davide _- Jan 13 '22 at 20:15
  • [How to associate a file extension to the current executable in C#](https://stackoverflow.com/questions/69761/how-to-associate-a-file-extension-to-the-current-executable-in-c-sharp/69826#69826) spells out what to set. Notice that the `emeditor.txt\shell\open\command` has a `%1` in it. That's where the file name will be inserted. – Raymond Chen Jan 13 '22 at 22:04
  • So if I get it correctly, that %1 value is going to be the path of the file that is being opened (when right clicking with open with on the file) which I can then retrieve and do stuff with it right? – Davide _- Jan 14 '22 at 10:02

0 Answers0