Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I would like to have my program ope

Status
Not open for further replies.

VincentP

Programmer
Apr 1, 2001
116
I would like to have my program open an html file at a given anchor point. For example: index.html#stuff

ShellExecute( NULL, "open", "index.html", NULL, NULL, SW_SHOWNORMAL );

works fine, but

ShellExecute( NULL, "open", "index.html#stuff", NULL, NULL, SW_SHOWNORMAL );

does not, since Windows does not find the file "index.html#stuff"...

The file is local. It works fine on internet files if I "execute"
Any ideas?

Vincent
 
I'm sorry I forgot to put a title to my question! Anyhow, I found a workaround, and thought I would share it for all who are interested.

I create a "temporary" .html file containing a redirection instruction to the address containing a #

Code:
FILE * fhtml = fopen( "tmp.html", "wt" );
fprintf( fhtml, &quot;<HTML><HEAD><META HTTP-EQUIV=\&quot;Refresh\&quot; CONTENT=\&quot;0; URL=%s\&quot;></HEAD><BODY>If you are not redirected, <a href=\&quot;%s\&quot;>click here</a>.</BODY></HTML>&quot;, p->strFile, p->strFile );
fclose( fhtml );

ShellExecute( NULL, &quot;open&quot;, &quot;tmp.html&quot;, NULL, NULL, SW_SHOWNORMAL );

p->strFile is a CString containing something like &quot;index.html#stuff&quot;.

It works... but if anyone can think of a way without a redirection, I'll take it!

Vincent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top