?
Solved

Linking txt files

Posted on 1999-11-30
8
Medium Priority
?
199 Views
Last Modified: 2010-04-04
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.

Thanks.
0
Comment
Question by:pablocasta
8 Comments
 
LVL 1

Expert Comment

by:Heapster
ID: 2245704
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.

paul
0
 
LVL 1

Accepted Solution

by:
King_David earned 0 total points
ID: 2245923
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"
begin
  if length(FileType) = 0 then EXIT;
  if length(Association) = 0 then EXIT;
  with TRegistry.Create do
    begin
    if FileType[1] <> '.' then FileType := '.'+FileType;
    RootKey := HKEY_CLASSES_ROOT;
    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');
    Free;
    end;
end;
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2246436
I do some thing like that in an example Delphi program. Program name is Easy note, you can find it in my homepage:

http://homepages.go.com/~azzoz/azzoz.html

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.

Motaz
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 15

Expert Comment

by:simonet
ID: 2246599
>It looks like hard work, doesn't it?

Yes... and 7 points doesn't cover it.
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 2246691
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....

http://members.xoom.com/craig_c/npad.zip
http://members.xoom.com/craig_c/delphi.htm  <my delphi site.
0
 

Author Comment

by:pablocasta
ID: 2248339
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...
Simonet..you're expected to HELP others and not to cry for useless points.
though..
Thanks everybody. :)
0
 
LVL 15

Expert Comment

by:simonet
ID: 2248365
Who's crying for points?

>Simonet..you're expected to HELP
>others

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: forums.borland.com.

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.

Alex
0
 
LVL 1

Expert Comment

by:Heapster
ID: 2248396
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.  

paul
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question