Linking txt files

I'm making a simple text editor. Everything seems to be fine expect for one thing. How do I link my program so that when somebody double clicks a txt file, my program opens displaying the selected txt file. May be some API will help here, I don't know, that's why I'm asking..
It looks like hard work, doesn't it?
Oh, just one little thing, I don't want to change explorer's setting manually or something like that, I just need code...if anyone accomplishes this, he/she will get the points.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Its the registry you need to be looking at for altering file assocations.  I cant provide code right now (im about to go home), but to get you started, do a search for 'txt' in your registry.  Using the tregistry object you can alter values in your registry as follows. In HKEY_CLASSES_ROOT  there will be an entry for .txt which gives a description of the file type, with a name ('txtfile') and content type('text/plain').  In the same 'directory', there will be an entry for 'txtfile' which says what application to run for opening files, printing, etc.
You need to update the values in this folder (txtfile) to point to your the location of your application.  Its pretty easy to use the registry object, and its worth getting to know.

im using NT btw.

procedure AssiciateFileType(FileType, Association: AnsiString);
// Ex:
//   FileType = '.pas'
//   Association = 'C:\Program Files\Delphi4\Bin\Delphi32.exe'
//   -> '.pas' = "pasFile"
//      pasFiles = "C:\Program Files\Delphi4\Bin\Delphi32.exe %1"
  if length(FileType) = 0 then EXIT;
  if length(Association) = 0 then EXIT;
  with TRegistry.Create do
    if FileType[1] <> '.' then FileType := '.'+FileType;
    OpenKey('\'+FileType, True);
    System.Delete(FileType, 1, 1); // Remove the leading point from FileType.
    WriteString('', FileType+'File');
    OpenKey('\'+FileType+'File\Shell\Open\command', True);
    WriteString('', Association+' %1');

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I do some thing like that in an example Delphi program. Program name is Easy note, you can find it in my homepage:

goto there and see My Delphi programs page.

If you need help about using Windows registry you can find it in my Delphi Electronic Book which will be found there.

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

>It looks like hard work, doesn't it?

Yes... and 7 points doesn't cover it.
yes i thought about this before, the easiest way i can think of is is this..... replace c:\windows\notepad.exe with your program, that way it does it, in your program you must have used something like, paramstr to find out the command line, in order to load the correct text, i wrote a very simple text one, and was going to finish it off but never got round to doing so....  <my delphi site.
pablocastaAuthor Commented:
thanks everybody for trying..but i think King David gave me what i wanted: CODE. Though i will not give him the points till i check the code he provided. (seems to be right, but wou never know)
and...'re expected to HELP others and not to cry for useless points.
Thanks everybody. :)
Who's crying for points?

>'re expected to HELP

No, I am not. As an EXPERT, I am suppose to EXCHANGE information I have for points you have. That's why this place is called Experts-Exchange.

If you don't like the concept, here's a suggestion for you:

You haven't been at E-E long enough. When you have been here long enough, you'll realize that the highest amount of points you assign to a question, the better chances there is that more skilled experts will be assisting you with your questions, not only giving better answers, but giving better answers in shorter times. That's the deal with the points. By assigning very low points to a question, you are diminishing the importance of the question.

7 points is pretty tight - i presume you didnt have many points available?  Simonets point is valid pablocasta, and the points may not be as useless as they seem.  They are our system of exchange/barter.  If you had put up some more points maybe i would have written the code you wanted from the outset - but for 7 points i didnt want to spend even 10 minutes writing and checking some code.  I think the discussion should end there.  

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.