Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Delphi - add trusted site in IE

Delphi - add trusted site in IE

Delphi - add trusted site in IE

Hi there,

I work for a business who has a large client base spread across the UK. We have to add a specific URL to IE on each of our clients dedicated machines, and they really dont have the staff skills to do it themselves.

I've written a small program to perform all the updates we need done, bar one.

Is is possible to add a trusted site autopmatically from a delphi app. I've seen some VB code which is supposed to be able to do it, but its beyond my comprehension.

Thanks in advance for any responses.

RE: Delphi - add trusted site in IE

A quick look on Google (for trusted sites registry)found this information:

and this (slightly more chatty):

There is also some basic info on writing to the registry at:

The registry key to change is
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains

Given the key, you can add your trusted sites to the registy (read the Delphi help on TRegistry and TRegIniFile).
This is a bit of test code I've created for the task (from the Delphi help example):


procedure TForm1.B_SubmitClick(Sender: TObject);
  KeyName ='Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains';
  Reg: tRegistry; //TRegistry;
  SectionName : string;
  nRestricted : word;

  nIntraNet := 1;
  nTrusted := 2;
  nInternetSites := 3;
  nRestricted := 4;

  Reg := TRegIniFile.Create;  //create the key
  SectionName := E_WebSite.Text;       // This is the web site, without the HTTP - eg microsoft.com
    Reg.RootKey := HKEY_CURRENT_USER; // write to this for all users, HKEY_CURRENT_USER for just the current user
    if Reg.OpenKey(KeyName + '\' + SectionName,TRUE) then  // open the key - the TRUE forces creation if its not there
        Reg.WriteInteger('http', nTrusted); // write the value - http or ftp can be used here

I've tested, but it might need some tweaking and should be straight forward to apply. It will probably have to run from  a script on login for all users to ensure it applies to each of them.

Don't forget to add the Registry unit to your uses clause.

Good luck


RE: Delphi - add trusted site in IE

ChrisGShultz you're right. I've approached the same issue in your way (using registry).  I wrote a simple program to quickly add sites to trusted zones in IE6. Just wanted to be convinced that it worked really. It seemed interesting to me to do that. :). Some trial and error investigations showed to me that for each site added in trusted zones of IE6 assuming site addresses were entered in the format:


protocol = [http|https|ftp]
domain   = [aWord.???|aWord.??.??]
prefix   = zero or more words separated by "."

the following happened:

0. The text after domain is ignored

1. A key with same name as domain entered is added under the  registry key which Chris pointed out:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains

2. If there is a prefix then a subkey with its name is created
   2.1 A value with same name as protocol entered and value 2 is created under the prefix key

3. If there was no prefix than
   3.1 A value with same name as protocol entered and value 2 is created under the domain key

This was my code. Again nothing essentially different from what ChrisGShultz posted.



procedure AddTrustedSite(Site:string);
procedure DecodeSiteName(Site:string;
                         var Protocol:string;
                         var Prefix:string;
                         var Domain:string);


uses Registry, StrUtils;


procedure TForm1.Button1Click(Sender: TObject);
      on e:Exception do
        ShowMessage('Try logging in as Administrator : '+e.Message);

// procedure : AddTrustedSite
// purpose   : Perform in IE6 the equivalent of user actions:
//            - Tools|Internet Options|Security|Trusted|
//              <Type and Add site>
// assumptions:
//      Assumes that the Site is passed in following format:
    [protocol://][{prefix.}...] domain.extension
procedure AddTrustedSite(Site:string);



      if reg.OpenKey(TRUSTED_ZONES_KEY,false) then
          //Make sure the domain is added as a key in the trusted zones

          //If there is a prefix create a subkey of it
          if sPrefix<>'' then

          //Add a value into the current key
          if sProtocol='' then
        raise Exception.Create('Failed to open Trusted Zones registry');


// procedure: DecodeSiteName
// purpose  : Decode given Site string into three parts according
//            to site format specified in AddTrustedSite comments
procedure DecodeSiteName(Site:string;
                         var Protocol:string;
                         var Prefix:string; var Domain:string);
    //Extract the protocol if there is any
    if nPos>0 then

    //Ignore any text after the trailing "/"
    if nPos>0 then


    with slTmp do

      //Are there at least three words in Site Address ??
      if Count>2 then
          //If the last words in the site are less than 2 letters long
          //Then the domain is made out of last three words
          //otherwise it is made out of the last two words
          if (length(Strings[Count-1])<3) and (length(Strings[Count-2])<3) then

          //The prefix is the remaining part of the Site address (if any is left)
          if Count>nDomainWords then


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close