📄 vc6.0调用浏览器访问web.htm
字号:
<TR>
<TD vAlign=top height=13>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=bottom width="50%" height=15><SPAN
class=unnamed1>你的位置: <A
href="http://computer.szptt.net.cn/index.htm">电脑频道</A> > <A
href="http://computer.szptt.net.cn/a5.htm">网上学院</A>> 编程指南
</SPAN></TD>
<TD width="33%" height=15> </TD>
<TD vAlign=bottom width="17%" height=15>
<DIV align=right><IMG height=19
src="VC6.0调用浏览器访问Web.files/botton.gif" width=60
useMap=index.htm#map2 border=0> <MAP name=map2><AREA
title=主页 shape=RECT coords=1,3,17,18
href="http://computer.szptt.net.cn/index.htm"><AREA
title=收藏 shape=RECT coords=23,3,37,16
href="javascript:window.external.addFavorite('http://www.shenzhen.gd.cn','深圳之窗');"><AREA
title=打印 shape=RECT coords=42,3,56,17
href="javascript:print();"></MAP></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD vAlign=top bgColor=#000066 rowSpan=2>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
<TBODY>
<TR>
<TD background=VC6.0调用浏览器访问Web.files/menu.gif height=26>
<P align=center>相关新闻</P></TD></TR>
<TR>
<TD background=VC6.0调用浏览器访问Web.files/left01.gif height=2>
<TABLE width="97%" align=left border=0>
<TBODY>
<TR>
<TD>
<UL>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-28/nw2002032800101.shtml">PHP开发动态WAP页面
</A></P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-28/nw2002032800094.shtml">用VB检测Internet连接
</A></P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-28/nw2002032800089.shtml">用VB控制Outlook发送邮件
</A></P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-28/nw2002032800087.shtml">轻松连接FTP服务器
</A></P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-27/nw2002032700110.shtml">用Delphi编写可以断开Internet连接的程序</A>
</P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-27/nw2002032700108.shtml">改进对象管理方式
提高程序性能</A> </P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-27/nw2002032700106.shtml">改进对象管理方式
提高程序性能1</A> </P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-27/nw2002032700105.shtml">J2EE应用部署(一):基础篇2</A>
</P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-27/nw2002032700104.shtml">J2EE应用部署(一):基础篇1</A>
</P>
<LI>
<P align=left><A
href="http://computer.szptt.net.cn/2002-03-27/nw2002032700020.shtml">用VisuaBasic制作软件启动“封面”
</A></P></LI></UL></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE> </TD>
<TD width="3%" height=2> </TD>
<TD vAlign=top width="74%" height=2><BR>
<TABLE width="92%" align=left border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><B><FONT color=#000080 size=+1>VC6.0调用浏览器访问Web
</FONT></B></DIV></TD></TR>
<TR>
<TD></TD></TR>
<TR>
<TD>
<DIV align=center>
<P><FONT color=#c0c0c0>http://www.szptt.net.cn 2002年3月28日 8:50:09 <A
class=b href="http://www.popunet.com/">大众网络报
</A></P></FONT></DIV> 现在软件的帮助菜单中都有一个类似于在线帮助的菜单,在正常情况下,点击菜单就能直接访问作者的个人网页以获得关于软件的详细信息或升级服务。作者这样做既可以为用户提供方便,又能提高网站的访问率,真可谓一举两得!那么,这种功能是如何实现的呢?笔者经过很多次实验,查阅了很多的相关资料,终于找到一个简单实用的方法。现在借《大众网络报》一角写出来与大家分享。<BR><BR>其实整个设计思想是非常简单的。通过读取注册表,取得Windows默认浏览器的路径名,然后带参数执行默认浏览器,所带的参数即所要调用的主页地址。<BR><BR>附注:Windows默认浏览器的键值在注册表中的具体路径是HKEY_CLASSES_ROOT\htmlfileshell\open\command’。<BR><BR>了解了设计思想后,我们再来看看具体的代码实现过程。在应用程序中添加一个命令按钮。<BR>void
CXHDeskDlg::OnBtnWeb() <BR>{ HKEY hkRoot,hSubKey;
//定义注册表根关键字及子关键字<BR>char ValueName[256];<BR>unsigned char
DataValue[256];<BR>unsigned long cbValueName=256;<BR>unsigned long
cbDataValue=256;<BR>char ShellChar[256]; //定义命令行<BR>DWORD
dwType;<BR>//打开注册表根关键字<BR>if(RegOpenKey(HKEY_CLASSES_ROOT,NULL,&hkRoot)==ERROR_SUCCESS)<BR>{
//打开子关键字
<BR>if(RegOpenKeyEx(hkRoot,"htmlfile\\shell\\open\\command",0,KEY_ALL_ACCESS,&hSubKey)==ERROR_SUCCESS)<BR>{
//读取注册表,获取默认浏览器的命令行<BR>RegEnumValue(hSubKey,
0,ValueName,&cbValueName,NULL,&dwType,DataValue,&cbDataValue);<BR>//
调用参数(主页地址)赋值<BR>strcpy(ShellChar,(char
*)DataValue);<BR>strcat(ShellChar," www.strayhome.com");<BR>//
启动浏览器<BR>WinExec(ShellChar,SW_SHOW);}<BR>else
MessageBox("Web浏览器打开错误!","错误",MB_OK);<BR>}<BR>else
MessageBox("Web浏览器打开错误!","错误",MB_OK);<BR>//关闭注册表<BR>RegCloseKey(hSubKey);<BR>RegCloseKey(hkRoot);<BR>}<BR><BR>看过上面的代码后,你是不是觉得格外简单呢?其实,这本身就不是一件复杂的事。只要我们能掌握程序的实质,确立正确的设计思想,很多看起来复杂的程序,我们也能轻松搞定的。<BR><BR>关于本文介绍的内容,如果你有更好的办法,欢迎与我交流!<BR><BR>以上程序在:Win
XP与VC 6.0环境下调试通过。 <BR></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD width="3%" bgColor=#ffffff height=2> </TD>
<TD class=unnamed1 vAlign=top width="74%" height=2><IMG height=31
src="VC6.0调用浏览器访问Web.files/bottom.gif" width=589 useMap=index.htm#map
border=0></TD></TR>
<TR>
<TD vAlign=top width="23%" bgColor=#000066 height=2> </TD>
<TD width="3%" height=2> </TD>
<TD class=unnamed1 vAlign=top width="74%" height=2>
<DIV align=center>
<P><FONT class=unnamed2 color=#333333><A class=black
href="http://computer.szptt.net.cn/a1.htm">业界动态</A><SPAN
class=black>|</SPAN> <A class=black
href="http://computer.szptt.net.cn/a2.htm">观点评论</A> | <A class=black
href="http://computer.szptt.net.cn/c/a/index.htm">行情报价</A> | <A
class=black href="http://computer.szptt.net.cn/a4.htm">硬件广场</A><SPAN
class=black> <SPAN class=black>|</SPAN> <A class=black
href="http://computer.szptt.net.cn/a5.htm">软件知识</A> <SPAN
class=black>|</SPAN> <A class=black
href="http://software.szwindow.net.cn/">软件下载</A> <SPAN
class=black>|</SPAN> <A class=black
href="http://computer.szptt.net.cn/a6.htm">网上学院</A> <SPAN
class=black>|</SPAN> <A class=black
href="http://computer.szptt.net.cn/h/index.htm">聊天社区</A> <SPAN
class=black>|</SPAN> <A class=black
href="http://computer.szptt.net.cn/free.htm">资源向导</A></SPAN></FONT></P></DIV></TD></TR>
<TR>
<TD vAlign=top width="23%" bgColor=#000066> </TD>
<TD width="3%"> </TD>
<TD class=unnamed1 vAlign=top width="74%"> </TD></TR>
<TR>
<TD vAlign=top width="23%" bgColor=#000066> </TD>
<TD width="3%"> </TD>
<TD class=unnamed1 vAlign=top width="74%">
<DIV align=center><FONT color=#333333>版权所有 深圳市数据通信局</FONT></DIV></TD></TR>
<TR>
<TD vAlign=top width="23%" bgColor=#000066> </TD>
<TD width="3%"> </TD>
<TD class=unnamed1 vAlign=top width="74%">
<DIV align=center><FONT color=#333333>如果你对我们的服务有任何意见或建议</FONT></DIV></TD></TR>
<TR>
<TD vAlign=top width="23%" bgColor=#000066> </TD>
<TD width="3%"> </TD>
<TD class=unnamed1 vAlign=top width="74%">
<DIV align=center><FONT color=#333333>请惠赐email:zginfo@mediaeval.com.cn
szvision@21cn.com</FONT></DIV></TD></TR></TBODY></TABLE><MAP name=map><AREA
shape=RECT coords=478,5,535,22
href="http://computer.szptt.net.cn/2002-03-28/nw2002032800097.shtml#"></MAP><!---- ROBOT Ver 1.0 -----></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -