描述:
Dll:
STDMETHODIMP CConvertPro::ConvertRtfToText(BSTR a_RtfText, BSTR *a_Text)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
AfxEnableControlContainer();
CString tmpStr;
CMyDlg *pDlg = new CMyDlg;
CRichText *l_rtf = new CRichText ;
int nRes;
//create the main dialog
nRes=pDlg->Create(IDD_DIALOG_MAIN,NULL);
pDlg->ShowWindow(SW_HIDE);
//create the richtext activex
nRes=l_rtf->Create(NULL, WS_VISIBLE, CRect(50,50,100,100), pDlg, 0);
//convert the text to rtf
CString str;
str = a_RtfText;
l_rtf->SetTextRTF(str);
tmpStr = l_rtf->GetText();
*a_Text= tmpStr.AllocSysString();
l_rtf->DestroyWindow();
delete l_rtf;
pDlg->DestroyWindow();
delete pDlg;
return S_OK;
}
ASP调用:
<%@ Language=VBScript %>
<%
option explicit
Response.Expires = 0
Dim objTest
Dim stra,strb,strc
Set objTest = createobject("CONVERTDLL.CONVERTPRO")
stra = "asdfsad ';:}{][|+_) (*&^%$#@!~`12345/.,iamtootired<>中""国"
Response.Write stra
strb = objTest.ConvertTextToRtf(cstr(stra))
Response.Write "<BR></BR>"
Response.Write strb
Response.Write "<BR></BR>"
Set objTest = nothing
%>