• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 694
  • Last Modified:

TWebBrowser block images

How can I block images from downloading in TWebBrowser?
0
billycl
Asked:
billycl
  • 3
  • 3
1 Solution
 
wildzeroCommented:
This is a setting that you have to tell internet explorer in the registry
This must be done before the application with TWebbrowser is loaded and will also effect any new instances of InternetExplorer.

In the registry
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
Then set "Display Inline Images" to no
or yes to display them

You can do this via the software like

Uses Registry
----

var
Reg : Tregistry;
begin
  Reg:=TRegistry.Create;
  Reg.RootKey:=HKEY_CURRENT_USER;
  Reg.OpenKey('Software\Microsoft\Internet Explorer\Main', False);

  If checkbox1.checked then
    Reg.WriteString('Display Inline Images', 'no') else Reg.WriteString('Display Inline Images', 'yes');

  Reg.Free;
end;

---
That will work with a button and a checkbox

0
 
Eddie ShipmanAll-around developerCommented:
You want to use a MIME Filter:
http://www.euromind.com/iedelphi/app/mimefilter.htm

Heere is the list of the known MIME types:
http://msdn.microsoft.com/workshop/networking/moniker/overview/appendix_a.asp?frame=true#Known_MimeTypes
Find the ones for images and write your filter to handle them.

You can use one temporarily:
Temporary MIME filter (TWebbrowser):


var
Factory: IClassFactory;
InternetSession: IInternetSession;

procedure RegisterMimeFilter;
begin
  CoGetClassObject(Class_OurMimeFilter, CLSCTX_SERVER, nil, IClassFactory, Factory);
  CoInternetGetSession(0, InternetSession, 0);
  InternetSession.RegisterMimeFilter(Factory, Class_OurMimeFilter, 'text/html');
end;

procedure UnRegisterMimeFilter;
begin
  InternetSession.UnregisterMimeFilter(Factory, 'text/html');
end;

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wildzeroCommented:
=)
That looks good! Might have to try that out myself
0
 
Eddie ShipmanAll-around developerCommented:
In essence, you could write a filter to replace images with text or certain size images with others.
Most people write them to filter porn and other undesirable content.

0
 
Eddie ShipmanAll-around developerCommented:
What, a MIME Filter is too much work for you?
0
 
billyclAuthor Commented:
i don't need mime for my program, maybe sometimes later
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now