写一个com控件,在控件内有一个字符串,希望ASP调用控件,并把控件内的字符串在网页中显示,但是不能显示任何数据。请各位看看那里出错了。谢谢!代码如下:
COM
STDMETHODIMP CSimple::get_Open(BSTR* pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()); // TODO: Add your implementation code here
BSTR bstr1; 
                bstr1 = SysAllocString(L"hello"); 
*pVal=bstr1; return S_OK;
}ASP代码:ASP
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<%dim OutStr
dim dataWith Request 
     Action = .Form("Action") 'QueryString用于取得客户端浏览器以GET方法提交的各数据值
    
End With Set Comm = CreateObject("Si.Simple") '处理客户端提交' 
With Comm 
    
     Select Case Action 
     Case "Open" 
     data = .Open 
    
     If Len(data) >0 then 
                OutStr = OutStr & "parent.ShowRecv(""" & data & """); " 
     End If 
  
     Case "Close" 
          .Close 
     Case Else 
 
%> <%      End Select 
End With Set Comm = Nothing 
if OutStr <> "" Then Response.Write "<script language=""vbscript"">" & OutStr & "</script>"   '输出 JS 脚本
%></head><body>
<!--#include file="WebSerial.inc"--> 
</body>
</html>HTML代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<style type=text/css> 
TD {font-size: 9pt; font-face:宋体;} 
INPUT {font-size: 9pt; font-face:宋体;} 
TEXTAREA {font-size: 9pt; font-face:宋体;} 
</style> <script language="vbscript"> 
function ModifyStr(strOld, strNew) 
     dim i, c1, c2, asc1, asc2, strret, strlen, strIn      strIn = right(strOld, 1) & strNew 
     strlen = len(strIn) 
     for i = 1 to len(strIn) 
         c1 = mid(strIn, i, 1) 
         asc1 = ascw(c1) 
         if asc1 >= 128 and asc1 <= 255 then 
            if i < strlen then 
                    c2 = mid(strIn, i + 1, 1) 
                    asc2 = ascw(c2) 
                    if asc2 >= 128 and asc2 <= 255 then 
                       strret = strret & chr(clng(asc1 * 256 + asc2))                        i = i + 1 
                    else 
                        strret = strret & c1 
                    end if 
            else 
                strret = strret & c1 
            end if 
          else 
              strret = strret & c1 
    end if 
next 
if len(strOld) > 0 then 
            ModifyStr = left(strOld, len(strOld) - 1) & strret 
else 
    ModifyStr = strret 
end if 
end function 
</script>  
<script language="vbscript"> 
function PostOpenCmd() 

       document.SerialCfgForm.action = "?Action=Open"; 
       document.SerialCfgForm.BtnOpen.disabled = true; 
       document.SerialCfgForm.submit(); 
} function ShowRecv(Content) 

      document.SerialCfgForm.Status.value =ModifyStr(document.SerialCfgForm.Status.value, Content);
    
} </script></head><body>
    <tr> 
       <form  method="POST" action="?Action=Open" name="SerialCfgForm" >
    <td width="60" height="30" align="left">SJ:</td> 
    <td width="160" height="30" align="left">
<input name="Status" type="text" size="36" style=" color:#000000;  border:#6C6967 1px solid;  height:16px;                            vertical-align:middle; line-height:16px;" >
<input type="button" value=" 打开 " name="BtnOpen"
           onclick="vbscript:PostOpenCmd();" />
<input type="button" value="  关闭  " name="cl" 
                           onclick="vbscript:window.close(); return false;" /></td> 
   </tr> 
</body>
</html>