📄 01_9_17_16.asp.html
字号:
<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<TITLE>计算机世界网-如何在InstallShield中使用自己的DLL</TITLE></HEAD>
<style>
.a14{font-size:14px;text-indent:25px;line-height:20px}
.f{font-size:18px;color=#0f3ccd}
img{border:0px;}
td,p,input{font-fammily:verdana,宋体;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>
<center>
<BODY topmargin=2 leftmargin=0>
<style>
.v12{font-size:10pt;color:"#ffffff";FONT-WEIGHT: bold}
.v14{font-size:14px;text-indent:25px;line-height:20px}
img{border:0px;}
td,p,input,select{font-fammily:verdana,宋体;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>
<style>
.v13{font-size:10pt;color:"#ffffff";FONT-WEIGHT: bold}
.v12{font-size:13px;color:"#4C029C";FONT-WEIGHT: bold}
.v14{font-size:14px;text-indent:25px;line-height:20px}
img{border:0px;}
td,p,input,select{font-fammily:verdana,宋体;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>
<!--头-->
<table align=center cellpadding="0" cellspacing="0" border="0" width="767">
<tr><td valign=bottom>
<table cellpadding="0" cellspacing="0" border=0>
<tr><td valign=top><img src="../../../../../center/image/ccwlogo.gif"></td></tr>
<tr><td height="27" valign=top><img src="../../../../../center/image/knowledge.gif" width="207" height="27"></td></tr>
</table></td>
<td valign=bottom width=556 bgcolor="#4c029c" height=96>
<table cellpadding="0" cellspacing="0" border=0 width=556 bgcolor="#4c029c" height=96>
<tr><td height=25 valign=bottom bgcolor="#ffffff" colspan=2 ><img src="../../../../../image2002/top.gif" usemap="#F"></td></tr>
<tr valign=middle >
<td align=center valign=middle height="60" align=center>
<!-- <a href="http://www.ccw.com.cn/search/" target=_blank><img src="../../../../../img2/esearch.GIF" border=0 width=468 height=60></a> --><a href="http://www.ccw.com.cn/html/search/thememail/" target=_blank><img src="../../../../../img2/topbanner_thememail.GIF" border=0 width=468 height=60></a>
</td>
<td align=center width=15%>
<table width=95%>
<tr><td><a href="mailto:center@ccw.com.cn?subject=我要投稿:" target=_blank><font class=v13>我要投稿</a><br><a href="mailto:center@ccw.com.cn?subject=编读往来"><font class=v13>编读往来</a><br><a href="javascript:AddBookMark('计算机世界网首页')"><font class=v13>加入收藏</a></font></td></tr>
</table>
</td>
</tr>
<tr><td bgcolor="#ffffff" height=1 colspan=2 ></td></tr>
<tr><td bgcolor="#b4aafc" height=2 colspan=2 ></td></tr></table>
<map name="F">
<area href="http://www.ccw.com.cn/" shape="rect" coords="29, 3, 61, 18" target=_blank>
<area href="http://www.ccw.com.cn/news1/" shape="rect" coords="72, 3, 143, 18" target=_blank>
<area href="http://www.ccw.com.cn/center/" shape="rect" coords="155, 2, 216, 18" target=_blank>
<area href="http://www.ccw.com.cn/work/" shape="rect" coords="225, 2, 299, 18" target=_blank>
<area href="http://www.ccw.com.cn/search/" shape="rect" coords="310, 3, 364, 19" target=_blank>
<area href="http://www3.ccw.com.cn/" shape="rect" coords="372, 2, 412, 19" target=_blank>
<area href="http://www2.ccw.com.cn/" shape="rect" coords="424, 2, 550, 18" target=_blank></map>
</td></tr>
<tr><td colspan=2 bgcolor="#b4aafc">
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr>
<td width=26% align=center><font class=v12>【2003年6月24日】 </font></td>
<td CLASS=V12> <a href="http://www.ccw.com.cn/center/topic.asp">专 题</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/tech.asp">技 术</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/prod.asp">产 品</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/app.asp">应 用</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/net.asp">网 络</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/prog.asp">编 程</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/skill.asp">技 巧</a> </td>
</tr>
</table>
</td></tr>
</table>
<table align=center width=728>
<tr><td align=center><br><h2><font color='#0f3ccd'>如何在InstallShield中使用自己的DLL</font></h2>
<br><b>郑州工业大学 傅常顺</b>
</td></tr><tr><td align=right>01-9-17 下午 01:10:15<br><hr size=1 width=718 color=#f46240></td></tr></table><br>
<table align=center width=728><tr><td valign=top width=600>
<table width=100% ><tr><td class=a14>作为一个开发人员,当我们为用户开发好应用系统时,就要包装分发自己的程序给最终用户。一般情况下,相应的开发系统中也提供了相应的分发工具,例如Visual Basic6.0中的 [Package & Deployment 向导] ,但是有的开发系统提供的都是英文版的,为了适应中国用户,我们需要选择一款易学易用,界面友好的工具软件,而 InstallShield 就是最好的工具之一。在此我选用的是 InstallShield 5.1 远东专业版本,此版本可以制作出支持多种语言界面的安装程序。 </td></tr></table><table width=100% ><tr><td class=a14>
InstallShield 的功能相当强大,能够对系统和安装需要提供丰富的函数支持,有足够灵活的界面控制支持,而且其脚本语言特点与Visual C++的代码极其相似,非常适合使用Visual C++的开发者使用。 </td></tr></table><table width=100% ><tr><td class=a14>
但是,在某些情况下,InstallShield不能提供能完成某种特殊功能的相应函数,这时需要我们自己开发出能够完成此功能的函数,然后放在InstallShield中调用,达到与其完美的结合,DLL是最佳的选择。 </td></tr></table><table width=100% ><tr><td class=a14>
本文以一个实例介绍了如何生成自己的DLL,以及如何在 InstallShield中调用。 </td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr>
<td class=a14> <b>一、制作DLL: </b></td>
</tr></table><table width=100% ><tr><td class=a14>
此动态库函数主要是显示出传给自己的字符串,并做了改动返回(如果要在InstallShield中使用改动过的字符串,在InstallShield中原型声明时,用POINTER对应LPSTR),并且根据传入的数据返回不同的返回值,用户只要根据此原理实现自己的函数即可: </td></tr></table><table width=100% ><tr><td class=a14>
1、在Visual C++中的 New 中选择 MFC AppWizard(DLL) 工程类型,输入工程名Setup00,点OK,直接 Finish 即可。然后在ClassView中,用鼠标右击Csetup00App,选择Add Member Function…,在Function Type中输入int,在Function Declaration中输入Test(LPSTR lpszStr, int iVal),Access类型选择Public,然后输入下面函数体。 Setup00.DLL的Test函数例码: </td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
int CSetup00App::Test(LPSTR lpszStr, int iVal)</td></tr></table><table width=100% ><tr><td class=a14>
{</td></tr></table><table width=100% ><tr><td class=a14>
AFX_MANAGE_STATE(AfxGetStaticModuleState());</td></tr></table><table width=100% ><tr><td class=a14>
AfxMessageBox(lpszStr);</td></tr></table><table width=100% ><tr><td class=a14>
//如果想改变字符串,用下面方法</td></tr></table><table width=100% ><tr><td class=a14>
strcpy(lpszStr,_T("动态库已经变了字符串"));</td></tr></table><table width=100% ><tr><td class=a14>
if (iVal == 1)</td></tr></table><table width=100% ><tr><td class=a14>
return 1;</td></tr></table><table width=100% ><tr><td class=a14>
else</td></tr></table><table width=100% ><tr><td class=a14>
return 2;</td></tr></table><table width=100% ><tr><td class=a14>
}</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
2、在FileView中,从Source Files中双击 Setup00.def,在代码; Explicit exports can go here的下一行输入: Test @1 </td></tr></table><table width=100% ><tr><td class=a14>
3、选择成Release版本,从 Build 菜单上选择 Build Setup00.dll即可。 </td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr>
<td class=a14> <b>二、在 InstallShield 中使用实例:</b> </td>
</tr></table><table width=100% ><tr><td class=a14>
1、在 Setup Files Pane 中的 Language Independent\Operating System Independent下用 Insert Files 命令添入 Setup00.dll 。这样,你的动态库就可以在制作安装盘时被压入 _user1.cab 中, </td></tr></table><table width=100% ><tr><td class=a14>
如果你没有把DLL放至_user1.cab中,你可以把DLL和你的应用程序放到一块,然后从目标系统中调用。但是,如果你已经做了,你必须指明你要使用的DLL的位置以使安装程序能够找到。而且你必须确信在调用DLL之前它已经被拷贝到预定目录之下。 </td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
2、在脚本程序的程序段中,添加下面代码: </td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
// 声明setp00.dll中的Test函数原型:</td></tr></table><table width=100% ><tr><td class=a14>
prototype INT Setup00.Test( STRING,INT);</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
//如果想要在DLL中改变字符串值,需要将STRING声明成按指针传递,如下: </td></tr></table><table width=100% ><tr><td class=a14>
//prototype INT Setup00.Test( BYREF STRING,INT);</td></tr></table><table width=100% ><tr><td class=a14>
</td></tr></table><table width=100% ><tr><td class=a14>
STRING szDLL, svString;</td></tr></table><table width=100% ><tr><td class=a14>
INT nValue;</td></tr></table><table width=100% ><tr><td class=a14>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -