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.
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.

You can find the right occurence in the registry at

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.


this is only a project. No form.

PROGRAM Notepad;

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

     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
       tutu:=tutu+' '+pchar(paramstr(c))
//     MessageDlg(tutu,mtError,[mbOK],0);
     shellExecute(0, pchar('open'), PChar(nimpo), Pchar(tutu), NIL, SW_SHOWNORMAL);

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

Ciao, Mike
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Look also on  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

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

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

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 ?
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.

Strange but I can't find any reference
to a right click stuff problem in your
question. Really strange.
xpherAuthor Commented:
you right click to view source
I meaned in the initial question.
Do you try my idea?
xpherAuthor Commented:
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.

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.

What type of browser do you use? I use IE5.

You can use RegMon utility from 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.

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

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?

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.
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

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
xpherAuthor Commented:
Sorry for delay in replying but not been able to surf etc.

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.