[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Browser - View Source

When viewing source in Internet Explorer (or other browsers) is there any way to change the application that the source is viewed in (using code). I'd like to use my own text editor rather than Notepad.
I know how to add my own application for adding to 'Edit with' for IE5, by adding to registry, but I can't seem to find anything for view source.
0
xpher
Asked:
xpher
  • 7
  • 5
  • 5
  • +2
1 Solution
 
jeurkCommented:
Hi,
You can find the right occurence in the registry at
HKEY_CLASSES_ROOT\.htm\OpenWithList\Notepad\shell\edit\command

the key there is C:\WINNT\Notepad.exe %1
change it.
or replace notepad with you own exe like
taht :

This is the source of a program
I created to load ultraedit instead of
notepad, it is working perfectly.
If you want handle more things like
printing you have to know that notepad
can be called with params like /p
for printing a file.
under NT notepad stays in \winnt\
and \winnt\system32\
so remember to change the two occurence.

CU


this is only a project. No form.

-------------------------------------
PROGRAM Notepad;

USES
     windows, shellapi, registry;
VAR
     ini: tregistry;
     nimpo: STRING;
     tutu : STRING;
     c:integer;
{$R *.RES}

BEGIN
     ini := tregistry.Create;
     ini.RootKey := HKEY_CLASSES_ROOT;
     ini.OpenKey('', FALSE);
     ini.OpenKey('UltraEdit-32 Document\shell\open\command', FALSE);
     nimpo := ini.readString('');
     nimpo:=copy(nimpo, 2, length(nimpo)-7);
     
     for  c:= 1 to ParamCount do
     begin
       tutu:=tutu+' '+pchar(paramstr(c))
     end;
//     MessageDlg(tutu,mtError,[mbOK],0);
     shellExecute(0, pchar('open'), PChar(nimpo), Pchar(tutu), NIL, SW_SHOWNORMAL);

     ini.Free;
END.
0
 
men xinCEOCommented:
listening..
0
 
LischkeCommented:
Isn't it funny how things come together sometimes :-)) ? We just discussed this stuff in at least one other question...

Ciao, Mike
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
vladikaCommented:
Look also on http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10239730  discussion.
(It is very expensive though :)

This is extract from my comment from those discussion:
First IE5 query for HKLM\Software\Microsoft\Internet Explorer\View Source Editor\Editor Name value from registry.
Then it uses this value to query HKLM\Software\Microsoft\Windows\CurrentVersion\AppPaths\YourEditorName value
If it found your viewer program then it run it. First parameter is html file.
If it cannot found your viewer program it run default viewer (notepad).

Please note that there is error in IE. When IE pass parameter to your program it does not quoted it with " char. This is  error obviously, becouse your program will treat ONLY part of (before first space) file name as html file name.

So you should treat all parameters as one, i.e.
RealFileName := Param(1) + ' ' + Param(2) + ' ' + .. ;// this is just pseudo code

0
 
jeurkCommented:
Yes, the only thing is that the question
lacks about 950 points ;)
0
 
LischkeCommented:
:-))
0
 
vladikaCommented:
I know xpher does not offer me points.
But... Just in case... I received completely from previous question and I don't want more :)
0
 
xpherAuthor Commented:
jeurk

I've done that, that is how I got the edit with using file/Edit with but it has no effect when right clicking and viewing source from popup



xpher
0
 
jeurkCommented:
You are talking about the registry stuff
I suppose.

It's not working because it has not much to do with that. It's working
with shell hooks for the right click
button. I don't know how to override
the standard one.

that's why I came out with the solution of replacing notepad with your own exe.
it's the easyest solution. And
if you want to replace it. You'll probably
no longer use it ?
0
 
xpherAuthor Commented:
Well thanks for your time. If you don't mind I'll delete this question cos it was really the right click view source idea I was after, I allready knew the registry bit.

Regards
xpher
0
 
jeurkCommented:
Strange but I can't find any reference
to a right click stuff problem in your
question. Really strange.
0
 
xpherAuthor Commented:
you right click to view source
0
 
jeurkCommented:
I meaned in the initial question.
0
 
vladikaCommented:
Do you try my idea?
0
 
xpherAuthor Commented:
jeurk
Right click to view source is same as viewing source. The registry idea which I knew allready works for if you go File - Edit with whatever is selected to edit with. This registry idea does not provide means of viewing source, try it in IE3.

vladika
Do I actually have to create the key 'View Source Editor', as I have no entry like that in my registry. I tried creating myself but still got nowhere.

cheers
xpher
0
 
vladikaCommented:
What type of browser do you use? I use IE5.

You can use RegMon utility from www.sysinternals.com to watch all registry-related activity. I used it to monitor IE5 activity.

You should create 'View Source Editor' key under HKLM\Software\Microsoft\Internet Explorer key. Then you should create 'Editor Name' key under 'View Source Editor' key. Then you should set 'Default' value under 'Editor Name' key equal your program name. For example 'WORDPAD.EXE'.

Then you should create HKLM\Software\Microsoft\Windows\CurrentVersion\AppPaths\YourEditorName key and set 'Default' value equal to path to your program. For example on my computer 'Default' value for 'WORDPAD.EXE' key equal to 'C:\Progra~1\Access~1\WORDPAD.EXE'.

After that if you select 'View Source' from menu WordPad will be started. But since there is error in IE5 (description see in previous comment) it will not show html.

In any case try to use RegMon utility to monitor registry-related activity of your browser.

0
 
xpherAuthor Commented:
Thanks I'll give it another try. I personally use IE5, but I would like idea to work with IE3 and up.

cheers
Chris
0
 
xpherAuthor Commented:
Hi vladika
Tried that again, got it to work. I see what you mean about it loading the application but not the file. Strange thing is that if I view source on a file saved to my hard drive it does actually open my app and show the source, yet when online it doesn't. Weird.

The comments you made about parameters is that something that should be added in my programme or something that should be added with registry changes?
Or is that explained in more detail in the other question you mentioned?

Thanks
xpher
0
 
vladikaCommented:
Ok.
There is error in IE5 (I think so). When IE5 runs your program it passes file name as parameter. But it does not  quote file name with " char.

For example it calls
WordPad.exe C:\WinNT\Profiles\Administrator\Temporary Internet Files\Content ......
instead of
WordPad.exe "C:\WinNT\Profiles\Administrator\Temporary Internet Files\Content ......"

In the file path there are spaces (for example: Temporary Internet Files). And your application receive 3 parameters instead of 1.
I.e
1 parameter: C:\WinNT\Profiles\Administrator\Temporary
2 parameter: Internet
3 parameter: Files\Content ......

Your application (and WordPad) use only 1 parameter to locate file and it cannot. You receive error.

So, to fix error you can in your application treat all parameters as one parameter, i.e.
RealFileName := Param(1) + ' ' + Param(2) + ' ' + .. ; // this is pseudo code

I guess that when you open file from hard drive the path of your file does not contain ' ' char (space). For example C:\MyFile.HTM
0
 
xpherAuthor Commented:
Sorry for delay in replying but not been able to surf etc.

cheers
xpher
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 7
  • 5
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now