Intercept clicks from browsers

How do I intercept clicks on certain file-types in IE and Netscape? (like all download-managers does)
jonassondanielAsked:
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.

intheCommented:
hi,
you just need to register your file types in the registry,so when a link to a file of type .txt is clicked it will open in your app instead of notepad.you can use some code liike this to do it:

procedure RegisterFile;

var Reg: TRegistry;

begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CLASSES_ROOT;
    Reg.OpenKey('\.txt', True);
    Reg.WriteString('', 'MyProgram');
    Reg.OpenKey('\MyProgram', True);
    Reg.WriteString('', 'a very special file');
    Reg.OpenKey('\MyProgram\DefaultIcon', True);
    Reg.WriteString('', Application.ExeName + ', 1');
    Reg.OpenKey('\MyProgram\Shell\open\command', True);
    Reg.WriteString('', Application.ExeName + ' "%1"');
    ShowMessage('successfully registered');
  finally
    Reg.Free;
  end;
end;

Regards Barry
0

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
craig_capelCommented:
Your a very clever man Barry :)
0
jonassondanielAuthor Commented:
Yes, that will start my program when a certain file is clicked, but how do I get the file-url and stop IE or Netscape from downloading that file?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

intheCommented:
this stopping should happen automaticaly because your program is handling it..
to get the paths/url call ParamStr(1);

ie:
memo1.lines.add(ParamStr(1));

or in a loop if need be:

var
  I: Word;
begin
  for I := 0 to ParamCount do begin
    memo1.lines.add(ParamStr(I));
   end;
end;
0
DarrinECommented:
the answer to this question is not correct and is a waste of points - does anyone mind if it is deleted and I can reclaim my points  ??

DarrinE
0
intheCommented:

look at the browser helper object here:

http://www.euromind.com/iedelphi/ie5tools/bho.htm

0
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
Delphi

From novice to tech pro — start learning today.