You are here:About>Computing & Technology>Delphi Programming> Coding Delphi Applications> Delphi Tips and Tricks> 2004 Delphi Tips> How to check if a document in a TWebBrowser is located on a local (or network) drive
About.comDelphi Programming
Newsletters & RSSEmail to a friendSubmit to Digg

How to check if a document in a TWebBrowser is located on a local drive

From Zarko Gajic,
Your Guide to Delphi Programming.
FREE Newsletter. Sign Up Now!
If you need to know the location of a document displayed in a TWebBrowser component, you need to get the Protocol property of the IHTMLLocation. Here's a function that returns true if a document in a WebBrowser is stored locally:

~~~~~~~~~~~~~~~~~~~~~~~~~
function WB_DocumentOnLocalDrive(wb: TWebBrowser): boolean;
const
   fileProtocol = 'file:';
var
   protocol : string;
begin
   if Assigned(wb.Document) then
     protocol := wb.Oleobject.Document.Location.Protocol;

   result := protocol = fileProtocol;
end;

Usage:
if WB_DocumentOnLocalDrive(WebBrowser1) then ShowMessage('Document on a local or network drive') ;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to allow column resize but disable movement (in TDBGrid)
« Adding About Delphi Programming site (link and the blog RSS feed) to the Delphi 2005 Welcome page

 All Topics | Email Article | | |
Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.