调用dll问题

gmj_1019 2003-08-19 09:31:41
dll文件 MyDLL.dll已在windows注册了。
asp程序运行成功了(掷色子程序)!
-----------------------------------------------
代码dice.asp:
<html>
<head><title>在ASP文件使用DLL</title></head>
<body>
<%
On Error Resume Next
'当程序出现意外错误时能继续执行

If Request.Form("T1")="" then
Session("point") = 6
Else
Session("point")=Request.Form("T1")
End If
'用Session("point")来存放色子的面数

Set dice1=Server.Createobject("MyDLL.clsDice")
'使用set语句创建dice1对象,其中MyDLL是上面创建dll文件时的工程名称(注意:不是文件的名称),clsDice为类模块的名称。至此我们就可以用Maxpoint,Result和Throw属性(方法)来对dice1对象进行操作。

If Request.ServerVariables("Request_Method")="POST" then
dice1.Maxpoint = Session("point")
'设定色子的面数
dice1.Throw
'掷色子
%>
<form method="POST" action="dice.asp">
<p>当色子的面数为<input type="text" name="T1" size="5" value=<% = session("point") %>>时</p>
<p><input type="submit" value="掷色子" name="B1"></p>
</form>
<p>结果为:<% = dice1.Result %>点 </p>
返回结果
<%
Else
dice1.Maxpoint = Session("point")
%>
<form method="POST" action="dice.asp">
<p>当色子的面数为<input type="text" name="T1" size="5" value=<% = session("point") %>>时</p>
<p><input type="submit" value="掷色子" name="B1"></p>
</form>
<%
End If
%>
</body>
-----------------------------------


同样,我在dice.php运行如下代码:
-------------------------------------------
<?
session_start();
session_register("point");
?>
<html>
<head><title>在php文件使用DLL</title></head>
<body>
<?
//On Error Resume Next
//当程序出现意外错误时能继续执行
//$["bl"];
If ($T1=="")
{
$point=6;
}
Else
{
$point=$T1;
}
//用Session("point")来存放色子的面数

$dice1=new COM("MyDLL.clsDice");
//使用set语句创建dice1对象,其中MyDLL是上面创建dll文件时的工程名称(注意:不是文件的名称),clsDice为类模块的名称。至此我们就可以用Maxpoint,Result和Throw属性(方法)来对dice1对象进行操作。

If ($B1=="掷色子")
{
$dice1->Maxpoint = $point;
//设定色子的面数
$dice1->Throw ;
//掷色子
?>
<form method="POST" action="dice.php">
<p>当色子的面数为<input type="text" name="T1" size="5" value="<?=$point;?>" >时</p>
<p><input type="submit" value="掷色子" name="B1"></p>
</form>
<p>结果为:<?=$dice1->Result;?>点 </p>
返回结果
<?
}
Else
{
$dice1->Maxpoint =$point;
?>
<form method="POST" action="dice.php">
<p>当色子的面数为<input type="text" name="T1" size="5" value="<?=$point;?>" >时</p>
<p><input type="submit" value="掷色子" name="B1"></p>
</form>
<?
}
?>
</body>
------------------------------------------------
但是显示结果总是0
请各位帮帮忙,看看为什么!谢谢!

...全文
71 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2003-08-19
  • 打赏
  • 举报
回复

If ($B1=="掷色子")
{
$dice1->Maxpoint = $point;
//设定色子的面数
$dice1->Throw ;
//掷色子
中,Throw应该是方法吧?
写作$dice1->Throw() ;
gmj_1019 2003-08-19
  • 打赏
  • 举报
回复
???
能不能具体些,谢谢!
xuzuning 2003-08-19
  • 打赏
  • 举报
回复
方法加()
xuzuning 2003-08-19
  • 打赏
  • 举报
回复
可见改了以后是可以的了。尝试修改php.ini中com相关参数。
既然用com当然iis要好些
gmj_1019 2003-08-19
  • 打赏
  • 举报
回复
不行呀,该了之后,程序总出现什么内存不足。apache运行错误!
重启动机器页不行。

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧