Article View: borland.public.cppbuilder.nativeapi
Article #9260Re: How to evoke browser for local file relative to exe dir?
From: Bob Gonder
Date: Tue, 20 Jul 2004 22:04
Date: Tue, 20 Jul 2004 22:04
36 lines
2357 bytes
2357 bytes
Randall Parker wrote:
>1) Can I assume that any path passed to a browser will be interpreted as being a
>relative path to the current exe? I'm guessing the answer is NO. So how to find out
>the path of the exe?
See GetModuleFileName()
Then parse out the exe name, leaving the path.
>2) Is there a syntax for a local file URL that all browsers recognize? I see that IE
>doesn't do file:/// for files you open locally but Mozilla does use that syntax.
I use ShellExecuteEx() using "open" and the full path, nothing fancy.
>4) How to convert the local path to URL format with the backslashes converted to
>forward slashes? Is there a routine in a BCB or OS lib that will do this?
Don't think that's needed, but it's easy enough to roll your own.
>5) Is it necessary to do double quoting escapes for paths that have spaces in dir names?
Depends on how you are launching it.
SHELLEXECUTEINFO si={sizeof(SHELLEXECUTEINFO),0};
si.lpVerb = "open";
si.lpFile = fullfilename;
si.lpDirectory = dir;
si.nShow = SW_SHOWNORMAL;
lstrcat(lstrcpy( fullfilename, dir),"\\manual.htm");
ShellExecuteEx(&si);
>6) Is there a way to tell the browser to open a new instance/window/tab rather than
>replace the current page of the browser with the new page?
Perhaps CreateProcess()? In which instance, you would probably want
to add quotes to your path.
Technical Details
Message-ID:
<rq3rf059dvm4fibk69n7lte7lme4eh2mlq@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40fd8196$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,cc0cc83f65df649b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: How to evoke browser for local file relative to exe dir? Date: Tue, 20 Jul 2004 15:04:50 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <rq3rf059dvm4fibk69n7lte7lme4eh2mlq@4ax.com> References: <40fd8196$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 65.41.125.111 X-Trace: newsgroups.borland.com 1090361087 65.41.125.111 (20 Jul 2004 15:04:47 -0700) Lines: 39 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail